• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:20
CEST 21:20
KST 04:20
  • 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
[ASL19] Finals Recap: Standing Tall10HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Weekly Cups (June 30 - July 6): Classic Doubles2[BSL20] Non-Korean Championship 4x BSL + 4x China9Flash Announces Hiatus From ASL66Weekly Cups (June 23-29): Reynor in world title form?14FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
The GOAT ranking of GOAT rankings The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
ASL20 Preliminary Maps [ASL19] Finals Recap: Standing Tall SC uni coach streams logging into betting site Flash Announces Hiatus From ASL BW General Discussion
Tourneys
[BSL20] Non-Korean Championship 4x BSL + 4x China [BSL20] Grand Finals - Sunday 20:00 CET CSL Xiamen International Invitational The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024! Summer Games Done Quick 2025!
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 710 users

The Big Programming Thread - Page 725

Forum Index > General Forum
Post a Reply
Prev 1 723 724 725 726 727 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
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
Germany546 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
Germany546 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
Poland17244 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
Poland17244 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
Poland17244 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
Poland17244 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 1031 Next
Please log in or register to reply.
Live Events Refresh
RotterdaM Event
16:00
Rotti Stream Rumble 4k Edition
RotterdaM957
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 957
Hui .144
StarCraft: Brood War
Bisu 1120
firebathero 221
Bonyth 80
sas.Sziky 52
Rock 9
Dota 2
qojqva3458
Pyrionflax22
League of Legends
Grubby3982
Counter-Strike
fl0m1606
Fnx 1429
ScreaM767
shoxiejesuss679
flusha381
sgares117
Heroes of the Storm
Liquid`Hasu71
Other Games
summit1g1255
B2W.Neo929
Beastyqt921
ceh9629
KnowMe191
Mew2King156
mouzStarbuck155
ToD146
oskar134
Trikslyr69
Sick51
ZombieGrub49
Organizations
Other Games
gamesdonequick49841
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• kabyraGe 247
• LUISG 11
• Reevou 10
• OhrlRock 2
• davetesta1
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• intothetv
• Kozan
• Migwel
• LaughNgamezSOOP
StarCraft: Brood War
• 80smullet 16
• Michael_bg 5
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota2641
League of Legends
• Jankos2367
• TFBlade1126
Other Games
• imaqtpie1745
• Shiphtur511
Upcoming Events
Replay Cast
4h 40m
Sparkling Tuna Cup
14h 40m
WardiTV European League
20h 40m
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 4h
The PondCast
1d 14h
WardiTV European League
1d 16h
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
1d 20h
Replay Cast
2 days
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
Replay Cast
3 days
[ Show More ]
RSL Revival
3 days
Classic vs Cure
FEL
3 days
RSL Revival
4 days
FEL
4 days
FEL
4 days
BSL20 Non-Korean Champi…
4 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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.