• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:53
CET 14:53
KST 22:53
  • 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
RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation13Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
Zerg is losing its identity in StarCraft 2 [TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t RotterdaM "Serral is the GOAT, and it's not close" RSL Season 3 - RO16 Groups C & D Preview
Tourneys
RSL Revival: Season 3 Sparkling Tuna Cup - Weekly Open Tournament Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle BGH Auto Balance -> http://bghmmr.eu/ What happened to TvZ on Retro? SnOw's ASL S20 Finals Review BW General Discussion
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET
Strategy
PvZ map balance Current Meta Simple Questions, Simple Answers How to stay on top of macro?
Other Games
General Games
Clair Obscur - Expedition 33 Should offensive tower rushing be viable in RTS games? Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
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
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2236 users

The Big Programming Thread - Page 725

Forum Index > General Forum
Post a Reply
Prev 1 723 724 725 726 727 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.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-04-30 02:50:05
April 30 2016 02:43 GMT
#14481
Honestly one of my favourite things in C++ is initialization lists. Not a big deal usually, but for prototyping it's really nice to be able to do std::set<int> combos = { 1, 2, 3, }; and have it compile. Or just call funcThatTakesInAList({ 1, 2, 3, });.

Otherwise I really like C++11 onwards, nullptr_t, range fors, strongly typed enums, auto return type, const exprs.

edit: apparently you can add ' to numbers to help readability, so 1'000'000 is the same as 1000000 :o

edit: binary literals too whoa 0b010 compiles :o
There is no one like you in the universe.
Artesimo
Profile Joined February 2015
Germany563 Posts
April 30 2016 15:34 GMT
#14482
On April 29 2016 00:23 tofucake wrote:
no, netbeans is stupid


At first I thought it was me being awful but: NetBeans keeps marking me things a wrong, saying identifiers are missing etc, yet the program compiles and runs fine! I made changes, made a cleanbuild etc. everything runs and compiles fine, even though it keeps marking things as wrong.
Of course I am awful at coding, but what the hell if wrong with this IDE…
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-04-30 16:53:45
April 30 2016 16:51 GMT
#14483
Honestly either it's that you need to more aggressively clean the build (because netbeans isn't recompiling files you've changed), or you should really just not use an ide if you can avoid it. Or at least use CLion or VS.

Dicking around with CMake is really enjoyable IMO. Learning stuff about build process.

Plus the output is pretty 😍

https://github.com/Blisse/CS452-Kernel/blob/master/CMakeLists.txt
There is no one like you in the universe.
Artesimo
Profile Joined February 2015
Germany563 Posts
April 30 2016 17:21 GMT
#14484
I am forced to use netbeans for a number of reasons. I am just baffled how "incredible" it is, given the fact that we are forced to work with it in some lectures. Right now I am just coding with gedit and giggle like a retard when I copy my code into netbeans and it just compiles even though it marks almost everything as wrong. It is better then the other way around
amazingxkcd
Profile Blog Joined September 2010
GRAND OLD AMERICA16375 Posts
April 30 2016 18:10 GMT
#14485
On May 01 2016 02:21 Artesimo wrote:
I am forced to use netbeans for a number of reasons. I am just baffled how "incredible" it is, given the fact that we are forced to work with it in some lectures. Right now I am just coding with gedit and giggle like a retard when I copy my code into netbeans and it just compiles even though it marks almost everything as wrong. It is better then the other way around


netbeans is fine but you have to spend time to set the IDE up right.
The world is burning and you rather be on this terrible website discussing video games and your shallow feelings
Manit0u
Profile Blog Joined August 2004
Poland17433 Posts
Last Edited: 2016-04-30 18:39:06
April 30 2016 18:36 GMT
#14486
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:


#include <stdio.h>
#include <stdlib.h>

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)
{
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);

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...
Time is precious. Waste it wisely.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-30 19:06:11
April 30 2016 18:52 GMT
#14487
When you're defining types you typically include an _t at the end of the names.

typedef struct integer_range_s {
int length;
int nums[];
} integer_range_t;


I'd also question your use of malloc in this scenario. The stack is large enough to have a small array printed, unless you're intending very large ranges to be printed or wanted to do some memory management.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Manit0u
Profile Blog Joined August 2004
Poland17433 Posts
Last Edited: 2016-04-30 22:14:49
April 30 2016 19:02 GMT
#14488
On May 01 2016 03:52 Blitzkrieg0 wrote:
When you're defining types you typically include an _t at the end of the names.

struct integer_range_s {
int length;
int nums[];
} integer_range_t;


