• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 22:46
CET 04:46
KST 12:46
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband Information Request Regarding Chinese Ladder SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
Which season is the best in ASL? [ASL20] Ask the mapmakers — Drop your questions BW General Discussion FlaSh's Valkyrie Copium BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread The Perfect Game Path of Exile 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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1298 users

The Big Programming Thread - Page 385

Forum Index > General Forum
Post a Reply
Prev 1 383 384 385 386 387 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.
Gorlin
Profile Joined November 2010
United States2753 Posts
Last Edited: 2013-11-01 23:58:02
November 01 2013 23:57 GMT
#7681
On November 02 2013 08:23 RoyGBiv_13 wrote:
Show nested quote +
On November 02 2013 08:07 Zocat wrote:
On November 02 2013 07:59 WolfintheSheep wrote:
Most interview "problems" aren't about creating a solution, but writing code and having a thought process that the interviewer can evaluate.

Just because you can answer the problem doesn't mean you'll get the job. It just means that everything on your resume isn't fluff.


Yeah definitely (my post might've been a bit harsh).

If there's nothing else the interviewer can evaluate - be prepare those nonsense questions.
If you can provide other stuff (specific core knowledge in a field) and hint at it a good interviewer will ask you stuff about that topic. If he doesnt - he sucks (and yes, you should provide that as feedback to his company (but dont do this as a guy fresh from university)).

On November 02 2013 07:59 WoolySheep wrote:
On November 02 2013 04:55 autechr3 wrote:
On November 01 2013 20:27 icystorage wrote:
i have my first job interview in a week. It also includes an exam and I just know it's about problem solving in stuff. It's so general that i don't know what to study. Any tips? =/ i've been brushing up on my data structures.


I'll share the problem who's correct solution got me my job:

Write a function that takes in any integer and displays the time as a string. Think standard wall clock that only has a minute hand.

+ Show Spoiler +
Input: 90
Output: 12:15

+ Show Spoiler +
Input: 450
Output: 1:15

+ Show Spoiler +
Input: -90
Output: 11:45




every 360 is one hour, 0 = 12:00.

outPutTime(int num) {

int hours = num / 360;
int min = (num - hours*360) / 6;

hours %= 12;
if (hours == 0 ) {
hours = 12;
}

print(hours + ":" + min);
}


Something like that?


Define your language.
You do hours = num/360 and then mod 12 it.
The given example shows num can be negative (so hours can be neg).

Modulus for neg. numbers isnt clearly defined (math pov afaik).
It's down to the programming language how it's implemented.
http://www.yourdailygeekery.com/2011/06/28/modulo-of-negative-numbers.html

Actually: I didnt check if your example gives correct output. It's definitely possible Just wanted to mention: be careful in what language you do mod.



Dear god, why would any language output 12 for -1 % 13?


Because it's mathematically correct? The modulus function maps to the range 1 ... n-1
-1 and 12 are congruent mod 13, but -1 is not in the range of the function, so why would you return it?
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2013-11-02 00:08:33
November 02 2013 00:08 GMT
#7682
While I'm Friday'ing it up in this thread, I might as well share my horror story from the day.

Some brilliantly foolish customer of mine has the following C++ code:

HardwareExceptionDisabler const disableExceptions;
CauseADataAbortException(<address>);

They changed the version of the compiler, and the newer version rearrangedoptimizes this inlined function such that the data abort exception happened before the disabler was finished being constructed.

We tried making the member variables volatile, including the pointer to the handler for the data abort exception that was to be used in the regular handler's place in order to disable.
+ Show Spoiler +
Look up the difference between volatile int * funcPtr; and int * volatile funcPtr; for a good read.

This was insufficient as the vtable was never referenced in the function at all as no member functions were explicitly called before the disableExceptions deconstructor is called, so it was being initialized after the data abort exception, and thus the pointer hadn't been updated yet.

The answer was to use this declaration instead, for all their uses of this crazy way of disabling hardware exceptions:
HardwareExceptionDisabler const volatile disableExceptions;
also, marking all used member data and functions as volatile.

Compilers are scary :0.
Any sufficiently advanced technology is indistinguishable from magic
berated-
Profile Blog Joined February 2007
United States1134 Posts
November 02 2013 00:08 GMT
#7683
On October 31 2013 16:26 tec27 wrote:
Show nested quote +
On October 31 2013 14:49 teamamerica wrote:
On October 31 2013 14:09 tec27 wrote:
On October 31 2013 08:39 tofucake wrote:
On October 31 2013 07:36 misirlou wrote:
On October 31 2013 07:21 DeltaX wrote:
I would suggest that you actually write something before you go spend money on web hosting (or a domain name).

If you are starting out with zero programming experience, I would first just do something basic with just html/css. Next you would likely need to learn an actual programming language. Most modern sites have some javascript running in the browser and something running on a server that will serve the pages and can send information to the javascript.

As a rule of thumb:

If you want exactly the same pages for everyone all the time, you only need to know html/css.
If you want pages to change based on some user input or anything else, you need some logic somewhere (on server or javascript)
If you want pages to be able to change based on user input without reloading the whole page, you need to know javascipt


Bottom line, learn javascript and when you need to do server stuff, do it on node.JS. Express + EJS + Database Module (Sqlite3/Mongoose or any other) and it just works like a charm
It's a bit complicated getting your head around all those callbacks but once you realise how to use them and why they are there, it's pretty simple

That's a ridiculous suggestion. Most hosts don't allow node to be run on shared servers in the first place, which will result in either a large increase in cost or a lot of time wasted learning node.

Its not really a large increase in cost, but it does require more knowledge. You can get a pretty decent VPS for $5 a month that will have way less issues than all of the typical shitty shared hosting providers (and let me be clear, *all* shared hosting is shitty, no ifs, ands or buts). But yeah, if you don't have experience setting up a linux box and don't know how to install everything you need, secure the machine, etc. you'd be pretty screwed going that route. I love Node, but its not the right route for someone who's never touched web development before. That path is best served by Rails, or Django or PHP, and PHP is probably the easiest to find on any given host (basically every host will have it installed). I do, however, think PHP is a really shitty language and not very useful to learn, so if you're interested in taking things further then Rails (Ruby) or Django (Python) are much better options.


I'm not trying to cause a flame war or promote one language over another, but I'm curious as to why to consider PHP shitty. As a nooby programmer, I'm sure there are things that I just can't see about the language, so that's why I'm asking.

If you were developing a greenfield project, would you consider PHP significantly shittier then Ruby or Python? I say that as someone whose made few small PHP sites (and has also had to work with too much shitty db logic mixed with html snippets mixed with business logic and fix them...) - get some DB data (PDO works fine), allow CRUD operations, maybe scrape some websites using curls (curl_multi lets me at least kinda pull multiple sites at the same time), hash some pws (blowfish is pretty easy now!). I just javascript libraries for most of my view rendering and mostly OO code.

There are times I hate some of the std lib functions for always having their parameters in different orders (needle, haystack - haytack, needle) but with an IDE that looks up functions, that's not an issue for me, and now I can write OO PHP code fine. What are the killer features of Ruby and Python (the languages) that you love? This includes stuff like dependency management and the language tooling in general.

In the context of just web development - as someone who hasn't touched any of the major PHP frameworks e.g. Symfony, Zend, <insert your favorite PHP framework> - are these frameworks significantly less productive then <insert your favorite Ruby/Python framework>? I started the Rails tutorial but wasn't like blown away - maybe the magic came later? They just looked like the PHP framework tutorials I've seen (but again, I could just be blind to the differences)

If I had to pick up a new web framework I'm tempted to learn a Java/Scala/C# one cause I'd like stronger static code analysis + boring enterprise java jobs 4lyfe, but those are just my thoughts.

The link phar gave is decent, but I guess I'll summarize my personal views as well. Firstly, I don't use Ruby or Python on a daily basis, so I'm not really going to try to argue with anyone about how they're better for web development. They are merely the choices with the A) largest amount of noob-friendly documentation and B) large, well-maintained and used web frameworks. I use Java (Android) at work [and hate Java with a passion], and Javascript for basically everything in my free time, but I've also written a lot of code in C#, C, C++, Delphi, and PHP, along with a small amount in Ruby and Python.

