• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 12:30
CEST 18:30
KST 01:30
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Weekly Cups (June 30 - July 6): Classic Doubles2[BSL20] Non-Korean Championship 4x BSL + 4x China8Flash Announces Hiatus From ASL66Weekly Cups (June 23-29): Reynor in world title form?14FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings Weekly Cups (June 23-29): Reynor in world title form? Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
Flash Announces Hiatus From ASL SC uni coach streams logging into betting site BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ ASL20 Preliminary Maps
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET CSL Xiamen International Invitational [BSL20] Non-Korean Championship 4x BSL + 4x China The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024! Summer Games Done Quick 2025!
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 633 users

The Big Programming Thread - Page 726

Forum Index > General Forum
Post a Reply
Prev 1 724 725 726 727 728 1031 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
Hyrule19031 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
Spain17971 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
Poland17243 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
Spain17971 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
Spain17971 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 1031 Next
Please log in or register to reply.
Live Events Refresh
RotterdaM Event
16:00
Rotti Stream Rumble 4k Edition
RotterdaM443
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 762
RotterdaM 443
Hui .357
MaxPax 334
StarCraft: Brood War
Bisu 1941
EffOrt 1308
Flash 1304
Jaedong 1180
Hyuk 821
Stork 371
actioN 369
Soulkey 276
Soma 275
Snow 187
[ Show more ]
firebathero 175
Mind 98
JulyZerg 71
TY 69
sSak 64
Barracks 57
Sharp 50
JYJ46
Terrorterran 45
PianO 43
Rock 31
HiyA 21
Aegong 20
soO 16
yabsab 15
GoRush 11
Shine 8
IntoTheRainbow 7
Dota 2
Gorgc6615
qojqva3321
League of Legends
singsing2289
Dendi1253
Counter-Strike
fl0m1143
markeloff176
Super Smash Bros
Mew2King204
Other Games
hiko1544
Beastyqt844
ceh9366
Lowko307
crisheroes263
ArmadaUGS149
KnowMe140
Trikslyr62
Organizations
Other Games
gamesdonequick47269
StarCraft 2
angryscii 21
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Reevou 7
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Michael_bg 2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis6915
• TFBlade833
• Jankos802
Other Games
• Shiphtur316
Upcoming Events
Replay Cast
7h 30m
Sparkling Tuna Cup
17h 30m
WardiTV European League
23h 30m
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 7h
The PondCast
1d 17h
WardiTV European League
1d 19h
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
1d 23h
Replay Cast
2 days
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
Replay Cast
3 days
[ Show More ]
RSL Revival
3 days
Classic vs Cure
FEL
3 days
RSL Revival
4 days
FEL
4 days
FEL
4 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
5 days
BSL20 Non-Korean Champi…
6 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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 © 2025 TLnet. All Rights Reserved.