• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 05:29
CET 11:29
KST 19:29
  • 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
ByuL: The Forgotten Master of ZvT28Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (Feb 16-22): MaxPax doubles0Weekly Cups (Feb 9-15): herO doubles up2ACS replaced by "ASL Season Open" - Starts 21/0243LiuLi Cup: 2025 Grand Finals (Feb 10-16)46Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2
StarCraft 2
General
ByuL: The Forgotten Master of ZvT How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Oliveira Would Have Returned If EWC Continued Behind the Blue - Team Liquid History Book Weekly Cups (Feb 16-22): MaxPax doubles
Tourneys
http://facebook.com/TivanoCuttingBoard.OfficialUSD StarCraft Evolution League (SC Evo Biweekly) Sea Duckling Open (Global, Bronze-Diamond) PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ? [A] Starcraft Sound Mod
External Content
Mutation # 514 Ulnar New Year The PondCast: SC2 News & Results Mutation # 513 Attrition Warfare Mutation # 512 Overclocked
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ ACS replaced by "ASL Season Open" - Starts 21/02 TvZ is the most complete match up CasterMuse Youtube A cwal.gg Extension - Easily keep track of anyone
Tourneys
Escore Tournament StarCraft Season 1 [Megathread] Daily Proleagues [LIVE] [S:21] ASL Season Open Day 1 Small VOD Thread 2.0
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Zealot bombing is no longer popular?
Other Games
General Games
Path of Exile Nintendo Switch Thread Beyond All Reason Battle Aces/David Kim RTS Megathread New broswer game : STG-World
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 TL Mafia Community Thread
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Mexico's Drug War Russo-Ukrainian War Thread Ask and answer stupid questions here!
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
ASL S21 English Commentary…
namkraft
Inside the Communication of …
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1119 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
Germany567 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
Germany567 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
Poland17671 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
Poland17671 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
Poland17671 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
Poland17671 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
CasterMuse Showmatch
09:00
SuperFight #002
Light vs Queen
Discussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 193
Creator 34
StarCraft: Brood War
Britney 30858
Calm 8046
Sea 4992
Rain 2110
Horang2 924
Flash 873
Bisu 310
Mong 256
BeSt 209
Dewaltoss 199
[ Show more ]
hero 159
Hyuk 144
EffOrt 101
Rush 67
Last 64
ToSsGirL 62
Soulkey 42
sorry 29
NaDa 23
Hm[arnc] 21
Free 18
910 15
Terrorterran 9
NotJumperer 5
Dota 2
XaKoH 502
febbydoto18
Counter-Strike
olofmeister1620
allub334
kRYSTAL_59
Heroes of the Storm
crisheroes177
Other Games
singsing1218
Liquid`RaSZi1005
ceh9584
Organizations
Other Games
gamesdonequick914
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• LUISG 39
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1733
• Stunt583
Upcoming Events
WardiTV Winter Champion…
1h 31m
OSC
13h 31m
The PondCast
23h 31m
Replay Cast
1d 13h
Korean StarCraft League
2 days
CranKy Ducklings
2 days
SC Evo Complete
3 days
Replay Cast
3 days
Sparkling Tuna Cup
3 days
uThermal 2v2 Circuit
4 days
[ Show More ]
Replay Cast
4 days
Wardi Open
5 days
Replay Cast
5 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-02-22
LiuLi Cup: 2025 Grand Finals
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Acropolis #4 - TS5
Jeongseon Sooper Cup
Spring Cup 2026
WardiTV Winter 2026
PiG Sty Festival 7.0
Nations Cup 2026
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025

Upcoming

[S:21] ASL SEASON OPEN 2nd Round
[S:21] ASL SEASON OPEN 2nd Round Qualifier
ASL Season 21: Qualifier #1
ASL Season 21: Qualifier #2
Acropolis #4 - TS6
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
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.