I'd also question your use of malloc in this scenario. The stack is large enough to have a small array printed, unless you're intending very large ranges to be printed or wanted to do some memory management.


I'm trying to remember how to properly use malloc and such
Also, I was a bit afraid of getting segfaults while trying to populate an unitialized variable length array inside of struct (trying to malloc it with too small size sure did that).

Edit:
Are there any current "best practices" or something like that for C this days?
Time is precious. Waste it wisely.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2016-04-30 23:55:57
April 30 2016 23:47 GMT
#14489
On May 01 2016 04:02 Manit0u wrote:
Show nested quote +
On May 01 2016 03:52 Blitzkrieg0 wrote:
When you're defining types you typically include an _t at the end of the names.

struct integer_range_s {
int length;
int nums[];
} integer_range_t;


I'd also question your use of malloc in this scenario. The stack is large enough to have a small array printed, unless you're intending very large ranges to be printed or wanted to do some memory management.


I'm trying to remember how to properly use malloc and such
Also, I was a bit afraid of getting segfaults while trying to populate an unitialized variable length array inside of struct (trying to malloc it with too small size sure did that).

Edit:
Are there any current "best practices" or something like that for C this days?


Yes, the best practice is to use C++ over C. No, really, why bother with all the primitive stuff C forces you to do when you can get all of that and safety from C++?

Edit: Why do you increment loop like
i += 1
? The common way is ++i instead.

Edit #2:


int reverse = (end < start);
int size = (reverse ? start - end : end - start) + 1;


Please use booleans. They exist even in C.
Manit0u
Profile Blog Joined August 2004
Poland17433 Posts
May 01 2016 01:47 GMT
#14490
On May 01 2016 08:47 Shield wrote:
Show nested quote +
On May 01 2016 04:02 Manit0u wrote:
On May 01 2016 03:52 Blitzkrieg0 wrote:
When you're defining types you typically include an _t at the end of the names.

struct integer_range_s {
int length;
int nums[];
} integer_range_t;


I'd also question your use of malloc in this scenario. The stack is large enough to have a small array printed, unless you're intending very large ranges to be printed or wanted to do some memory management.


I'm trying to remember how to properly use malloc and such
Also, I was a bit afraid of getting segfaults while trying to populate an unitialized variable length array inside of struct (trying to malloc it with too small size sure did that).

Edit:
Are there any current "best practices" or something like that for C this days?


Yes, the best practice is to use C++ over C. No, really, why bother with all the primitive stuff C forces you to do when you can get all of that and safety from C++?

Edit: Why do you increment loop like
i += 1
? The common way is ++i instead.

Edit #2:


int reverse = (end < start);
int size = (reverse ? start - end : end - start) + 1;


Please use booleans. They exist even in C.


I don't like C++.

i += 1 is a habit from writing python scripts, I don't mind it

Using bools is a good idea, I'll be sure to do that.
Time is precious. Waste it wisely.
Thaniri
Profile Blog Joined March 2011
1264 Posts
May 01 2016 04:29 GMT
#14491
Has anyone here tried HackerRank challenges in JavaScript?

I'm trying this one right here and I don't know how to deal with their inputs. The input is served as an array like so:

console.log(_input[0],_input[1],_input[2],_input[3],_input[4],_input[5],_input[6]);
[2, "", 1, "", 0, "", 1, "", 0]


I've solved 2 challenges using this method before but I'm aware of how idiotic it is. Anyone know if I'm doing it wrong or if I should just do everything in Java instead?
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
May 01 2016 06:58 GMT
#14492
On May 01 2016 13:29 Thaniri wrote:
Has anyone here tried HackerRank challenges in JavaScript?

I'm trying this one right here and I don't know how to deal with their inputs. The input is served as an array like so:

console.log(_input[0],_input[1],_input[2],_input[3],_input[4],_input[5],_input[6]);
[2, "", 1, "", 0, "", 1, "", 0]


I've solved 2 challenges using this method before but I'm aware of how idiotic it is. Anyone know if I'm doing it wrong or if I should just do everything in Java instead?



I got a different input, essentially just a newline separated string "2\n10\n100".

function processData(input) {
var count = null;
input.split("\n").forEach(function(item) {
// First item is number of testcases, we don't need that
// Just storing it for completeness sake
if (count === null) {
count = parseInt(item);
return;
}
var sum = 0;
for (var i=1; i < parseInt(item); ++i)
{
if (!(i % 3) || !(i % 5)) sum += i;
}
sum && process.stdout.write(sum+"\n");
});
}

