Open Side Menu Go to the Top
Register
Programming homework and newbie help thread Programming homework and newbie help thread

04-23-2016 , 06:09 AM
Quote:
Originally Posted by goofyballer
Deployment question - I'm not using bower at the moment, but I probably should be. To deploy to my remote host, I push my git repository, then it installs all the node modules in my package.json. When I start installing things via bower, will the setup process that my host uses also grab everything that bower is referencing in its json file, or do I need to set up an install script of some sort?
I made the same assumption as you - that all bower components that were listed in the bower json file would be automagically installed server side. Boy was I wrong. All files related to bower components are indistinguishable from normal .js/whatever files at least in master branch of my company's repo.
Programming homework and newbie help thread Quote
04-23-2016 , 12:12 PM
Talk to me like an idiot about this topic, because I am, but my project is loading large js assets on every page, for a thing that's only active on one page. There's got to be a better way to do that, right? Like add the script for it at the bottom of the specific page vs in the main application page for rails?
Programming homework and newbie help thread Quote
04-23-2016 , 01:19 PM
Quote:
Originally Posted by Noodle Wazlib
Talk to me like an idiot about this topic, because I am, but my project is loading large js assets on every page, for a thing that's only active on one page. There's got to be a better way to do that, right? Like add the script for it at the bottom of the specific page vs in the main application page for rails?
ugh, yes. this is what i hate about rails and its culture of monoliths and magic. in vanilla html, the answer to this would be obvious. you have a script tag on some pages and not on others. but now you have to go learn about the ****ing "asset pipeline" or whatever rails calls its over-engeineered way to include js tags in web pages, or you have to create different "layout" views, etc, etc. what you are doing should be trivially easy, as you probably intuitively feel it should be.
Programming homework and newbie help thread Quote
04-23-2016 , 02:45 PM
http://motherboard.vice.com/read/lin...h-fake-degrees

get a degree online from a fake university.
Programming homework and newbie help thread Quote
04-23-2016 , 02:56 PM
Quote:
Originally Posted by penguinpoker
Most likely I don't understand your question, but will attempt to answer. My experience has been deploying on heroku. To do that, it appears you can do add bower as a post-install script.

"scripts": {
"start": "node index.js",
"postinstall": "bower install"
}

And make sure you include bower as a dependency

"dependencies": {
"bower": "1.6.5"
},
That sounds like exactly what I need, thanks.
Programming homework and newbie help thread Quote
04-23-2016 , 10:28 PM
viktor are you still trying to get a programming job? do you have one? are you any good at this ****?
Programming homework and newbie help thread Quote
04-23-2016 , 10:46 PM
Quote:
Originally Posted by Noodle Wazlib
had some git repos getting out of control. got all the merging sorted and deleted the brances on bitbucket, but they're still showing up on my local pc when i do a git branch -a

tried fetching and pulling, but it doesn't seem to help. Any way to get all synced up?

edit

ugh, think i'm just making this worse. now there's a heroku master and a remote/origin/head -> origin/master

who gave me the keys to this thing?!
git reset --hard 2e3875a <--- your commit #

git push --force

git push heroku --force

... that is one option.
Programming homework and newbie help thread Quote
04-23-2016 , 10:47 PM
Quote:
Originally Posted by waffle
viktor are you still trying to get a programming job? do you have one? are you any good at this ****?
he is on the final project of bootcamp in Cleveland see bootcamp topic.
Programming homework and newbie help thread Quote
04-24-2016 , 05:55 PM
Quote:
Originally Posted by waffle
viktor are you still trying to get a programming job? do you have one? are you any good at this ****?
ya I am trying to get a job. I am ok. I mean, I cant hang with people on this board but I am probably the best in my bootcamp.
Programming homework and newbie help thread Quote
04-25-2016 , 03:08 PM
Coming from Java and trying to work with a C++ code base. I want to have my code call update_fold_regret() with probability 1 / (1000000 * sqrt(T)), where T is the iteration number of the loop.

So on iteration 5, T = 5 and probability should be 1 / (1000000 * sqrt(5)).

Here's what I have:

Code:
if (use_update_fold_regret(T)) {
    update_fold_regret();
} else {
    update_regret();
}
And here's the definition of use_update_fold_regret(T):

