• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 03:33
CET 09:33
KST 17:33
  • 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 Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
$21,000 RyongYi Cup Season 3 announced (Jan 22-Feb 7)1Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns6[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises3
StarCraft 2
General
Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns SC2 All-Star Invitational: Jan 17-18 Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises Chinese SC2 server to reopen; live all-star event in Hangzhou Starcraft 2 Zerg Coach
Tourneys
$21,000 RyongYi Cup Season 3 announced (Jan 22-Feb 7) WardiTV Winter Cup WardiTV Mondays SC2 AI Tournament 2026 OSC Season 13 World Championship
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution
Brood War
General
I would like to say something about StarCraft BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion StarCraft & BroodWar Campaign Speedrun Quest Data analysis on 70 million replays
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Game Theory for Starcraft Simple Questions, Simple Answers Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Awesome Games Done Quick 2026! Stormgate/Frost Giant Megathread General RTS Discussion Thread Nintendo Switch Thread Should offensive tower rushing be viable in RTS games?
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread The Big Programming Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Psychological Factors That D…
TrAiDoS
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1559 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
Germany565 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
Germany565 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
Poland17576 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
Poland17576 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
Poland17576 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
Poland17576 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
Next event in 19h 27m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft516
SortOf 105
StarCraft: Brood War
Britney 16878
GuemChi 3599
Hyuk 1451
Pusan 508
Shuttle 373
Movie 118
Light 117
Mini 106
EffOrt 87
Dewaltoss 72
[ Show more ]
Killer 63
Sharp 55
NotJumperer 53
Nal_rA 35
Barracks 34
ZergMaN 30
soO 29
Mong 26
JulyZerg 24
Noble 22
Sacsri 12
NaDa 9
Bale 8
Dota 2
NeuroSwarm101
League of Legends
JimRising 710
C9.Mang0519
Other Games
Happy279
Fuzer 234
crisheroes211
Organizations
Other Games
gamesdonequick30647
StarCraft: Brood War
UltimateBattle 107
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift4467
• Scarra2298
• Rush1154
• Lourlo1106
• HappyZerGling158
Upcoming Events
SOOP
19h 27m
SHIN vs GuMiho
Cure vs Creator
The PondCast
1d 1h
Wardi Open
1d 3h
Big Gabe XPERIONCRAFT
1d 4h
AI Arena Tournament
1d 11h
Sparkling Tuna Cup
2 days
WardiTV Invitational
2 days
IPSL
2 days
DragOn vs Sziky
Replay Cast
3 days
Wardi Open
3 days
[ Show More ]
Monday Night Weeklies
3 days
WardiTV Invitational
4 days
WardiTV Invitational
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2026-01-06
WardiTV 2025
META Madness #9

Ongoing

C-Race Season 1
IPSL Winter 2025-26
Escore Tournament S1: W3
OSC Championship Season 13
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Thunderfire SC2 All-star 2025
Big Gabe Cup #3
Nations Cup 2026
Underdog Cup #3
NA Kuram Kup
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
TLPD

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

Advertising | Privacy Policy | Terms Of Use | Contact Us

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