PS: That is ugly code. Don't write production code like that.
Thaniri
Profile Blog Joined March 2011
1264 Posts
May 01 2016 07:31 GMT
#14493
Thanks man, didn't know an array could be manipulated like that. I'm an amateur programmer anyway I can't even tell what good code looks like. It's like asking an american what good cheese is if they've been eating it out of a jar or cheddar for their whole life.
bangsholt
Profile Joined June 2011
Denmark138 Posts
May 01 2016 10:39 GMT
#14494
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.
Manit0u
Profile Blog Joined August 2004
Poland17433 Posts
Last Edited: 2016-05-01 12:03:05
May 01 2016 12:00 GMT
#14495
On May 01 2016 19:39 bangsholt wrote:
Show nested quote +
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
}
Time is precious. Waste it wisely.
Khalum
Profile Joined September 2010
Austria831 Posts
May 01 2016 12:28 GMT
#14496
On May 01 2016 21:00 Manit0u wrote:
Show nested quote +
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
}


-1 for a * isn't so cool. Just return NULL.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
May 01 2016 17:59 GMT
#14497
On April 29 2016 17:08 Djagulingu wrote:
Show nested quote +
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.
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-02 00:49:21
May 02 2016 00:45 GMT
#14498
On May 01 2016 21:00 Manit0u wrote:
Show nested quote +
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.
amazingxkcd
Profile Blog Joined September 2010
GRAND OLD AMERICA16375 Posts
May 02 2016 03:24 GMT
#14499
On May 02 2016 09:45 Shield wrote:
Show nested quote +
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?
The world is burning and you rather be on this terrible website discussing video games and your shallow feelings
Arnstein
Profile Blog Joined May 2010
Norway3381 Posts
May 02 2016 08:19 GMT
#14500
Suddenly I have to write JavaScript at work, and I'm a hardware design/verification guy...!
What's the best practice for saving info done on a webpage? Not global variables I assume? I am thinking that when the user chooses settings in boxes I have made, the settings get saved in a string that is shown in a box, so that he can copy/paste it and give it to coworkers. When the coworker pastes and presses "go" in this box, the settings will be applied so he can get the same settings.
rsol in response to the dragoon voice being heard in SCII: dragoon ai reaches new lows: wanders into wrong game
Prev 1 723 724 725 726 727 1032 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Korean Royale
12:00
Group Stage 1 - Group A
WardiTV640
LiquipediaDiscussion
Kung Fu Cup
12:00
2025 Monthly #3: Day 5
Cure vs herOLIVE!
Reynor vs TBD
RotterdaM617
TKL 352
IndyStarCraft 269
SteadfastSC113
IntoTheiNu 35
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 617
TKL 352
Tasteless 324
Reynor 276
IndyStarCraft 269
Rex 147
SteadfastSC 113
Railgan 25
MindelVK 21
StarCraft: Brood War
Britney 36790
Rain 8932
Sea 4139
firebathero 4096
BeSt 1748
Horang2 1687
GuemChi 939
Soma 605
EffOrt 552
Stork 500
[ Show more ]
Mini 456
actioN 283
Rush 225
Killer 174
Last 146
Hyun 144
scan(afreeca) 136
hero 133
Bonyth 99
Mind 90
Barracks 61
Sharp 51
zelot 50
yabsab 49
Sea.KH 45
sorry 42
Snow 39
sas.Sziky 24
Shinee 18
Hm[arnc] 15
NaDa 8
Bale 6
Dota 2
singsing3070
qojqva1678
Dendi1083
Gorgc737
XcaliburYe301
Counter-Strike
byalli539
x6flipin531
Heroes of the Storm
Khaldor238
Liquid`Hasu193
Other Games
FrodaN4939
B2W.Neo1844
Pyrionflax359
Fuzer 256
KnowMe216
DeMusliM40
Organizations
Dota 2
PGL Dota 2 - Main Stream14873
PGL Dota 2 - Secondary Stream1808
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Adnapsc2 8
• Dystopia_ 6
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV606
• Ler66
Upcoming Events
BSL 21
6h 7m
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
6h 7m
Dewalt vs WolFix
eOnzErG vs Bonyth
Replay Cast
9h 7m
Wardi Open
22h 7m
Monday Night Weeklies
1d 3h
Replay Cast
1d 9h
WardiTV Korean Royale
1d 22h
BSL: GosuLeague
2 days
The PondCast
2 days
Replay Cast
3 days
[ Show More ]
RSL Revival
3 days
BSL: GosuLeague
4 days
RSL Revival
4 days
WardiTV Korean Royale
4 days
RSL Revival
5 days
WardiTV Korean Royale
5 days
IPSL
6 days
Julia vs Artosis
JDConan vs DragOn
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-11-14
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 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.