Code:
static bool use_update_fold_regret(long long iteration) {
        double limit = 1.0 / (1000000 * sqrt(iteration));
        //generate random number
        srand((unsigned)time(NULL));
        double random_number = ((double)rand()/(double)RAND_MAX);
        //if random number < limit, return true
        return (random_number < limit) ? true : false;
}
Does this function look right to you? I'm really banging my head against the wall on this one
Programming homework and newbie help thread Quote
04-25-2016 , 04:05 PM
- don't call srand every time, just call it once at the start of your program (this isn't the reason why it's not working, just good practice)
- don't return "x ? true : false", just return x
- generally looks right as far as I can tell, but maybe try with smaller numbers and see if that works to see if floating point inaccuracy at the levels you're working with might be the problem. There are steps you could take in your code to reduce floating point error if that's the issue
- you can also add statements that log values at different points of the way to make sure it's behaving how you want it to, and identify where things are going wrong if it's not
Programming homework and newbie help thread Quote
04-25-2016 , 05:58 PM
All of goofyballers statements are correct

In addition you can simplify the math
So let's say bignum = 1000000 * sqrt(iteration)
you currently have
rand() / RAND_MAX < 1/bignum
which is really the same as
rand() < RAND_MAX/bignum
and there's no need to do any explicit double conversions there

So yeah to debug I would start with bignum being much smaller, like 10*sqrt(T) or something.
Programming homework and newbie help thread Quote
04-25-2016 , 10:28 PM
Quote:
Originally Posted by Mariogs37
Coming from Java and trying to work with a C++ code base. I want to have my code call update_fold_regret() with probability 1 / (1000000 * sqrt(T)), where T is the iteration number of the loop.

So on iteration 5, T = 5 and probability should be 1 / (1000000 * sqrt(5)).

Here's what I have:

Code:
if (use_update_fold_regret(T)) {
    update_fold_regret();
} else {
    update_regret();
}
And here's the definition of use_update_fold_regret(T):

Code:
// implicit conversion of long long to double
static bool use_update_fold_regret(double dIteration) {
        // Compile time constants no need to compute on each call
       static const double dcLim = 0.000001;
       static const double dcRand = 1.0 / static_cast<double>(RAND_MAX);
      
       // You don't need to initialize it to false but why not
       static bool bRandnumSeeded = false;

       // Seed it once, lazy initialzation
       if (!bRandnumSeeded) { 
           // You don't need the cast, it is an implicit conversion
           srand(time(NULL));

           bRandnumSeeded = true;
       }

        double limit = 1.0 / sqrt(dIteration);
        limit *= dcLim;

        // Don't need an explicit cast
        double random_number = rand();

        random_number *= dcRand;

        return (random_number < limit);
}
Does this function look right to you? I'm really banging my head against the wall on this one
You probably should check your input parameter for negative numbers, infinity, and zero
Programming homework and newbie help thread Quote
04-26-2016 , 10:31 AM
Quote:
Originally Posted by blacklab
Ever type in an entire game/program into your vic-20 or apple II from a magazine?
I typed in an entire game into my ZX Sepctrum that was Z80 assembler, so the listing was a huge block of poorly printed hexadecimal (printed on a thermal printer).

Got it to work though.
Programming homework and newbie help thread Quote
04-26-2016 , 02:36 PM
I typed 2 pages of basic code into my sony msx to get a game running, but it was bugged and didn't run.

And I had no cassette recorder (all my games were cartridge based) so when I went to sleep my mom turned it off and I had to retype it all again to get it to finally work.
Programming homework and newbie help thread Quote
04-26-2016 , 07:00 PM
Quote:
Originally Posted by goofyballer
- don't call srand every time, just call it once at the start of your program (this isn't the reason why it's not working, just good practice)
- don't return "x ? true : false", just return x
- generally looks right as far as I can tell, but maybe try with smaller numbers and see if that works to see if floating point inaccuracy at the levels you're working with might be the problem. There are steps you could take in your code to reduce floating point error if that's the issue
- you can also add statements that log values at different points of the way to make sure it's behaving how you want it to, and identify where things are going wrong if it's not
Thanks for the feedback.

I commented out my srand call (I think srand is used elsewhere in the program) and I think it works now!
Programming homework and newbie help thread Quote
04-28-2016 , 07:27 AM
so, setting up a tournament bracket in html and css is really really challenging
Programming homework and newbie help thread Quote
04-28-2016 , 11:25 AM
Background image + ul > li ??
Programming homework and newbie help thread Quote
04-28-2016 , 12:12 PM
Quote:
Originally Posted by Victor
so, setting up a tournament bracket in html and css is really really challenging
I just did one but didn't finish it in time for march madness.
Let me know if you want it. It uses angular to update the picks
Programming homework and newbie help thread Quote
04-28-2016 , 01:57 PM
Quote:
Originally Posted by Shaomai888
Background image + ul > li ??
ya ended up using ul and li with flex grow. used this guys code as a template. http://codepen.io/aronduby/pen/qliuj

