$ apt-get install libncurses5-dev
$ wget -c http://erlang.org/download/otp_src_19.3.tar.gz
$ tar xzf otp_src_19.3.tar.gz
$ cd otp_src_19.3/
| # Bash best practices and style-guide | |
| Just simple methods to keep the code clean. | |
| Inspired by [progrium/bashstyle](https://github.com/progrium/bashstyle) and [Kfir Lavi post](http://www.kfirlavi.com/blog/2012/11/14/defensive-bash-programming/). | |
| ## Quick big rules | |
| * All code goes in a function | |
| * Always double quote variables |
Not all random values are created equal - for security-related code, you need a specific kind of random value.
A summary of this article, if you don't want to read the entire thing:
Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.random-number-csprng.You should seriously consider reading the entire article, though - it's
| #!/bin/bash | |
| mkdir git-repo | |
| cd git-repo | |
| git init | |
| touch my_code.sh | |
| git add my_code.sh | |
| echo "echo Hello" > my_code.sh | |
| git commit -am 'initial' | |
| git checkout -b new_branch | |
| echo "echo \"Hello World\"" > my_code.sh |
| wait4eth1() { | |
| CNT=0 | |
| until ip a show eth1 | grep -q UP | |
| do | |
| [ $((CNT++)) -gt 60 ] && break || sleep 1 | |
| done | |
| sleep 1 | |
| } | |
| wait4eth1 |
I fell in love with CoffeeScript a couple of years ago. Javascript has always seemed something of an interesting curiosity to me and I was happy to see the meteoric rise of Node.js, but coming from a background of Python I really preferred a cleaner syntax.
In any fast moving community it is inevitable that things will change, and so today we see a big shift toward ES6, the new version of Javascript. It incorporates a handful of the nicer features from CoffeeScript and is usable today through tools like Babel. Here are some of my thoughts and issues on moving away from CoffeeScript in favor of ES6.
While reading I suggest keeping open a tab to Babel's learning ES6 page. The examples there are great.
Holy punctuation, Batman! Say goodbye to your whitespace and hello to parenthesis, curly braces, and semicolons again. Even with the advanced ES6 syntax you'll find yourself writing a lot more punctuatio
| // Pretend that cookies work | |
| (function (document) { | |
| var cookies = {}; | |
| document.__defineGetter__('cookie', function () { | |
| var output = []; | |
| for (var cookieName in cookies) { | |
| output.push(cookieName + "=" + cookies[cookieName]); | |
| } | |
| return output.join(";"); | |
| }); |
| /* | |
| * Copyright (c) 2014 LG Electronics. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| import os | |
| import asyncio | |
| import sys | |
| from asyncio.streams import StreamWriter, FlowControlMixin | |
| reader, writer = None, None | |
| @asyncio.coroutine | |
| def stdio(loop=None): |
For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.
Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.
You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.