• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 22:36
CET 04:36
KST 12:36
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Behind the Blue - Team Liquid History Book15Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8herO wins SC2 All-Star Invitational14
Community News
ACS replaced by "ASL Season Open" - Starts 21/0220LiuLi Cup: 2025 Grand Finals (Feb 10-16)26Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2Nexon's StarCraft game could be FPS, led by UMS maker10PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)14
StarCraft 2
General
How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Nexon's StarCraft game could be FPS, led by UMS maker Terran Scanner Sweep Behind the Blue - Team Liquid History Book Weekly Cups (Jan 12-18): herO, MaxPax, Solar win
Tourneys
PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) LiuLi Cup: 2025 Grand Finals (Feb 10-16) RSL Season 4 announced for March-April RSL Revival: Season 4 Korea Qualifier (Feb 14) Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ? [A] Starcraft Sound Mod
External Content
The PondCast: SC2 News & Results Mutation # 512 Overclocked Mutation # 511 Temple of Rebirth Mutation # 510 Safety Violation
Brood War
General
Which units you wish saw more use in the game? ACS replaced by "ASL Season Open" - Starts 21/02 StarCraft player reflex TE scores [ASL21] Potential Map Candidates Gypsy to Korea
Tourneys
[Megathread] Daily Proleagues Escore Tournament StarCraft Season 1 Small VOD Thread 2.0 KCM Race Survival 2026 Season 1
Strategy
Fighting Spirit mining rates Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta
Other Games
General Games
Path of Exile Nintendo Switch Thread Diablo 2 thread Battle Aces/David Kim RTS Megathread ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Ask and answer stupid questions here! European Politico-economics QA Mega-thread The Games Industry And ATVI Russo-Ukrainian War Thread
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
ADHD And Gaming Addiction…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2184 users

The Big Programming Thread - Page 726

Forum Index > General Forum
Post a Reply
Prev 1 724 725 726 727 728 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
May 02 2016 11:04 GMT
#14501
On May 02 2016 12:24 amazingxkcd wrote:
Show nested quote +
On May 02 2016 09:45 Shield wrote:
On May 01 2016 21:00 Manit0u wrote:
On May 01 2016 19:39 bangsholt wrote:
On May 01 2016 03:36 Manit0u wrote:
Since I'm trying to brush up on my C a bit (been years since I last did anything in it) I'm here to ask you guys if this code is acceptable and please point out any errors or give suggestions if you have them.

I've decided to start with something relatively simple - generating an array of numbers in range (eg. irange(1, 3) results in {1, 2, 3}, irange(3, 1) results in {3, 2, 1} etc.). Generating forward and reverse arrays of letters comes next:
+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
// Include stdbool.h to get booleans

// Merge the typedef with the declaration of the struct
typedef struct integer_range integer_range;

integer_range *irange(int start, int end);

struct integer_range {
int length;
int nums[];
};

integer_range *irange(int start, int end)
{
// Use booleans for the next two declarations
int reverse = (end < start);
int size = (reverse ? start - end : end - start) + 1;
size_t mem = sizeof(integer_range) + size * sizeof(int);
integer_range *range = malloc(mem);

// Check return value of malloc.

range->length = size;

for (int i = 0; i < size; i += 1) {
range->nums[i] = reverse ? start - i : start + i;
}

return range;
}

