• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:59
CEST 13:59
KST 20:59
  • 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
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Chinese SC2 server to reopen; live all-star event in Hangzhou17Weekly Cups (Oct 13-19): Clem Goes for Four2BSL Team A vs Koreans - Sat-Sun 16:00 CET7Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)81
StarCraft 2
General
RotterdaM "Serral is the GOAT, and it's not close" 5.0.15 Patch Balance Hotfix (2025-10-8) Weekly Cups (Oct 13-19): Clem Goes for Four Chinese SC2 server to reopen; live all-star event in Hangzhou Weekly Cups (March 17-23): Clem Bounces Back
Tourneys
Tenacious Turtle Tussle RSL Season 3 Qualifier Links and Dates $1,200 WardiTV October (Oct 21st-31st) SC2's Safe House 2 - October 18 & 19 INu's Battles #13 - ByuN vs Zoun
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
BW General Discussion SnOw's Awful Building Placements vs barracks BSL Team A vs Koreans - Sat-Sun 16:00 CET Is there anyway to get a private coach? BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues 300$ 3D!Community Brood War Super Cup #4 [ASL20] Semifinal B Azhi's Colosseum - Anonymous Tournament
Strategy
Current Meta BW - ajfirecracker Strategy & Training Roaring Currents ASL final [I] Funny Protoss Builds/Strategies
Other Games
General Games
Nintendo Switch Thread Path of Exile Stormgate/Frost Giant Megathread Dawn of War IV ZeroSpace Megathread
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine The Chess Thread Men's Fashion Thread
Fan Clubs
The herO Fan Club!
Media & Entertainment
Anime Discussion Thread Series you have seen recently... [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023 Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Sabrina was soooo lame on S…
Peanutsc
Our Last Hope in th…
KrillinFromwales
Certified Crazy
Hildegard
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1331 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
Hyrule19144 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
Spain18096 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
Poland17391 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
Spain18096 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
Spain18096 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
The PondCast
10:00
Episode 68
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko332
StarCraft: Brood War
actioN 2827
Hyuk 2071
GuemChi 1905
Bisu 862
ZerO 784
Jaedong 759
firebathero 462
Hyun 407
Mini 308
Stork 300
[ Show more ]
hero 272
BeSt 246
Light 194
Pusan 156
Last 148
ggaemo 146
EffOrt 143
Barracks 120
Larva 115
zelot 110
ToSsGirL 92
Shine 92
Rush 76
Mind 50
TY 44
Sea.KH 34
sorry 32
Free 25
Sharp 22
Shinee 19
Icarus 17
soO 15
Noble 15
Sexy 14
Yoon 14
Terrorterran 13
HiyA 11
Sacsri 10
Dota 2
XaKoH 290
BananaSlamJamma193
XcaliburYe161
Dendi160
canceldota30
League of Legends
JimRising 445
Counter-Strike
olofmeister2658
zeus641
x6flipin473
allub210
oskar144
markeloff117
byalli71
edward37
Super Smash Bros
Westballz34
Other Games
summit1g6569
singsing1904
B2W.Neo957
crisheroes317
Mew2King48
Trikslyr13
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 966
Counter-Strike
PGL224
Other Games
BasetradeTV144
StarCraft 2
WardiTV88
StarCraft: Brood War
UltimateBattle 52
lovetv 10
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• LUISG 35
• StrangeGG 23
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV601
League of Legends
• Jankos2081
• Lourlo451
Upcoming Events
OSC
2m
WardiTV Invitational
23h 2m
Online Event
1d 4h
RSL Revival
1d 14h
RSL Revival
1d 22h
WardiTV Invitational
1d 23h
OSC
2 days
SKillous vs goblin
Spirit vs GgMaChine
ByuN vs MaxPax
Afreeca Starleague
2 days
Snow vs Soma
Sparkling Tuna Cup
2 days
WardiTV Invitational
3 days
[ Show More ]
CrankTV Team League
3 days
RSL Revival
3 days
Wardi Open
4 days
CrankTV Team League
4 days
Replay Cast
4 days
WardiTV Invitational
5 days
CrankTV Team League
5 days
Replay Cast
5 days
CrankTV Team League
6 days
Replay Cast
6 days
The PondCast
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
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.