PHP is a bad language to learn for beginners because of many reasons. First, there's a ridiculous amount of bad documentation, bad tutorials, and bad advice. PHP at this point has certainly "grown up" somewhat, but if you search for how to do something in PHP, its very likely you're going to find some horrible code somewhere that uses libraries that are completely frowned upon/maybe deprecated if you're lucky, and as a beginner you're going to have no way of figuring out that its wrong. And when you look at the next search result it'll be using the same thing, so it must be right! But its not. Sure, other languages have their fair share of bad, outdated advice; I know Javascript certainly does and its frustrating. But PHP stands out by far as the language with the worst examples on the Internet in my mind, and that alone makes it a bad choice for someone who lacks experience.

Next, you have PHP's standard library. PHP's standard library is extensive, and all documented on php.net to at least some extent (when its not being infected with malware and claiming its a false positive ). But its also full of a ridiculous number of quirks, of tons of libraries that do the same thing in subtly different ways, wildly inconsistent style, and way too many choices for a beginner. People that lack experience would do much better with a language that has a consistent, simple standard library that they can pick up quickly.

Lastly, there's the language itself. PHP has some really baffling semantics (e.g. foreach behavior), especially when you start getting into things that were obviously never intended back when Rasmus Lerdorf just wanted a replacement for perl for his personal website. Beginners may not run into these things often, but when they do, they'll be completely unequipped to figure out what's going on. Add to that the completely frustrating syntax error handling, and you have a recipe for PHP development being pretty non-enjoyable.

Since you may wonder why I hate PHP but love JS, since they both have baffling semantics at times and similarly bad examples throughout the web: I don't view Javascript as a wonderful language for beginners. I think Javascript can be a good choice, given that any person who runs a decently modern browser is just a couple keystrokes from a powerful REPL and the ability to interact with content throughout the web, but it certainly has its fair share of confusing elements and behavior. Overall, I like JS because it is semantically simple, for the most part, and incredibly flexible. JS offers little in the way of data structures, OO implementation, etc. but offers a ton in the way of molding it and using it how you wish. There's very little in the language that is "sacred", and you can modify and reproduce almost all of the behavior of the built-in types. Node continues the JS simplicity, offering a very minimal standard library and allowing you to pick and choose from a huge library of packages to get what you want. NPM (Node's package manager) is simple and awesome, and definitely the best package manager I have come across for a platform.

PHP, on the other hand, feels very much like something thrown together by people who didn't really realize the full implications of their choices. Its way too big for what it is, there's tons of stuff it accomplishes in C that you could never hope to do in actual PHP code, and tons of stuff is implemented in inconsistent and unexpected ways. Overall, its a very bewildering language to use, and doesn't even give you a great deal of power in exchange for your sanity. I don't think there is ever a project I would say PHP is the best choice for.


I'm a little late to the game, but this happens to always be one of my favorite debates, so I have to chime in.

Everyone has their own opinion as to what is a good beginner language and what is not, but, I'm always a little confused by everyone that states that PHP is _terrible_ to be a first language. While I certainly wouldn't pick PHP for any of my current projects, I do not regret learning PHP early on in the stages of my programming career for a couple of reasons:

* A ton of bad documentation can be better than no documentation. I know this seems crazy on the surface, but, when you first start programming you need something to keep you engaged. There is plenty of time to learn the ins and outs of programming -- we all aren't going to be enterprise architects or a javascript ninja in the early years, so I think its more important to find _a_ solution to your problem than to become frustrated and give up. As a few have pointed out, there is no shortage of people posting tutorials online.

* The cost to entry is so low. There isn't any struggling with setting up npm or learning tomcat and servlets, or learning how to get a django server running, or figuring out most of that stuff. Install LAMP, or WAMP and off you go. The feedback is instant, create a .php, use your <?php ?> and poof you have a dynamic webpage.

* It's really easy to be quick and dirty. When you have no programming experience at all, do you really think that complicating things by introducing MVC or asynchronous programming is the best idea? Wouldn't it be simpler if you started with how does the web work? Request, response, sessions, html... I've met enterprise java developers that struggle with these concepts, let alone total noobies.

I just don't buy that if you start out with a language that has problems that you are ruined for life. If you are a decent programmer you'll learn like the rest of us that you ultimately need to pick the right tool for the job, and the farther into your programming career you go that tool probably isn't going to be PHP. That doesn't mean that you need to trash the language completely though and ignore it because it does have its place.

Manit0u
Profile Blog Joined August 2004
Poland17490 Posts
November 02 2013 02:00 GMT
#7684
On November 01 2013 22:25 Encdalf wrote:
Show nested quote +
On November 01 2013 17:28 Manit0u wrote:
On November 01 2013 17:17 sob3k wrote:
On November 01 2013 16:27 Manit0u wrote:
Guys, a quick question for you. Do you know how to make the <footer> stick to the bottom of the page in HTML/CSS without reverting to putting everything into a big content-wrapper <div> and setting position: absolute; bottom: 0; to the <footer>?

I'm trying to make a fairly simple page and it's important that it follows a clear logic structure:

<header> (top of page, with <nav> section etc.)
<article> (actual page content)
<footer> (bottom of the page, copyright, site map etc.)

For some reason, if I won't wrap everything into one big <div> with height: 100% etc. the <footer> will overlap with <article> section and display itself in the middle of the page. It's driving me nuts.

+ Show Spoiler [HTML] +


<!DOCTYPE html>
<html>

<head>
<title>Some Simple Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="styles/site.css"/>
</head>

<body>

<div class="content-wrapper">

<header>

<img src="images/logo.png" class="logo">

<nav id="menu">
<ul>
<li><a class="active" href="#">Menu</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Staff</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>

<h1 class="title">Some Simple Website</h1>

</header>

<article>
<ul>
<li><h2>About Us</h2></li>
<li><p>Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est
laborum.</p></li>
<li><a href="#">More</a></li>
</ul>
</article>

<article>
<ul>
<li><h2>Gallery</h2></li>
<li><p>Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est
laborum.</p></li>
<li><a href="#">More</a></li>
</ul>
</article>

<article>
<ul>
<li><h2>Staff</h2></li>
<li><p>Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est
laborum.</p></li>
<li><a href="#">More</a></li>
</ul>
</article>

<article>
<ul>
<li><h2>Contact</h2></li>
<li><p>Lorem ipsum dolor sit amet, consectetur adipisicing
elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa
qui officia deserunt mollit anim id est
laborum.</p></li>
<li><a href="#">More</a></li>
</ul>
</article>

<footer>

<ul>
<li><h3>&copy; 2013</h3></li>
<li><h3>Author: John Doe</h3></li>
</ul>

<nav>
<ul>
<li><a href="#">Back to Top</a></li>
<li><a href="#">Site Map</a></li>
</ul>
</nav>

</footer>

</div><!-- .contnet-wrapper -->

</body>

</html>



+ Show Spoiler [CSS] +


html, body {
width: 100%;
height: auto;
margin: 0;
padding: 0;
background-color: #FFFFFF;
}

header {
width: 1000px;
height: 200px;
margin: 20px auto 50px auto;
border-bottom: 1px solid #E7E7E7;
display: block;
}

footer {
width: 1000px;
height: 70px;
position: absolute;
bottom: 0;
border-top: 1px solid #E7E7E7;
}

footer nav {
height: 40px;
}

footer nav ul, footer ul, #menu ul, article ul {
list-style: none outside none;
padding: 0;
margin: 0;
}

footer nav li, footer li {
display: inline-block;
width: 300px;
position: relative;
float: left;
margin-left: 200px;
}

footer h3 {
font: 12px Arial, sans-serif;
color: #8A8A8A;
letter-spacing: 1px;
}

footer nav a {
font: 12px Arial, sans-serif;
color: #E7E7E7;
}

footer nav a:hover {
color: #20ADA1;
}

