• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:44
CEST 11:44
KST 18:44
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
BSL 2025 Warsaw LAN + Legends Showmatch0Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29
StarCraft 2
General
#1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia WardiTV TL Team Map Contest #5 Tournaments RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
Soulkey on ASL S20 ASL TICKET LIVE help! :D BW General Discussion NaDa's Body A cwal.gg Extension - Easily keep track of anyone
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues BSL 2025 Warsaw LAN + Legends Showmatch
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Borderlands 3 General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread UK Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
I <=> 9
KrillinFromwales
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1572 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
Hyrule19087 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
Spain18050 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
Poland17341 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
Spain18050 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
Spain18050 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
Next event in 16m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Rex 2
StarCraft: Brood War
Calm 5699
Bisu 731
Hyuk 162
HiyA 96
Hyun 96
sorry 86
ToSsGirL 84
Dewaltoss 82
Pusan 77
Light 74
[ Show more ]
Soma 60
actioN 56
Mini 49
ZerO 32
BeSt 30
Nal_rA 28
soO 27
Liquid`Ret 26
Sharp 24
Rush 19
Free 16
SilentControl 10
Dota 2
singsing1508
XcaliburYe237
boxi98170
League of Legends
JimRising 381
Counter-Strike
olofmeister1583
shoxiejesuss629
allub166
Other Games
XaKoH 143
NeuroSwarm75
Trikslyr15
Organizations
Other Games
gamesdonequick599
StarCraft: Brood War
lovetv 593
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1421
• Stunt679
Other Games
• WagamamaTV81
Upcoming Events
RSL Revival
16m
Maru vs Reynor
Cure vs TriGGeR
Rex2
Map Test Tournament
1h 16m
The PondCast
3h 16m
RSL Revival
1d
Zoun vs Classic
Korean StarCraft League
1d 17h
BSL Open LAN 2025 - War…
1d 22h
RSL Revival
2 days
BSL Open LAN 2025 - War…
2 days
RSL Revival
3 days
Online Event
3 days
[ Show More ]
Wardi Open
4 days
Monday Night Weeklies
4 days
Sparkling Tuna Cup
5 days
LiuLi Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
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

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.