int main(void)
{
integer_range *range = irange(7, -1);

for (int i = 0; i < range->length; i += 1) {
printf("%d\n", range->nums[i];
}

free(range);

return 0;
}


Please don't mind the main function for now. It's just there for testing purposes...


Threw in a few comments in the spoiler for your code.


Thanks. By checking return value of malloc do you mean something like that?


if (range == NULL) {
return -1; // something went wrong
}


I still find it hilarious how you force yourself to do manual memory management and reinvent a basic version of std::vector. Here is your code with more safety (leak-free) that tries to resemble your C variant. That's not how I'd have written it anyway.

+ Show Spoiler +


#include <vector>
#include <iostream>

typedef struct integer_range integer_range;

integer_range irange(int start, int end);

struct integer_range
{
std::vector<int> nums;
};

integer_range irange(int start, int end)
{
bool reverse = end < start;
int size = (reverse ? start - end : end - start) + 1;
integer_range range;

for (int i = 0; i < size; ++i) {
range.nums.push_back(reverse ? start - i : start + i);
}

return range;
}

int main(void)
{
integer_range range = irange(7, -1);

for (const int& num : range.nums) {
std::cout << num << std::endl;
}

return 0;
}



Are you trying to develop operating systems or embedded systems? Why C? "I don't like C++" is not a good reason.


maybe he just wants to use C?


But why limit yourself to an outdated, unsafe language unless it's for embedded systems/operating systems?
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 02 2016 11:16 GMT
#14502
On May 02 2016 20:04 Shield wrote:
Show nested quote +
On May 02 2016 12:24 amazingxkcd wrote:
On May 02 2016 09:45 Shield wrote:
On May 01 2016 21:00 Manit0u wrote:
On May 01 2016 19:39 bangsholt wrote:
On May 01 2016 03:36 Manit0u wrote:
Since I'm trying to brush up on my C a bit (been years since I last did anything in it) I'm here to ask you guys if this code is acceptable and please point out any errors or give suggestions if you have them.

I've decided to start with something relatively simple - generating an array of numbers in range (eg. irange(1, 3) results in {1, 2, 3}, irange(3, 1) results in {3, 2, 1} etc.). Generating forward and reverse arrays of letters comes next:
+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
// Include stdbool.h to get booleans

// Merge the typedef with the declaration of the struct
typedef struct integer_range integer_range;

integer_range *irange(int start, int end);

struct integer_range {
int length;
int nums[];
};

integer_range *irange(int start, int end)
{
// Use booleans for the next two declarations
int reverse = (end < start);
int size = (reverse ? start - end : end - start) + 1;
size_t mem = sizeof(integer_range) + size * sizeof(int);
integer_range *range = malloc(mem);

// Check return value of malloc.

range->length = size;

for (int i = 0; i < size; i += 1) {
range->nums[i] = reverse ? start - i : start + i;
}

return range;
}

int main(void)
{
integer_range *range = irange(7, -1);

for (int i = 0; i < range->length; i += 1) {
printf("%d\n", range->nums[i];
}

free(range);

return 0;
}


Please don't mind the main function for now. It's just there for testing purposes...


Threw in a few comments in the spoiler for your code.


Thanks. By checking return value of malloc do you mean something like that?


if (range == NULL) {
return -1; // something went wrong
}


I still find it hilarious how you force yourself to do manual memory management and reinvent a basic version of std::vector. Here is your code with more safety (leak-free) that tries to resemble your C variant. That's not how I'd have written it anyway.

+ Show Spoiler +


#include <vector>
#include <iostream>

typedef struct integer_range integer_range;

integer_range irange(int start, int end);

struct integer_range
{
std::vector<int> nums;
};

integer_range irange(int start, int end)
{
bool reverse = end < start;
int size = (reverse ? start - end : end - start) + 1;
integer_range range;

for (int i = 0; i < size; ++i) {
range.nums.push_back(reverse ? start - i : start + i);
}

return range;
}

int main(void)
{
integer_range range = irange(7, -1);

for (const int& num : range.nums) {
std::cout << num << std::endl;
}

return 0;
}



Are you trying to develop operating systems or embedded systems? Why C? "I don't like C++" is not a good reason.


maybe he just wants to use C?


But why limit yourself to an outdated, unsafe language unless it's for embedded systems/operating systems?


While I do agree with your statement for the most part, sometimes people just prefer a language over another language, even if that language is just a subset of a more modern language. People have preferences that don't always have to make sense or fit into our world view.

C, while it's indeed a bit outdated, is not a bad language as such and you can always learn a bit more about memory management from working with it, so it's not the worst language to program in.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
May 02 2016 12:19 GMT
#14503
On May 02 2016 02:59 WarSame wrote:
Show nested quote +
On April 29 2016 17:08 Djagulingu wrote:
On April 27 2016 23:42 WarSame wrote:
On April 27 2016 18:41 Wrath wrote:
On April 27 2016 10:43 WarSame wrote:
Folks, looking for a bit of help with mean.io. I dled and installed node, mongodb and git. I then init a directory and run npm install inside of it. I then run gulp to start the server. This throws errors that I'm missing various modules such as 'mongoose', 'async', etc. but these should be installed from the npm install, correct? The exact error is + Show Spoiler +
E:\mean_workspace\monoprobability\node_modules\q\q.js:155
throw e;
^

Error: Cannot find module 'mongoose'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\server\models\user.js:6:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at requireModel (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:116:19)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:21:7
at Array.forEach (native)
at walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:23:7
at Array.forEach (native)
at Object.walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at MeanUserKlass.Module (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:134:14)
at new MeanUserKlass (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:10:10)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:21:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Module.activate (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\dependablelist.js:52:15)



When I tried to start using mean.io on another computer it worked fine so it is almost certainly a problem with my current environment. When I look inside of my root's node_modules folder it is missing both 'async' and 'mongoose'. Are they supposed to be in that folder?


Can't you copy them from the other computer and see if that solves the issue for you?

The other computer is a work computer which disables copying files :/

On April 27 2016 19:43 Acrofales wrote:
On April 27 2016 10:43 WarSame wrote:
Folks, looking for a bit of help with mean.io. I dled and installed node, mongodb and git. I then init a directory and run npm install inside of it. I then run gulp to start the server. This throws errors that I'm missing various modules such as 'mongoose', 'async', etc. but these should be installed from the npm install, correct? The exact error is + Show Spoiler +
E:\mean_workspace\monoprobability\node_modules\q\q.js:155
throw e;
^

Error: Cannot find module 'mongoose'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\server\models\user.js:6:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at requireModel (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:116:19)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:21:7
at Array.forEach (native)
at walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:23:7
at Array.forEach (native)
at Object.walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at MeanUserKlass.Module (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:134:14)
at new MeanUserKlass (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:10:10)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:21:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Module.activate (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\dependablelist.js:52:15)



When I tried to start using mean.io on another computer it worked fine so it is almost certainly a problem with my current environment. When I look inside of my root's node_modules folder it is missing both 'async' and 'mongoose'. Are they supposed to be in that folder?


Is your internet stable, and no timeout problems? I've had issues with npm skipping stuff if it cannot get it sufficiently quickly, and then claiming success all the same. rerunning npm install usually works, but sometimes it's really confused and you need to throw away your node_modules and start again. either that, or your package.json is wrong.

Yup, my internet is pretty stable here. I've run the command like 5 times in a row and I've deleted and reinited the app ~5 times too, so that shouldn't be it. My package.json is simply the default mean.io package, so it should be fine.

I know it's a dumb question but... Does your package.json have async and mongoose in dependencies section? The only other thing I can think about is async and mongoose getting deleted from central npm repo. I don't think internet connection creates major issues because I might be having one of the shittiest internet connections in the entire thread and still didn't have any issues with npm claiming success but not downloading dependencies. Regardless, you can run:

npm install --save async mongoose 


and solve your problem that way.

It now starts the server, looks like it's going fine and then refuses to serve the pages. :/ Not sure why it's doing that... This is the same thing that happened last time I tried to manually install the packages.

Dafaq?

Can you link me your github/bitbucket so that I can check out your code?
"windows bash is a steaming heap of shit" tofucake
tofucake
Profile Blog Joined October 2009
Hyrule19192 Posts
May 02 2016 12:45 GMT
#14504
Saving things is usually done by a database, so there will be a PHP (or python or asp or ruby) layer you'll need to interact with.
Liquipediaasante sana squash banana
Acrofales
Profile Joined August 2010
Spain18215 Posts
May 02 2016 13:31 GMT
#14505
On May 02 2016 21:45 tofucake wrote:
Saving things is usually done by a database, so there will be a PHP (or python or asp or ruby) layer you'll need to interact with.

Or you use nodejs, which does db access itself. But yeah. You have some kind if backend that your front end JS has to interact with.
Manit0u
Profile Blog Joined August 2004
Poland17661 Posts
Last Edited: 2016-05-02 15:37:00
May 02 2016 15:14 GMT
#14506
On May 02 2016 20:04 Shield wrote:
Show nested quote +
On May 02 2016 12:24 amazingxkcd wrote:
On May 02 2016 09:45 Shield wrote:
On May 01 2016 21:00 Manit0u wrote:
On May 01 2016 19:39 bangsholt wrote:
On May 01 2016 03:36 Manit0u wrote:
Since I'm trying to brush up on my C a bit (been years since I last did anything in it) I'm here to ask you guys if this code is acceptable and please point out any errors or give suggestions if you have them.

I've decided to start with something relatively simple - generating an array of numbers in range (eg. irange(1, 3) results in {1, 2, 3}, irange(3, 1) results in {3, 2, 1} etc.). Generating forward and reverse arrays of letters comes next:
+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
// Include stdbool.h to get booleans

// Merge the typedef with the declaration of the struct
typedef struct integer_range integer_range;

integer_range *irange(int start, int end);

struct integer_range {
int length;
int nums[];
};

integer_range *irange(int start, int end)
{
// Use booleans for the next two declarations
int reverse = (end < start);
int size = (reverse ? start - end : end - start) + 1;
size_t mem = sizeof(integer_range) + size * sizeof(int);
integer_range *range = malloc(mem);

// Check return value of malloc.

range->length = size;

for (int i = 0; i < size; i += 1) {
range->nums[i] = reverse ? start - i : start + i;
}

return range;
}

int main(void)
{
integer_range *range = irange(7, -1);

for (int i = 0; i < range->length; i += 1) {
printf("%d\n", range->nums[i];
}

free(range);

return 0;
}


Please don't mind the main function for now. It's just there for testing purposes...


Threw in a few comments in the spoiler for your code.


Thanks. By checking return value of malloc do you mean something like that?


if (range == NULL) {
return -1; // something went wrong
}


I still find it hilarious how you force yourself to do manual memory management and reinvent a basic version of std::vector. Here is your code with more safety (leak-free) that tries to resemble your C variant. That's not how I'd have written it anyway.

+ Show Spoiler +


#include <vector>
#include <iostream>

typedef struct integer_range integer_range;

integer_range irange(int start, int end);

struct integer_range
{
std::vector<int> nums;
};

integer_range irange(int start, int end)
{
bool reverse = end < start;
int size = (reverse ? start - end : end - start) + 1;
integer_range range;

for (int i = 0; i < size; ++i) {
range.nums.push_back(reverse ? start - i : start + i);
}

return range;
}

int main(void)
{
integer_range range = irange(7, -1);

for (const int& num : range.nums) {
std::cout << num << std::endl;
}

return 0;
}



Are you trying to develop operating systems or embedded systems? Why C? "I don't like C++" is not a good reason.


maybe he just wants to use C?


But why limit yourself to an outdated, unsafe language unless it's for embedded systems/operating systems?


Because all I want to do is just refresh my memory of it and brush up on it a bit. It provides a nice counter-balance to all of the objective, functional and otherwise highly abstract stuff I get to work with on a daily basis. I really like its simplicity and purity. It can teach you some solid practices and how to tackle your programs from a different angle.

On a side note, if anyone is working with PHP and has to make use of DOMDocument class here's a helper function I've devised that makes it much less of a hassle to build xml/html documents without resorting to string concatenation:


function buildNodesFromArray(\DOMDocument $document, $nodeName, array $nodeElements)
{
$node = $document->createElement($nodeName);

foreach ($nodeElements as $key => $value) {
if (is_array($value)) {
if (is_int($key)) { // array of arrays
$key = key($value);
$value = array_shift($value);
}

if (is_array($value)) {
$subNode = buildNodesFromArray($document, $key, $value);

$node->appendChild($subNode);
} else {
$node->appendChild(createNode($document, $key, $value));
}
} else {
$node->appendChild(createNode($document, $key, $value));
}
}

return $node;
}

function createNode(\DOMDocument $document, $key, $value)
{
if (null === $value || '' === $value) { // empty node
$emptyValue = $document->createTextNode('');
$element = $document->createElement($key);
$element->appendChild($emptyValue);
} else {
$element = $document->createElement($key, $value);
}

return $element;
}


Example usage:


$data = [
'items' => [
['item' => null],
['item' => 0],
['item' => 1],
['item' => 2],
],
];
$document = new \DOMDocument('1.0', 'UTF-8');
$nodes = buildNodesFromArray($document, 'list', $data);

$document->appendChild($nodes);

$xml = $document->saveXML();

// output:
<?xml version="1.0" encoding="UTF-8"?>
<list>
<items>
<item></item>
<item>0</item>
<item>1</item>
<item>2</item>
</items>
</list>


It takes care of typical problems like having multiples of the same key or empty nodes that you'd still want in your DOM. Not dealing with attributes just yet.

I must say I'm quite surprised how often I'm using this helper now since I've created the initial version of it 5 months ago just to solve the empty node problem I've run into (and found related question on SO).
Time is precious. Waste it wisely.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
May 03 2016 02:32 GMT
#14507
On May 02 2016 21:19 Djagulingu wrote:
Show nested quote +
On May 02 2016 02:59 WarSame wrote:
On April 29 2016 17:08 Djagulingu wrote:
On April 27 2016 23:42 WarSame wrote:
On April 27 2016 18:41 Wrath wrote:
On April 27 2016 10:43 WarSame wrote:
Folks, looking for a bit of help with mean.io. I dled and installed node, mongodb and git. I then init a directory and run npm install inside of it. I then run gulp to start the server. This throws errors that I'm missing various modules such as 'mongoose', 'async', etc. but these should be installed from the npm install, correct? The exact error is + Show Spoiler +
E:\mean_workspace\monoprobability\node_modules\q\q.js:155
throw e;
^

Error: Cannot find module 'mongoose'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\server\models\user.js:6:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at requireModel (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:116:19)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:21:7
at Array.forEach (native)
at walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:23:7
at Array.forEach (native)
at Object.walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at MeanUserKlass.Module (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:134:14)
at new MeanUserKlass (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:10:10)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:21:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Module.activate (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\dependablelist.js:52:15)



When I tried to start using mean.io on another computer it worked fine so it is almost certainly a problem with my current environment. When I look inside of my root's node_modules folder it is missing both 'async' and 'mongoose'. Are they supposed to be in that folder?


Can't you copy them from the other computer and see if that solves the issue for you?

The other computer is a work computer which disables copying files :/

On April 27 2016 19:43 Acrofales wrote:
On April 27 2016 10:43 WarSame wrote:
Folks, looking for a bit of help with mean.io. I dled and installed node, mongodb and git. I then init a directory and run npm install inside of it. I then run gulp to start the server. This throws errors that I'm missing various modules such as 'mongoose', 'async', etc. but these should be installed from the npm install, correct? The exact error is + Show Spoiler +
E:\mean_workspace\monoprobability\node_modules\q\q.js:155
throw e;
^

Error: Cannot find module 'mongoose'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\server\models\user.js:6:17)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at requireModel (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:116:19)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:21:7
at Array.forEach (native)
at walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:23:7
at Array.forEach (native)
at Object.walk (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\util.js:16:25)
at MeanUserKlass.Module (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\index.js:134:14)
at new MeanUserKlass (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:10:10)
at Object.<anonymous> (E:\mean_workspace\monoprobability\node_modules\meanio-users\app.js:21:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Module.activate (E:\mean_workspace\monoprobability\node_modules\meanio\lib\core_modules\module\dependablelist.js:52:15)



When I tried to start using mean.io on another computer it worked fine so it is almost certainly a problem with my current environment. When I look inside of my root's node_modules folder it is missing both 'async' and 'mongoose'. Are they supposed to be in that folder?


Is your internet stable, and no timeout problems? I've had issues with npm skipping stuff if it cannot get it sufficiently quickly, and then claiming success all the same. rerunning npm install usually works, but sometimes it's really confused and you need to throw away your node_modules and start again. either that, or your package.json is wrong.

Yup, my internet is pretty stable here. I've run the command like 5 times in a row and I've deleted and reinited the app ~5 times too, so that shouldn't be it. My package.json is simply the default mean.io package, so it should be fine.

I know it's a dumb question but... Does your package.json have async and mongoose in dependencies section? The only other thing I can think about is async and mongoose getting deleted from central npm repo. I don't think internet connection creates major issues because I might be having one of the shittiest internet connections in the entire thread and still didn't have any issues with npm claiming success but not downloading dependencies. Regardless, you can run:

npm install --save async mongoose 


and solve your problem that way.

It now starts the server, looks like it's going fine and then refuses to serve the pages. :/ Not sure why it's doing that... This is the same thing that happened last time I tried to manually install the packages.

Dafaq?

Can you link me your github/bitbucket so that I can check out your code?

Well, I've got the whole mean.io setup there, which is huge. The package for my website itself is here but that's just the basic website they offer as an example.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2016-05-03 22:47:02
May 03 2016 22:45 GMT
#14508
Some asshole tried to enter into my Facebook today but it's good I have 2-step verification, so nothing happened. It wasn't the easiest password but it wasn't a too simple one either. It's been written as if it's:

st4rw4rsbr0 - starwarsbro (not actual password)


Either way, I've set a new password using LastPass now. I should be fine.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
May 04 2016 05:12 GMT
#14509
I want to switch to LastPass but I feel like I'm going to get really mad one day if I need to access a file on a friend's computer or something :/
There is no one like you in the universe.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-05-04 07:19:58
May 04 2016 07:17 GMT
#14510
--- Nuked ---
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2016-05-04 17:35:07
May 04 2016 17:34 GMT
#14511
On May 04 2016 16:17 Nesserev wrote:
Show nested quote +
On May 04 2016 07:45 Shield wrote:
Some asshole tried to enter into my Facebook today but it's good I have 2-step verification, so nothing happened. It wasn't the easiest password but it wasn't a too simple one either. It's been written as if it's:

st4rw4rsbr0 - starwarsbro (not actual password)


Either way, I've set a new password using LastPass now. I should be fine.

Wait, so your original facebook password was compromised? Do you have an idea how it could've happened?

Show nested quote +
On May 04 2016 14:12 Blisse wrote:
I want to switch to LastPass but I feel like I'm going to get really mad one day if I need to access a file on a friend's computer or something :/

There's an alternative service that is accessible online and let's you type in a password and website, and it auto-generates a strong password. Don't remember what it was... maybe someone in this thread knows.


No, other than password being too easy for that person, I'm not really sure. Facebook thought it was someone from Indonesia but it could have been proxy. It's a shame Facebook doesn't have a customer service team to talk to. Just generic forms.
Chocolate
Profile Blog Joined December 2010
United States2350 Posts
May 05 2016 12:36 GMT
#14512
I know this isn't the "computer science" thread but is anybody interested in an algorithms! problem? I encountered this problem in the context of matching people based on survey answers and couldn't really find anything similar / analogous on the internet (I'm sure someone has implemented a solution to this in some shape or form before though, since from what I can tell e.g. dating websites often seek to answer this exact problem. Perhaps I just didn't look hard enough lol), so I'd consider it a pretty interesting problem with very clear practical applications.

Basically the problem is this: When someone takes a survey, their responses are recorded in a sequence. We want to take an input sequence, look into a set of sequences, and return from that set the sequence that most closely matches the input. We determine if two sequences match by comparing their elements pairwise. Assume that all sequences have constant length A, and that for question i we know the maximum number of answers to that question Bi (i.e. there exists a mapping M[i] = Bi). Let n be the number of sequences we want to draw a best match from.

A naive solution is to just store the sequences in a list, iterate over the sequences, and for each sequence find how many of its elements match the input. If this number is greater than the old best match number, make the new best match this sequence, and continue iterating. Then you just return what's stored as the best match once the list is iterated.

Now this seems like a good solution because it's O(n) (times A). However in the contexts this would be used we'd likely have millions of sequences to find a match from, and each sequence could have a hundred entries. I want to find a sublinear solution to this problem (perhaps involving tries) or at least one that reduces the coefficient on O(n) severely.

Let me know if you want me to post more information about this problem and PLEASE PLEASE PLEASE let me know if this is already a problem someone has solved. I've been thinking about it a lot and I love playing around with it.
Acrofales
Profile Joined August 2010
Spain18215 Posts
May 05 2016 13:31 GMT
#14513
What you need is a similarity measure. The cosine similarity seems like it might work well for you.

Given that you want to do pairwise comparisons, you won't get less than O(n) (cosine similarity is also O(n), but it's fast... Then again, so is edit distance, which you seem to describe). You could try speeding it up by shortening the vectors through some form of feature selection (it'll still be O(n), but you'll have less n.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
May 05 2016 14:33 GMT
#14514
On May 05 2016 21:36 Chocolate wrote:
Matching stuff

I think it's obvious that the only way to go below O(n) (or to achieve a constant factor c < 1 for O(n)) is to maintain some sort of lookup table/matrix/cache that you can query quickly.

Just some random idea, this might not actually lead anywhere:
Imagine your data as an A-dimensional matrix of sets of identical survey results. For any given result you can locate all identical results by looking up the corresponding entry in the matrix. That's the easy part (even though you probably need some sort of high performance sparse matrix implementation to make this work).

Now how do we find the closest match if there are no identical ones? For a 2 dimensional matrix (only 2 questions), that would be the entries in the same row or column as the one you are matching with. But if we scan through all of these entries in a large matrix and repeat that for increasingly less similar results, it probably becomes very slow. I don't know, it might be fast, but I doubt it.

But since we are always looking for the closest match, then if we don't find an identical entry in the matrix we know that this entry in the matrix is free to store other stuff. So we can store pointers to the next closest matches there. Obviously this would make lookup blazing fast. But how do we update those pointers? Assume we have an empty matrix at first, obviouslty no pointers at all yet. The first entry is easy, everything now points to that (can we do that with a sparse matrix?). For the next ones, we have to find all the entries that should now point to the new entry and update those. We know the previously closest match for the new entry, so maybe that helps? We don't have to update the entries that are already occupied. That also helps a little.

Well, I guess that's it for now. I'd have to actually spend a bunch of time to continue this from here.
If you have a good reason to disagree with the above, please tell me. Thank you.
Khalum
Profile Joined September 2010
Austria831 Posts
May 05 2016 14:45 GMT
#14515
Might not be a lot of a speedup but you can stop comparing two sequences early when the number of remaining elements is not enough to produce a new best fit.

And I'm not sure if that works cause I didn't really think it trough completely, but maybe you can pre-process your sequences so that you know how often answer A, B, C... was selected and store these. That might let you completely skip sequences if these values not "equal" enough compared to the best fit you already have.
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
May 05 2016 14:50 GMT
#14516
I feel like this problem can be solved as an eigenvalue problem, but I'm not sure on the specifics.
TRUEESPORTS || your days as a respected member of team liquid are over
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
May 05 2016 15:35 GMT
#14517
On May 04 2016 16:17 Nesserev wrote:
Show nested quote +
On May 04 2016 07:45 Shield wrote:
Some asshole tried to enter into my Facebook today but it's good I have 2-step verification, so nothing happened. It wasn't the easiest password but it wasn't a too simple one either. It's been written as if it's:

st4rw4rsbr0 - starwarsbro (not actual password)


Either way, I've set a new password using LastPass now. I should be fine.

Wait, so your original facebook password was compromised? Do you have an idea how it could've happened?

Show nested quote +
On May 04 2016 14:12 Blisse wrote:
I want to switch to LastPass but I feel like I'm going to get really mad one day if I need to access a file on a friend's computer or something :/

There's an alternative service that is accessible online and let's you type in a password and website, and it auto-generates a strong password. Don't remember what it was... maybe someone in this thread knows.

I use keepass.info. They have an iOS app so I always have access to all my passwords if necessary.
Zocat
Profile Joined April 2010
Germany2229 Posts
Last Edited: 2016-05-05 17:25:25
May 05 2016 17:18 GMT
#14518
On May 05 2016 21:36 Chocolate wrote:
stuff


Look at the 2D case (so only 2 questions). Now your input/target t and all your other sequences in the set S of sequences are 2D points. Your goal is now to find the sequence s from S that is "closest" to t.

You are looking for the nearest-neighbour in high dimensions.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
May 05 2016 17:35 GMT
#14519
On May 06 2016 02:18 Zocat wrote:
Show nested quote +
On May 05 2016 21:36 Chocolate wrote:
stuff


Look at the 2D case (so only 2 questions). Now your input/target t and all your other sequences in the set S of sequences are 2D points. Your goal is now to find the sequence s from S that is "closest" to t.

You are looking for the nearest-neighbour in high dimensions.

I don't think it's quite that. Imagine 100 different possible answers per question. The result (0,0) is closer to (1,1) than it is to (0,99). But (0,99) is still a better match. Assuming that the best match is the one which has the most identical answers.
If you have a good reason to disagree with the above, please tell me. Thank you.
Acrofales
Profile Joined August 2010
Spain18215 Posts
May 05 2016 18:19 GMT
#14520
On May 06 2016 02:35 spinesheath wrote:
Show nested quote +
On May 06 2016 02:18 Zocat wrote:
On May 05 2016 21:36 Chocolate wrote:
stuff


Look at the 2D case (so only 2 questions). Now your input/target t and all your other sequences in the set S of sequences are 2D points. Your goal is now to find the sequence s from S that is "closest" to t.

You are looking for the nearest-neighbour in high dimensions.

I don't think it's quite that. Imagine 100 different possible answers per question. The result (0,0) is closer to (1,1) than it is to (0,99). But (0,99) is still a better match. Assuming that the best match is the one which has the most identical answers.

Depends on your distance metric. Edit distance is a perfectly acceptable distance metric, and for edit distance for d((0,0),(1,1)) = 2, whereas d((0,0), (0,99)) = 1. There's no specific reason to limit yourself to Euclidean or Manhattan distance. I suggested cosine distance, but you're right that that may be the wrong approach if he really needs it to be edit distance.

As above, the only way to reduce the problem down form O(n) to some smaller version of O(n) is to find some way of reducing the number of n you have to look at. Obviously, heuristically stopping any time a solution goes over your minimum distance so far (or you can expand this heuristic to one that may be sub-optimal, but will always return at least a decent response, by doing this in parts). However, some kind of feature selection might work even better: for instance, if you have 20 questions about what general outward traits someone likes, stereotype that, and reduce it to searching for people whose outward traits were matched to that stereotype. It is suboptimal, but optimality is not everything it was made out to be anyway (especially not if dealing with human data, which is usually not a fully accurate representation of what you`re trying to figure out anyway).
Prev 1 724 725 726 727 728 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
HomeStory Cup 28 - Group C
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 241
NeuroSwarm 202
StarCraft: Brood War
JulyZerg 45
910 37
Icarus 3
Dota 2
monkeys_forever589
LuMiX2
League of Legends
JimRising 800
Super Smash Bros
C9.Mang01263
Mew2King65
Other Games
summit1g15387
tarik_tv5678
ToD115
Moletrap11
Organizations
Other Games
gamesdonequick1227
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• davetesta55
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Stunt357
Upcoming Events
Sparkling Tuna Cup
6h 24m
LiuLi Cup
7h 24m
Maru vs Reynor
Serral vs Rogue
Ladder Legends
14h 24m
Replay Cast
20h 24m
Replay Cast
1d 5h
Wardi Open
1d 8h
Monday Night Weeklies
1d 13h
OSC
1d 20h
WardiTV Winter Champion…
2 days
Replay Cast
3 days
[ Show More ]
WardiTV Winter Champion…
3 days
Replay Cast
3 days
PiG Sty Festival
4 days
The PondCast
4 days
KCM Race Survival
4 days
WardiTV Winter Champion…
4 days
Replay Cast
4 days
PiG Sty Festival
5 days
Epic.LAN
5 days
Replay Cast
5 days
PiG Sty Festival
6 days
CranKy Ducklings
6 days
Epic.LAN
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-02-14
Rongyi Cup S3
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
LiuLi Cup: 2025 Grand Finals
Nations Cup 2026
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025

Upcoming

Escore Tournament S1: King of Kings
[S:21] ASL SEASON OPEN 1st Round
[S:21] ASL SEASON OPEN 1st Round Qualifier
[S:21] ASL SEASON OPEN 2nd Round
[S:21] ASL SEASON OPEN 2nd Round Qualifier
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
WardiTV Winter 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.