.content-wrapper {
width: 1000px;
min-height: 100%;
height: auto;
margin: 0 auto;
display: block;
}

article {
width: 500px;
height: 300px;
margin: 0;
display: inline-block;
float: left;
}

article h2 {
font: 25px bold Arial, serif;
color: #20ADA1;
letter-spacing: 1px;
}

article p {
font: 14px Arial, sans-serif;
color: #8A8A8A;
letter-spacing: 1px;
text-indent: 20px;
width: 400px;
}

article a {
font: 12px Arial, sans-serif;
color: #E7E7E7;
text-decoration: none;
display: block;
float: right;
position: relative;
margin-right: 50px;
}

article a:hover {
color: #20ADA1;
}

img.logo {
width: 200px;
height: 200px;
margin-left: 30px;
display: inline-block;
float: left;
position: relative;
}

#menu {
width: 510px;
height: 40px;
margin-top: 60px;
margin-left: 200px;
border-bottom: 1px solid #E7E7E7;
display: inline-block;
float: left;
position: relative;
}

#menu li {
display: inline;
}

#menu a {
font: 20px bold Arial, sans-serif;
color: #E7E7E7;
text-decoration: none;
letter-spacing: 1px;
margin-left: 10px;
margin-right: 10px;
}

#menu a.active {
color: #20ADA1;
}

#menu a:hover {
color: #20ADA1;
padding-bottom: 15px;
border-bottom: 5px solid #20ADA1;
}

h1.title {
font: 36px bold large Arial, serif;
color: #20ADA1;
letter-spacing: 1px;
height: 45px;
width: 450px;
margin-left: 220px;
margin-top: 25px;
display: inline-block;
float: left;
position: relative;
}



Note: The above code is still very early in the works, so it's not very clean


Why is your footer using absolute positioning? Absolute positioning removes the element from the document flow. If you use relative positioning and put it below the articles it will naturally be pushed to the bottom of the page by them. If you want it to always show at the bottom of the screen then you would used position: fixed.


I don't want to make it fixed. Had to use absolute because with relative it wasn't pushed below articles and I have no idea why (tried it in various configurations and with different settings). I don't want to use the content-wrapper div or absolute positioning either, but for now it's the only way I can make it work. I checked the web and it seems that everyone is using this solution...

Edit: it works with relative position and inline-block display, but I still have to keep the content-wrapper, which I don't want to do.

+ Show Spoiler [CSS] +


html, body {
width: 100%;
height: auto;
margin: 0;
padding: 0;
background-color: #FFFFFF;
}

header {
width: 1000px;
height: 200px;
margin: 20px auto 50px auto;
border-bottom: 1px solid #E7E7E7;
display: block;
}

footer {
width: 1000px;
height: 70px;
position: relative;
display: inline-block;
border-top: 1px solid #E7E7E7;
margin-top: 50px;
}

footer nav {
height: 40px;
}

footer nav ul, footer ul, #menu ul, article ul {
list-style: none outside none;
padding: 0;
margin: 0;
}

footer nav li, footer li {
display: inline-block;
width: 300px;
position: relative;
float: left;
margin-left: 200px;
}

footer h3 {
font: 12px Arial, sans-serif;
color: #8A8A8A;
letter-spacing: 1px;
}

footer nav a {
font: 12px Arial, sans-serif;
color: #E7E7E7;
}

footer nav a:hover {
color: #20ADA1;
}

.content-wrapper {
width: 1000px;
min-height: 100%;
height: auto;
margin: 0 auto;
display: block;
}

article {
width: 460px;
height: 300px;
margin-left: 40px;
display: inline-block;
float: left;
}

article h2 {
font: 25px bold Arial, serif;
color: #20ADA1;
letter-spacing: 1px;
}

article p {
font: 14px Arial, sans-serif;
color: #8A8A8A;
letter-spacing: 1px;
text-indent: 20px;
width: 400px;
}

article a {
font: 12px Arial, sans-serif;
color: #E7E7E7;
text-decoration: none;
display: block;
float: right;
position: relative;
margin-right: 60px;
}

article a:hover {
color: #20ADA1;
}

img.logo {
width: 200px;
height: 200px;
margin-left: 30px;
display: inline-block;
float: left;
position: relative;
}

#menu {
width: 510px;
height: 40px;
margin-top: 60px;
margin-left: 200px;
border-bottom: 1px solid #E7E7E7;
display: inline-block;
float: left;
position: relative;
}

#menu li {
display: inline;
}

#menu a {
font: 20px bold Arial, sans-serif;
color: #E7E7E7;
text-decoration: none;
letter-spacing: 1px;
margin-left: 10px;
margin-right: 10px;
}

#menu a.active {
color: #20ADA1;
}

#menu a:hover {
color: #20ADA1;
padding-bottom: 15px;
border-bottom: 5px solid #20ADA1;
}

h1.title {
font: 36px bold large Arial, serif;
color: #20ADA1;
letter-spacing: 1px;
height: 45px;
width: 450px;
margin-left: 240px;
margin-top: 25px;
display: inline-block;
float: left;
position: relative;
}





To be honest, I'm not sure I completely got what you wanted there, but let's try it the way I understood it:
From what I got there you want to have a page with the head on top, then a couple of articles and the footer at the bottom.
And the footer should not be fixed, so it stays while crolling, instead simply below the content. From your html and css I understood that you wanted the articles to be displayed two in a row, centered on the page.
So far, thats actually pretty simple, if you wouldn't add that unusual request to no use a limiting container div.