it had to be dynamic so I had to go back and add a round field to every game. then I iterated over the rounds then iterated over the games of each round.

it looks pretty decent, even for 128 teams

http://i.imgur.com/t3E2RP6.png

I am still working on an algorithm to figure out how to create the games for an amount of teams that isnt a power of 2. was able to derive an algorithm to figure out which game number the winner of the previous game number plays but it only works for tourneys with 2,4,8,16,32,64,128 teams.

Code:
                int gameTrack=(int) (game.getGameNumber()-(teams-teams/Math.pow(2,(game.getRoundNumber()-1))));
		if(gameTrack%2==0){
			int nextGame=(int) (teams-teams/Math.pow(2,game.getRoundNumber()))+gameTrack/2;
			String sqlUpdateQuery = "UPDATE game SET competitor_2 = ?  WHERE game_number = ? AND tournament_id = ?";
			jdbcTemplate.update(sqlUpdateQuery, game.getWinnerCompetitorId(), nextGame, tournamentId);
			
		}
		else{
			gameTrack++;
			int nextGame=(int) (teams-teams/Math.pow(2,game.getRoundNumber()))+gameTrack/2;
			String sqlUpdateQuery = "UPDATE game SET competitor_1 = ?  WHERE game_number = ? AND tournament_id = ?";
			jdbcTemplate.update(sqlUpdateQuery, game.getWinnerCompetitorId(), nextGame, tournamentId);
		}
so gameNumber 1 is the first game of the tourney. gameNumber 33 is the first game of the 2nd round of a 64 team tourney. I thought about that for 2 days and figured I would just have to brute force a bunch of if-statements, but then it hit me while I was driving and I pulled over and wrote it down on a napkin so I wouldnt forget.

anyway, decent project, was a ton of work due to large amount of data that needed to be recorded. way more than I thought it would be. Still could be modified to use javascript so its more interactive and I may do that if I cant find employment soon.
Programming homework and newbie help thread Quote
04-28-2016 , 02:01 PM
05-02-2016 , 06:08 PM
I'm just about to finish my first semester taking computer science courses. I want to sign up for at least two classes during the summer. The offerings are somewhat limited, though, and my options boil down to these:
1) Intro to Game Design - From what I understand from talking to others, this class basically consists of creating text based games in Python. I think it could be fun, but it's something I've already done a bit on my own and I'm not sure I would learn a whole lot from it. Python is at this point the only language I really know at all, from my intro classes, learnpythonthehardway, and a few other things I've done on my own.
2) Intro to Java
3) Intro to C#
4) Intro to C+

Is it a mistake to take intro classes in different languages at the same time? Regardless of that, any opinions on which language I should choose? I don't really have a particular focus in terms of what kind of programming I want to do right now, but if anyone could give me some insight into the strengths and major uses of the above languages, that would be great. Thanks for any input.
Programming homework and newbie help thread Quote
05-03-2016 , 06:43 AM
Hey friends, suppose if I want to run an exhaustive search across all permutations in 16 different arrays in c, is there a elegant way to write this without having 16 nested loops?
Programming homework and newbie help thread Quote
05-03-2016 , 07:02 AM
Quote:
Originally Posted by LBloom
Is it a mistake to take intro classes in different languages at the same time?
Nah.

Quote:
Regardless of that, any opinions on which language I should choose? I don't really have a particular focus in terms of what kind of programming I want to do right now, but if anyone could give me some insight into the strengths and major uses of the above languages, that would be great. Thanks for any input.
My subjective view:

1) Intro to Game Design - sounds fun but as you said, probably not the most usefull for you at this point.

2) Intro to Java - the language of the internet. It might not be hip-n-cool but it's the go to for large scalable distributed enterprise systems and its not going anywhere. (do this imo)

3) Intro to C# - the language of Microsoft. Similar to java in many ways, better than java if you want to make Windows Gui apps. Arguably worse than java for backend stuff because it forces you to use their proprietary tech stack.

4) Intro to C++ - the language of low level stuff and hardcore game programming.
Programming homework and newbie help thread Quote
05-03-2016 , 08:14 AM
Take c++ and Java. I felt more prepared to go deeper in Java after having a better understanding of c++
Programming homework and newbie help thread Quote

      
m