Anyway, I used your html as reference and build a skeleton out of it. (different css though)
http://jsfiddle.net/ZrGQs/
Difference here is that the container ".content-wrapper" is ow called ".limiter" and only wrapped around the articles.
As for the clearfix, you could either use a clearfix, or simply a clear both on the footer. Depends on the additional usage of the limiter. (see http://jsfiddle.net/ZrGQs/1/ )

Now that one got only one update (http://jsfiddle.net/ZrGQs/2/ ), which is basically
article:nth-of-type(2n+1){
clear: left;
float: left;
}

As a fix for when the articles arn't the same height, which easily coud happen when filled with different content.
This is, in my optionion, a pretty solid cross browser solution, but your reueqst was to remove the container...

Removing the limiter and at the same time centering the content called for display: inline-block and text-align: center
Which results in basically http://jsfiddle.net/5FeAm/1/
However I couldn't find a way to limit the articles to two per row. Instead they use up the available horizontal space.
You could add a <br> after every second article (http://jsfiddle.net/5FeAm/2/) but that's not an elegant solution either.
If someone finds a solution for that, I'd be happy to hear it.

Approaching it from a different angle, I went back to "float" and let the articles float again, using the above selector to break into a newline after two articles. But since there is no limiting and centering div, the only option I saw to get them centered was to use a margin-left, which had to be calculated:

article:nth-of-type(2n+1){
clear: left;
float: left;
margin-left: calc(50% - 480px);
}

Resulting in the full code: http://jsfiddle.net/dZFA2/
The downside is of course the usage of calc which isn't exactly cross browser compatible (yes, you could polyfill but stilll..)

Any real elegant cross browser solution? For now I couldn't come up with any, maybe someone else has an idea? Except to stick to the limiter div, it saves you trouble.
And if my idea of what you wanted in the first place is completely differenct from what I tried to solve.. well..at least the laundry is done by now..


Thanks for the insight. I'll take a closer look into that.

On November 02 2013 01:38 Rotodyne wrote:
Hey Manit0u,

When I remove the container div and change the footer code to


footer {
width: 1000px;
height: 70px;
border-top: 1px solid #E7E7E7;
}


The footer stays at the bottom. From what I can see the only difference is the articles are no longer centered?


That's because for some reason it doesn't treat the footer as separate block and tries to align it with the articles (pushing them aside).

I've been taking a closer look at this and decided to leave the wrapper since it's the only way I can get the desired behaviour out of the site. I've even encapsulated all of the articles into a single container. With other methods I've noticed 2 major problems:
1. Footer not being in the same place on every single page (if I would have only 2 articles instead of 4, the footer would be pushed up and it looks bad). I want the page having fixed width and height in all views, to make it really consistent.
2. When resizing browser window to something small the footer would float to the top, overlapping other things. I don't want it to move.

Articles being too large isn't really that much of the issue since there won't be dynamic content in them really. The website will serve mainly as a rather glorified online business card.
Time is precious. Waste it wisely.
WoolySheep
Profile Blog Joined October 2010
Canada82 Posts
November 02 2013 11:16 GMT
#7685
On November 02 2013 08:57 Gorlin wrote:
Show nested quote +
On November 02 2013 08:23 RoyGBiv_13 wrote:
On November 02 2013 08:07 Zocat wrote:
On November 02 2013 07:59 WolfintheSheep wrote:
Most interview "problems" aren't about creating a solution, but writing code and having a thought process that the interviewer can evaluate.

Just because you can answer the problem doesn't mean you'll get the job. It just means that everything on your resume isn't fluff.


Yeah definitely (my post might've been a bit harsh).

If there's nothing else the interviewer can evaluate - be prepare those nonsense questions.
If you can provide other stuff (specific core knowledge in a field) and hint at it a good interviewer will ask you stuff about that topic. If he doesnt - he sucks (and yes, you should provide that as feedback to his company (but dont do this as a guy fresh from university)).

On November 02 2013 07:59 WoolySheep wrote:
On November 02 2013 04:55 autechr3 wrote:
On November 01 2013 20:27 icystorage wrote:
i have my first job interview in a week. It also includes an exam and I just know it's about problem solving in stuff. It's so general that i don't know what to study. Any tips? =/ i've been brushing up on my data structures.


I'll share the problem who's correct solution got me my job:

Write a function that takes in any integer and displays the time as a string. Think standard wall clock that only has a minute hand.

+ Show Spoiler +
Input: 90
Output: 12:15

+ Show Spoiler +
Input: 450
Output: 1:15

+ Show Spoiler +
Input: -90
Output: 11:45




every 360 is one hour, 0 = 12:00.

outPutTime(int num) {

int hours = num / 360;
int min = (num - hours*360) / 6;

hours %= 12;
if (hours == 0 ) {
hours = 12;
}

print(hours + ":" + min);
}


Something like that?


Define your language.
You do hours = num/360 and then mod 12 it.
The given example shows num can be negative (so hours can be neg).

Modulus for neg. numbers isnt clearly defined (math pov afaik).
It's down to the programming language how it's implemented.
http://www.yourdailygeekery.com/2011/06/28/modulo-of-negative-numbers.html

Actually: I didnt check if your example gives correct output. It's definitely possible Just wanted to mention: be careful in what language you do mod.



Dear god, why would any language output 12 for -1 % 13?


Because it's mathematically correct? The modulus function maps to the range 1 ... n-1
-1 and 12 are congruent mod 13, but -1 is not in the range of the function, so why would you return it?


Hey guys - it was just some pseudo code written to look like code. I didn't actually test it with values. Assume error checking happens before the function is called, and i based it off of Java, where int divided by int takes the floor.


tec27
Profile Blog Joined June 2004
United States3702 Posts
November 02 2013 12:02 GMT
#7686
On November 01 2013 17:05 sluggaslamoo wrote:
Show nested quote +
On November 01 2013 16:13 tec27 wrote:
What's the last version of Node you used? Native library support has been fine ever since the introduction of node-gyp, which was around 0.6 or so (so like, over a year ago). Pretty much no packages depend on a specific NPM version, so I'm not really sure where you're getting that from, and NPM is installed as part of node, so its not likely people aren't going to be on relatively similar versions. Modules being installed in the source directory is a *feature*, a very valuable one, I'm not sure why you would complain about that. Having a global repository for all the modules you use throughout all of the code on your computer is a recipe for disaster. By keeping modules local to the place where they are used (and recursively so), you ensure that each module gets the things it was expecting, at the versions it was expecting, every time. Its not perfect, but no system is. Its far preferable from needing to create a virtual-env to keep everything separate or install things without root permissions, and it also allows you to check your dependencies into version control for deployable applications, which makes for much easier bisecting to find regression causes.

NPM and all of the other Node package managers that came before it would certainly have existed without Rubygems. The point of my previous reply was to demonstrate that you were being revisionist: CPAN has been around and hugely popular for far longer than gems. It is the package management system that all other language's systems strive to be. Period. Any decently productive language nowadays basically *has* to have a package management system: NPM for Node, `go get` for golang, Nuget for C#, the list goes on. You can't honestly believe they're all "copying Ruby" just because they see value in making reusable modules easy to download, install and use.

Node is also not copying Ruby in the least. I'm not even sure how I can take you seriously if you try to state that there "aren't many unique node modules." Did you like search through a list of all the node modules in existence and check off the ones that were "copies of Ruby modules?" All 45,000 of them? I don't really care if you make recommendations or give advice or commentary about things you have knowledge of, but this is like the 4th or 5th time you've tried to tell someone that you're experienced in Node, when you clearly have no idea wtf you're talking about. Just stop.


Wow chill out dude, you are taking this very personally.

Sorry, I'll try to be more civil. I just think there are a lot of impressionable programmers here, I don't like seeing them get what I think is bad information.


I'm not saying its a bad thing, I'm just stating that that is what is happening, I'm not really fussed. I like Node.

I'm using Node right now for regression testing in a professional environment and all my claims are due to experience.

(hell I even suggested using it when we needed a continuous integration framework set up)

Show nested quote +
Firstly, I don't use Ruby or Python on a daily basis, so I'm not really going to try to argue with anyone about how they're better for web development.


So you said yourself that you don't really use Ruby, so how would you know?

I can say these things because I use both, how would you know that there aren't heaps of carbon copies of Ruby gems if you haven't used both?

Pretty much the typical stacks for Node websites are very similar to Ruby, you cannot say that of other languages.

You make a website using Jade, Stylus, Coffeescript, Jasmine, Zombie, Cucumber, Sinatra.

Jade is basically Slim, Stylus is basically Sass, Jasmine is a clone of Rspec, everything else bar Zombie is a carbon copy of the Ruby version with JS on the end of it. There was no predecessor for the Ruby versions of those libraries either.

I did mention that there are some Node modules that I like that aren't in Ruby in the above post, but there are a lot of copies, and there is no denying it, and I'm not saying its a bad thing.

I said I don't use Ruby on a daily basis, I *have* used it in the past and try my best (and I think do a fairly good job of) keeping up with developments across platforms. You're cherrypicking a lot of modules here to make your case. Jade, Stylus and Jasmine are derived from other things, Ruby things, absolutely. Jade and Stylus are both by tjholowaychuk, who is/was one of the most "rubyist" noders there is. Connect/Express have their roots in Sinatra, and both were also the work of TJ. Jasmine, on the other hand, isn't even a Node thing, it's been around since 2008. You can't pick these things and use them to say that all Node modules, or even lots of Node modules are just clones of things in Ruby. TJ, for one, has since realized/decided that these modules were not optimal for Node and taken different approaches for each of their domains.

And then you have all of the other prolific Node module writers that write stuff like you would never, ever see in Ruby. People like substack, who have hundreds of modules, have never been part of the Ruby community, use nothing from the Ruby community, and have opinions diametrically opposed to what is commonly accepted there. The fact that you ignore all of that, especially when those sorts of people occupy almost the entirety of the thought leadership in Node, shows me that you are either cherrypicking examples dishonestly, or out of touch with what Node actually is.


Show nested quote +
Pretty much no packages depend on a specific NPM version, so I'm not really sure where you're getting that from, and NPM is installed as part of node, so its not likely people aren't going to be on relatively similar versions.


I had to update NPM a few weeks ago because Karma depended on a newer version of NPM (it literally wouldn't let me install Karma stating that it required a later version of NPM). I've experienced this plenty of times. This ends here.

I've never, ever seen this happen through many, many Node projects and extensive use of NPM. That's obviously not very useful given that you claim to see it, but you seem to again be picking a single example and extrapolating it to the entire Node ecosystem. Karma's even a bit of a special case, since its just a utility that happens to be available in NPM, not really a module in the typical sense. I'd be interested to see the error it was giving you, since NPM is basically feature-stable at this point, and Node's module system is certainly not changing.

I even just searched through the NPM source for the words "later", "upgrade", and "update", and the only relevant things I can find are telling you to upgrade Node because the package requires a later version. This would indicate that you're either running really outdated versions of Node, or you misunderstood the message you were seeing. I also searched through Karma's repo, and found no relevant results. Given that Karma requires 0.8 or 0.10, this would mean you were running 0.6? If so, you would be running a version that is 2 years old and complaining that you were forced to upgrade because a module properly delineated what versions it supported.


Show nested quote +
Modules being installed in the source directory is a *feature*, a very valuable one, I'm not sure why you would complain about that. Having a global repository for all the modules you use throughout all of the code on your computer is a recipe for disaster. By keeping modules local to the place where they are used (and recursively so), you ensure that each module gets the things it was expecting, at the versions it was expecting, every time. Its not perfect, but no system is.


Bundler gives you the option of doing it exactly the way NPM does it. You can even force other users of your repository to do it this way, or if your production environment does not support Rubygems, but nobody uses it because its a PITA. If it was as good as you said it was, and the alternate was a recipe for disaster, then why isn't anybody using that widely accessible feature for Ruby?

You said yourself its a pain to use, don't you think that might be why people don't use it? The file structure it generates might be similar, but its clearly not the same thing as Node's module system, which is about as simple to use and non-magical as it can get. Node's module system also provides a number of advantages WRT to dependency versioning, whereas Bundler's local install just gives you a per-project global module store, instead of a completely global one.


However global libraries is not well supported well in NPM, maybe that's why you think its a recipe for disaster? But if done well, its amazing, ala Bundler/Rubygems.

I do not want to clone a repository with all the libraries source code bundled with it, when I already have the libraries. If you are really concerned about people not using the latest update, put in a version lock in the Gemfile, it is not a "recipe for disaster" and works much better than NPM (In My Humble Opinion). The lockfile by default already handles all of this for you anyway if you're lazy.

Trust me, when you've worked on the same language for years you pretty much have every library out there updated to the latest version. I see no point in having to,
1. Spend ages downloading libraries I already have
2. Keep 5 copies of the same library up to date because I have 5 repositories with the same library, I'd rather just update the one.
3. Waste valuable hard drive space, because every KB matters K? Actually I just wanted a #3 because the list looks weird with only 2 points.

I get this is a matter of preference, but saying it is a recipe for disaster when Rubygems is a much more mature system of which I have had literally 0 problems with in 4 different companies makes you more biased than I am. You don't even use it, at least I use Node.

You're thinking about this in a very flat manner, e.g. "My Applications" -> "My Applications' Dependencies". That's not really how things work in the real world. Your dependencies have dependencies, those dependencies have dependencies, etc. Especially in Node, where the generally encouraged practice is to keep your modules as small and single-function as possible, each module can end up with a ton of other modules it needs. And moreover, it will need a specific version of that module (or at least within whatever semver range the module author has specified).

If you control the code, then having the latest version of everything can work great, because you can always update all of your code to work with whatever other changes you made. The minute you don't control some code, however, and that code depends on some other code, it becomes much harder to always guarantee you can use the latest version. You especially start to run into problems when two modules you don't control both require the same dependency, but at a different version number. Your options are basically to find some version of the dependency that will satisfy both, or submit pull requests to the maintainers with fixes to get them on the latest version. With NPM's local approach, on the other hand, each module can get the exact version it needs, and the two modules are both happy with no changes.

As substack said in his blog on the "node aesthetic":
All of this preferred locality in the module loader has the very important practical upshot in that you can depend on different versions of modules in different places in your program's dependency graph and node will pick the most local dependency for each module. So if a module "foo" was tested against and depends on "baz@0.1.x" and a module "bar" depends on "baz@0.2.x", then when you go to use both "foo" and "bar" in your own program, "foo" and "bar" will both use the version of "baz" that they were tested and depend against!

This approach to versioning means that nearly all modules should be interoperable with each other. It also means that module authors can be more aggressive with iterating and pushing out backwards-incompatible breaking changes to their APIs, so long as the authors are careful to increment the module version appropriately. Concurrent versioning and locality preference drastically accelerate the rate that we can iterate on new experiments and the levels of reuse that we can attain both in a single large project and among projects.


Download time (which is really never the bottleneck in your development, and you know it) and having multiple copies of the same library are a small price to pay for being able to use a huge number of different modules together, despite when they might have last been updated or how actively they were maintained. Having multiple copies of the same module also gives you the flexibility to update them at separate times in each project, which is important given that you have limited time, and you can't spend all your time updating your dependencies if you actually want to build new features. With NPM, you can strategically prioritize when it makes sense to update a specific dependency for each project, and not be hit with a huge time sink the first time you decide its worth it.

Anecdotal evidence isn't really helpful here, and of course I'm biased. I never said I was impartial, of course I'm partial to Node's module system. I think its superior for open source work, that's why I'm making the arguments I am.

I work at a company where every developer, all the many thousands of them, commits to the same repository and all of the builds of every project start from head. This is just about the largest sort of "global module repository" you will find in the world, and it certainly has advantages. But there's a key difference between what that system is and what Node is, and its the degree of control. In my company's repository, I can easily commit to anywhere. If I need to update some dependency, I can modify that dependency, and I can modify all of its dependents in one fell swoop. In Node, however, I'm stuck. Its incredibly unlikely that I have commit access to all the different modules I use, and so I have to send out pull requests to people and wait for them to respond, accept them, and re-publish the module. With a global module location, your likelihood of running into this problem grows exponentially with every new dependency you pull in. With Node's setup, you almost never have to worry about it, and you can update dependencies in individual modules at will and be sure of the effect its having.

An even closer analogy to the global module location at my company is how third-party libraries are dealt with. They're copied into the repository and pinned to a specific version, very similar to what lockfiles do. This works fine if you're the only one or part of a small group that depends on a library. Once you have a lot of code depending on a library, however, it starts to become very hard to ever upgrade that library again. The pressure is actually the *opposite* of what you're stating, that is, the pressure is to keep all of your dependencies on the same (older) version because there's too much other code you'd have to change to move to the latest. "Stop the world" upgrade paths clearly make it harder to actually upgrade your dependencies regularly, and the avoidance of this is a major advantage of a locally-installed module system.


The 4th or 5th time? Was this when I was talking about concurrent and asynchronous programming which is inherent in Node and arguing against people who said Node should be taught for beginners?

Its been months and still no one has come up with a single good answer to this, except "blah blah you're wrong you know nothing about Node shutup". So where's the counter argument?

Maybe I will quote you on something you said which may bring in some perspective

Show nested quote +
PHP is a bad language to learn for beginners because of many reasons. First, there's a ridiculous amount of bad documentation, bad tutorials, and bad advice. PHP at this point has certainly "grown up" somewhat, but if you search for how to do something in PHP, its very likely you're going to find some horrible code somewhere that uses libraries that are completely frowned upon/maybe deprecated if you're lucky, and as a beginner you're going to have no way of figuring out that its wrong.


And this... is exactly my problem with Node. Most people using nor teaching Node aren't actually using it correctly which is why it shouldn't be taught for beginners. A lot of node websites run slow as shit because they are doing synchronous programming in an asynchronous environment.

You made this quote so you should be able to see where I am getting at, and if you can't see that for yourself, well that's a problem.

You're quoting this as if I'm not aware I said it, or that I somehow said Node is a great environment for beginners. You should read the rest of my posts on that page, especially the one where I said:
On October 31 2013 14:09 tec27 wrote:
I love Node, but its not the right route for someone who's never touched web development before.


That said, I don't think Node is a horrible option for beginners, and I think you're crazy if you think people are teaching Node the wrong way. The vast majority of the Node tutorials out there are correct, you only get into trouble when you find old JS (and non-node-related) things. JavaScript is a hugely popular beginner language, it lets you get started very quickly, and it can be very powerful once you understand it deeply. There are tons of initiatives within the Node community to help beginners get started and interested, like JS For Cats, VoxelJS, and all of the nodebots stuff. Node is an incredibly welcoming community for beginners, and I would not be scared at all to drop a new programmer into it. The problem, to me, is that for a web app, Node is at a much lower level than your Rails or Django or Flask or PHP or whatever else. The CGI-model of request/response is far easier for a beginner to grasp in concert with HTTP than having a single process that stays around for the lifetime of your web app. That's the reason I would send someone elsewhere, not because I think everyone's doing it wrong: they aren't.

For the record, you think everyone is doing Node wrong because you don't get it. I know you hate to hear this, you just said so in your post after all, but it is absolutely true. There is a post that I clearly remembered when I wrote my previous post, and why I chose not to hold my tongue while you tried to talk about it this time. In it, you were arguing with fonger and telling him pretty much exactly the same things you posted here. Almost word for word exact. Then, you posted this code as an example of what you think is "proper Node style":

On March 15 2012 23:23 sluggaslamoo wrote:
So instead of

for(var i= 0, l = entries.length; i < l; i++) {
doSomething(entries[i]);
}


We have to use a non-blocking loop (and we will use an un-ordered loop because most of the time order doesn't matter)


var leftToProcess = entries.length;

for(var i = 0, l = entries.length; i < l; i++){
(function(foo){
process.nextTick(function(){
doSomething(foo);
if(--leftToProcess === 0){
done();
}
}
);})(entries[i]);
}



This is not proper Node style. This will never *be* proper Node style. There is not a single prolific Node committer who would tell you this is proper style.

Async functions are for things that are I/O bound, not CPU bound. Async functions *can* be for CPU bound things when you run those things in the background, but typically those are encapsulated in native modules (and exposed via an async interface) or via child processes (or, as is often the case, other node processes that communicate over sockets). You cannot achieve asynchrony by throwing process.nextTick calls around your inherently CPU-bound code, and by doing so you're making your code run a helluva lot slower, be way harder to JIT, and super ugly to write and maintain.

You used this as a club in your argument with fonger, trying to show him that Node was silly and not worth the development time tradeoffs (tradeoffs that only existed because you don't understand Node). I don't know where you got the idea that this silly crap was how Node was meant to be, but you should really spend some more time reading code that other people write before you start claiming that you're experienced in something. As I said before, it really irks me when people come in here and talk as if they're experts in something they clearly aren't, because beginning programmers have little way to discern that they aren't actually an expert.
Can you jam with the console cowboys in cyberspace?
misirlou
Profile Joined June 2010
Portugal3241 Posts
November 02 2013 12:56 GMT
#7687
On November 01 2013 17:05 sluggaslamoo wrote:

I do not want to clone a repository with all the libraries source code bundled with it, when I already have the libraries. If you are really concerned about people not using the latest update, put in a version lock in the Gemfile, it is not a "recipe for disaster" and works much better than NPM (In My Humble Opinion). The lockfile by default already handles all of this for you anyway if you're lazy.

Trust me, when you've worked on the same language for years you pretty much have every library out there updated to the latest version. I see no point in having to,
1. Spend ages downloading libraries I already have
2. Keep 5 copies of the same library up to date because I have 5 repositories with the same library, I'd rather just update the one.
3. Waste valuable hard drive space, because every KB matters K? Actually I just wanted a #3 because the list looks weird with only 2 points.

I get this is a matter of preference, but saying it is a recipe for disaster when Rubygems is a much more mature system of which I have had literally 0 problems with in 4 different companies makes you more biased than I am. You don't even use it, at least I use Node.

The 4th or 5th time? Was this when I was talking about concurrent and asynchronous programming which is inherent in Node and arguing against people who said Node should be taught for beginners?

Its been months and still no one has come up with a single good answer to this, except "blah blah you're wrong you know nothing about Node shutup". So where's the counter argument?

Maybe I will quote you on something you said which may bring in some perspective

Show nested quote +
PHP is a bad language to learn for beginners because of many reasons. First, there's a ridiculous amount of bad documentation, bad tutorials, and bad advice. PHP at this point has certainly "grown up" somewhat, but if you search for how to do something in PHP, its very likely you're going to find some horrible code somewhere that uses libraries that are completely frowned upon/maybe deprecated if you're lucky, and as a beginner you're going to have no way of figuring out that its wrong.


And this... is exactly my problem with Node. Most people using nor teaching Node aren't actually using it correctly which is why it shouldn't be taught for beginners. A lot of node websites run slow as shit because they are doing synchronous programming in an asynchronous environment.

You made this quote so you should be able to see where I am getting at, and if you can't see that for yourself, well that's a problem.


First off, Node_Modules should be gitignored. period. Second, you can install things globally with npm install -g. Then when you get to your source simply npm link --save said packages and they will instantly be added to package Json. The only thing that node is still lacking is linking instead of downloading when you simply 'npm link' with a package.Json already there. Currently it downloads all packages instead of trying to search for them on your global folder, if you don't want them to download, you have to link them by name one by one. Hope they can fix this some time before node 1.0 .
Pointing Node copies a lot of things from Ruby/Rails is cynical, especially when you specifically point gems that aren't even original to Ruby but are from PHP.

On other news, Im falling in love with EJS :D.
This week my college will host a contest of student projects, can be from courses, but I think I'm going to do a brand new just for it and have some fun and learn something. Thinking RPi Room Mp3 Player controlled by node (drag and drop website, play that music, commands for pause and resume) with a route to ring a doorbell (stop music, ring and resume music), nothing too hardcore but fun enough .


tec27
Profile Blog Joined June 2004
United States3702 Posts
November 02 2013 13:08 GMT
#7688
On November 02 2013 21:56 misirlou wrote:
First off, Node_Modules should be gitignored. period.

There are perfectly valid reasons to check your dependencies into git, see: http://www.futurealoof.com/posts/nodemodules-in-git.html (That's even in the npm FAQ for christ's sake, quit acting like its a hard and fast rule )
Can you jam with the console cowboys in cyberspace?
Amnesty
Profile Joined April 2003
United States2054 Posts
November 03 2013 18:47 GMT
#7689
I need to learn SQL. Really, just queries and consumption of a database. I don't have to admin it.
Can someone give me some links to start.
I'm a hands on learner mostly. I would like to setup a local database and play around with it.
What editors are good for creating queries?
Is there a database i can use locally (after downloading it?), or would i need to create one?
The sky just is, and goes on and on; and we play all our BW games beneath it.
Fission
Profile Blog Joined August 2010
Canada1184 Posts
Last Edited: 2013-11-03 19:48:53
November 03 2013 19:31 GMT
#7690
On November 04 2013 03:47 Amnesty wrote:
I need to learn SQL. Really, just queries and consumption of a database. I don't have to admin it.
Can someone give me some links to start.
I'm a hands on learner mostly. I would like to setup a local database and play around with it.
What editors are good for creating queries?
Is there a database i can use locally (after downloading it?), or would i need to create one?


Hey - MS SQL server express is a good and free database which you can learn on. MySQL is also another good starting point if you prefer non-microsoft stuff. I believe they both come with a default db schema which is standard for many sql-server related tutorials etc. Most learning resources will supply a db for you to go through exercises anyways. All the main RMDBS use the same SQL, so once you learn it, it's basically the same everywhere (except for minor syntactic flavouring). Avoid Oracle DB if you value your sanity (source: I am an oracle pl\sql programmer and data analyst).

http://www.microsoft.com/en-ca/download/details.aspx?id=29062

http://dev.mysql.com/downloads/mysql/
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-11-03 22:50:56
November 03 2013 22:42 GMT
#7691
On November 04 2013 03:47 Amnesty wrote:
I need to learn SQL. Really, just queries and consumption of a database. I don't have to admin it.
Can someone give me some links to start.
I'm a hands on learner mostly. I would like to setup a local database and play around with it.
What editors are good for creating queries?
Is there a database i can use locally (after downloading it?), or would i need to create one?

In my class we're using postgresql locally.

There are free courses for all different types of SQL on coursera, probably khan academy too. It can be worthwhile taking a course on databases if you have the time, otherwise you'll never be really efficient at using them and won't be able to make advanced queries so you'll have to spend more time coding in another language.

Depending on which database you're working with, there are many editors.
For postgres, I use the native pgadmin
For mysql I use mysql workbench
And I remember using something else for mssql. edit: I think it was ms sql server management studio.


Why are you learning sql? A friend recently recommended I look into Parse which is supposed to be an easier way to handle back ends.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
bangsholt
Profile Joined June 2011
Denmark138 Posts
November 04 2013 01:00 GMT
#7692
As you're learning you shouldn't rely on IDEs - so my suggestion is to go with sqlite3 link

Use the commandline interface, learn to type the correct queries and how they work. A short and not finished book to look into is this this
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
November 04 2013 02:19 GMT
#7693
You want a horror story?

We spent three weeks debugging something crashing our user authentication system. If you log in multiple times with a specific type of user, there was a possibility that the application would throw a NullReferenceException somewhere in the authentication library. The authentication system is outsourced so we couldn't just apply null checks in the code.

After an insane amount of debugging, we found the issue to be the existence of a progress bar on our splash page. Even though it had absolutely no relevance to the authentication system, removing the progress bar would reliably disable the exception, and adding it back in would cause the exceptions to occur again.

Why am I in programming again?


I managed to reproduce the bug reliably outside of the application just as the client started getting angry (it took a while) and just before the higher-ups okay'd the command to sent the client our source code for them to debug the issue internally. It was such a relief.
There is no one like you in the universe.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
November 04 2013 02:52 GMT
#7694
On November 02 2013 21:02 tec27 wrote:
For the record, you think everyone is doing Node wrong because you don't get it. I know you hate to hear this, you just said so in your post after all, but it is absolutely true. There is a post that I clearly remembered when I wrote my previous post, and why I chose not to hold my tongue while you tried to talk about it this time. In it, you were arguing with fonger and telling him pretty much exactly the same things you posted here. Almost word for word exact. Then, you posted this code as an example of what you think is "proper Node style":

Show nested quote +
On March 15 2012 23:23 sluggaslamoo wrote:
So instead of

for(var i= 0, l = entries.length; i < l; i++) {
doSomething(entries[i]);
}


We have to use a non-blocking loop (and we will use an un-ordered loop because most of the time order doesn't matter)


var leftToProcess = entries.length;

for(var i = 0, l = entries.length; i < l; i++){
(function(foo){
process.nextTick(function(){
doSomething(foo);
if(--leftToProcess === 0){
done();
}
}
);})(entries[i]);
}



This is not proper Node style. This will never *be* proper Node style. There is not a single prolific Node committer who would tell you this is proper style.

Async functions are for things that are I/O bound, not CPU bound. Async functions *can* be for CPU bound things when you run those things in the background, but typically those are encapsulated in native modules (and exposed via an async interface) or via child processes (or, as is often the case, other node processes that communicate over sockets). You cannot achieve asynchrony by throwing process.nextTick calls around your inherently CPU-bound code, and by doing so you're making your code run a helluva lot slower, be way harder to JIT, and super ugly to write and maintain.

You used this as a club in your argument with fonger, trying to show him that Node was silly and not worth the development time tradeoffs (tradeoffs that only existed because you don't understand Node). I don't know where you got the idea that this silly crap was how Node was meant to be, but you should really spend some more time reading code that other people write before you start claiming that you're experienced in something. As I said before, it really irks me when people come in here and talk as if they're experts in something they clearly aren't, because beginning programmers
have little way to discern that they aren't actually an expert.


Thanks for your reply, I read it all and usually I don't have time to answer all of your points because I only spend time doing this bored at work but I guess I have to reply to this one. I will respond to the others later .

Pretty sure this example was written for pre v10 node, it is no longer the correct way to use nextTick.

At the time I wasn't using node for a while. I had used node extensively at Deloitte prior to v10, from which that post was probably made only a few months after the patch. So my bad if that's what you were pointing out.

You may also point out that this is why Karma needed the update, it had to do with the fact that Ubuntu's package manager installed pre v.9 NPM which I needed for Karma IIRC. Regardless, you can have an old as balls version of gems and still use everything, it wasn't meant to be the focal point of my argument, I still think its a valid point, but its a small one and I'm willing to let that pass.

If you were going to make the case that I shouldn't have made the post then (pre-emptively, got nothing against you), I wouldn't count out anyone's suggestions when Node makes big changes to their platform all the time. For any other language it would still have been an "experienced programmers" answer. I just want to say this incase you were to bring it up, but I'd also happily bring up the fact that this also works against your case.

You cannot achieve asynchrony by throwing process.nextTick calls around your inherently CPU-bound code, and by doing so you're making your code run a helluva lot slower, be way harder to JIT, and super ugly to write and maintain.


That said the argument you made against it makes me think you misunderstood though. The basic idea was to defer the execution of the operations inside the loop so that other users could use my website without being locked out.

I don't think you understand the point of nextTick and why it was being used. I don't want to repeat myself so I will explain more about the idea behind that example and why I was making that point below.

Please have a read through this, this is also based on the pre v10 nextTick but its a decent primer nevertheless. There are a couple of people that tried to argue against that post but they are incorrect, keep that in mind.

http://howtonode.org/understanding-process-next-tick

For the record, you think everyone is doing Node wrong because you don't get it. I know you hate to hear this, you just said so in your post after all, but it is absolutely true.


This is an unfair suggestion when I could have said the exact same to you and I haven't said it.

Its just like your example of PHP, I just don't buy it. You just claimed that the majority of PHP examples, the language and the like is bad.

What would you do if some fanatic PHP developer who has barely touched Node, started doing the same thing.

That said, I don't think [PHP] is a horrible option for beginners, and I think you're crazy if you think people are teaching Node the wrong way. The vast majority of the [PHP] tutorials out there are correct...


For the record, you think everyone is doing [PHP] wrong because you don't get it. I know you hate to hear this, you just said so in your post after all, but it is absolutely true.


Actually rephrase all your post as if it were a PHP developer talking to you after just making those points about PHP, and put yourself in my shoes. Do you think its fair?

And would you just admit it? Cmon. For the record I disagree, otherwise I wouldn't be posting.

I think you should drop it, this gets us no where.

That said, I don't think Node is a horrible option for beginners, and I think you're crazy if you think people are teaching Node the wrong way. The vast majority of the Node tutorials out there are correct, you only get into trouble when you find old JS (and non-node-related) things.


Async functions are for things that are I/O bound, not CPU bound


This is not true at all, unless I'm misunderstanding something or you made a mistake in your wording.

I think I explained this in that post that you quoted me for, but it is very important to realise for beginners that unlike Ruby/PHP and other platforms, NodeJS does not spawn separate threads for each connection (like a user). So either I'm misunderstanding you, or you are missing out on a very integral part of how NodeJS works.

http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/

In other platforms such as Ruby, IO is run synchronously for each connection (unless you don't want it to), this is made possible because each connection has a separate thread allowing them to run in parallel anyway.

NodeJS does the opposite, because there is only one thread (or more but agnostic to the number of connections) to run CPU processes, the creators made IO operations by default run asynchronously. Now this has pros and cons, the biggest pro is performance and and a more managed environment.

What makes me think you are misunderstanding something is that what you call asynchronous functions are actually callbacks (which I guess can fall under the umbrella of asynchronous functions but its not what I meant). Yes you need callbacks for IO operations because otherwise you can't continue where you left off. You do need "asynchronous functions" for CPU operations.

For cheap CPU operations you can afford to run things synchronously, most libraries (for example a library of helper functions) are very simple and consist of very cheap operations and don't need code like this.

And as I was referring to the point of examples earlier, in the context of the example it is correct, however the problem lies when a user goes to copy it and uses it for an expensive operation in which case it is the wrong way to do it. In which case my argument makes perfect sense.

In a real application you aren't working on trivial code, in any large project you will be doing BIG operations.

This is not so bad for anyone using Ruby or PHP, sure you should probably defer something to a worker process that will hog the CPU. But its not gonna kill you if you don't, often it will barely be noticeable unless its of a ridiculous proportion, simply due to the innate parallelization coming from spawning a new thread each time.

In Node this is a BIG deal. I'm pretty sure I mentioned this with the example, but for even slightly expensive processes you should either run them in parallel or defer them, which is where the example came in.

If you are going to run a big fat loop, and NodeJS runs its CPU processes in a single thread means that if you run the loop synchronously you are blocking anyone else from using the application while this loop is running. Therefore you either, run it parallel OR defer it and allow others to do simple tasks during your loop.

IT DOESN'T MATTER WHAT ANYONE THINKS, BECAUSE THIS IS HOW YOU HAVE TO DO IT, OTHERWISE YOU ARE DEFYING THE MOST BASIC LAWS OF COMPUTING!!!

I don't know what else to say to this. Single thread + no asynchronous = a lot of very sad pandas using your site!

and by doing so you're making your code run a helluva lot slower, be way harder to JIT, and super ugly to write and maintain.


THAT IS EXACTLY MY POINT!!!!

You believe it looks ugly and hard to maintain? Well too bad, its NodeJS and you gotta fucking do it, because everything runs in a single thread. Doesn't matter what anyone says, that's the system.

Now this is where I'm confused, either you are running everything synchronously in your production environment, and your production environment has so much metal in it that it can afford to do this OR you have a bunch of helpers which is abstracting your from the process and you don't realise you are doing it OR you are using a router/framework that spawns separate threads for each user (there are some out there) although it completely defeats the purpose of using NodeJS.

So when I see an example which is often used for an expensive operation, and there's no option for asynchronous, then I think its a bad example. Which is why I make the same point for Node for beginners that you did for PHP.

Now its been ages since that post so I don't really remember but in the case of development trade offs. If I had to choose between Node and Ruby, you are definitely going to write more Node than Ruby, a lot more. You don't have to manage a lot of the stuff you have to do in Node, such as callbacks and parallelization. Also even tho JS is functionally oriented, I still find myself doing more powerful functional programming in Ruby, because of its in-built libraries and syntactic sugar. So my code ends up being much much more concise in Ruby than it does in even Coffeescript.

Yes there is a lot of really cool stuff even in Javascript alone, I fucking... love... functional programming, I love Coffeescript, but I'd still pick Ruby over Node any day for productivity.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
November 04 2013 03:20 GMT
#7695
On November 04 2013 03:47 Amnesty wrote:
I need to learn SQL. Really, just queries and consumption of a database. I don't have to admin it.
Can someone give me some links to start.
I'm a hands on learner mostly. I would like to setup a local database and play around with it.
What editors are good for creating queries?
Is there a database i can use locally (after downloading it?), or would i need to create one?

Just a side-note: It's always good to learn some SQL, but manipulating a database that you're not admining is a recipe for nightmares and headaches that should never be allowed to happen.

Again, nothing with becoming more knowledgeable, but if you actually have a dedicated database admin or team, let them handle any database interaction, no matter how trivial something might be. Even something as simple as a SELECT query...you might think it's minor, but you could easily expose some information that shouldn't be made public.
Average means I'm better than half of you.
Fission
Profile Blog Joined August 2010
Canada1184 Posts
Last Edited: 2013-11-04 04:49:47
November 04 2013 04:49 GMT
#7696
On November 04 2013 12:20 WolfintheSheep wrote:
Show nested quote +
On November 04 2013 03:47 Amnesty wrote:
I need to learn SQL. Really, just queries and consumption of a database. I don't have to admin it.
Can someone give me some links to start.
I'm a hands on learner mostly. I would like to setup a local database and play around with it.
What editors are good for creating queries?
Is there a database i can use locally (after downloading it?), or would i need to create one?

Just a side-note: It's always good to learn some SQL, but manipulating a database that you're not admining is a recipe for nightmares and headaches that should never be allowed to happen.

Again, nothing with becoming more knowledgeable, but if you actually have a dedicated database admin or team, let them handle any database interaction, no matter how trivial something might be. Even something as simple as a SELECT query...you might think it's minor, but you could easily expose some information that shouldn't be made public.


It's not even just security concerns - even something as simple as a SELECT query can have catastrophic performance implications if the person writing it doesn't understand the database schema or network architecture (particularly important when using linked databases).
pyro19
Profile Joined August 2010
6575 Posts
November 04 2013 16:32 GMT
#7697
I need to write the Nicholl-Lee-Nicholl line clipping code in OpenGL.Any suggestions? Any good sites for openGL tutorials?
I have no idea what openGL is actually? I'm used to writing this stuff in C.
Thy Shall Die Alone...or emm..something like that.
ObliviousNA
Profile Joined March 2011
United States535 Posts
November 04 2013 17:26 GMT
#7698
What's a good OpenGL book? I have a decent background in it, but I want to learn the modern/correct way of doing things.

Considering:
http://www.amazon.com/OpenGL-Programming-Guide-Official-Learning/dp/0321773039/ref=sr_1_1?ie=UTF8&qid=1383584858&sr=8-1&keywords=opengl

http://www.amazon.com/OpenGL-SuperBible-Comprehensive-Reference-ebook/dp/B00E1GL1SO/ref=sr_1_2?ie=UTF8&qid=1383584858&sr=8-2&keywords=opengl

Neither have stellar reviews for their recent versions, which makes me a bit wary. I'm mainly looking for a good description of API and best practices with a refresher on the math.

Also, if someone could speak to the formatting/support for their e-books (with a smaller screen like the nex 7) that would be great!
Theory is when you know everything but nothing works. Practice is when everything works but no one knows why. In our lab, theory and practice are combined: nothing works and no one knows why.
Zocat
Profile Joined April 2010
Germany2229 Posts
November 04 2013 17:31 GMT
#7699
I heard the red book is often recommended. There should be (free) online versions available for some of the older editions. Might give those a look and then decide if it's worth paying.
"Advanced Graphics Programming Using OpenGL" is something recommended as well.

For non-OpenGL but 3D graphics overall: "Real-Time Rendering"
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-11-04 19:26:16
November 04 2013 19:02 GMT
#7700
I'm having some problems with a website. Sitegrounds says we are going over the CPU load available for our site. We upgraded and are still going over and sitegrounds is shutting us down.

It's definitely a cron issue rather than a visitors issue. All of the problems occur at 1AM or 2AM. HTTP CPU load is low but Cron CPU usage is high.
[image loading]

These cron job times are wrong. Add one hour for each one. Eg if it says it runs at 4:30, it really runs at 5:30 my time. Timezones.
[image loading]

How do I debug this?
I've looked at the error logs file and there's nothing from this month in it.
Which files should I be looking at?
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
Prev 1 383 384 385 386 387 1032 Next
Please log in or register to reply.
Live Events Refresh
PiGosaur Monday
01:00
#60
PiGStarcraft614
SteadfastSC169
CranKy Ducklings84
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft614
SteadfastSC 169
RuFF_SC2 113
Nathanias 84
StarCraft: Brood War
Artosis 670
PianO 57
Noble 32
Icarus 10
Dota 2
monkeys_forever418
Other Games
summit1g12071
JimRising 651
WinterStarcraft363
C9.Mang0358
ViBE173
Mew2King27
Organizations
Other Games
gamesdonequick1107
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Hupsaiya 77
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Azhi_Dahaki16
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo473
• Stunt259
Other Games
• Scarra1326
Upcoming Events
Wardi Open
8h 14m
StarCraft2.fi
13h 14m
Replay Cast
20h 14m
The PondCast
1d 6h
OSC
1d 12h
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 20h
Korean StarCraft League
2 days
CranKy Ducklings
3 days
SC Evo League
3 days
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
[ Show More ]
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
4 days
OSC
4 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
5 days
Wardi Open
5 days
StarCraft2.fi
5 days
Replay Cast
5 days
StarCraft2.fi
6 days
PiGosaur Monday
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
TLPD

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

Disclosure: This page contains affiliate marketing links that support TLnet.

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.