This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The objective of this post is to get you from absolutely nothing, to a fully functional nodejs environment. | |
Software used: Ubuntu 11.10, Nodejs v0.6.12, Nginx, MongoDB, Redis, and NPM modules. | |
1. Download and install the latest version of Ubuntu: http://www.ubuntu.com/download (don't select any extra items to install when prompted) | |
2. Once you are logged in and are at your Ubuntu command prompt, install the necessary software you will need: | |
a. sudo apt-get install openssh-server | |
b. sudo apt-get install libssl-dev | |
c. sudo apt-get install git | |
d. sudo apt-get install g++ | |
e. sudo apt-get install make |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error_reporting(E_ALL); | |
ini_set('display_errors', '1'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#save HTML content to file.html | |
curl -o /tmp/file.html http://glowgaze.com/ | |
#search by grep content in file.html | |
function get { | |
arr=(`cat /tmp/file.html | grep -o -E '(goto-+([0-9]*-)('$1')(\w)*)'`) | |
echo ${arr[0]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.copyDatabase("test","test_copy","127.0.0.1"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.contests_tbbt2013.aggregate( | |
{ $group: {_id: "$country", total: {$sum: 1} } } | |
); | |
db.contests_tbbt2013.aggregate( | |
{$group: | |
{ | |
_id:{ $dayOfYear:'$regdate' }, | |
sum:{$sum:1}, | |
date:{$first: '$regdate'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test | |
def initialize | |
@hash = {prop1: 'prop 1 value', prop2: 'prop2 value'} | |
end | |
def method_missing(m, *args) | |
#setter | |
if /^(\w+)=$/ =~ m | |
@hash[:"#{$1}"] = args[0] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#find string inside files | |
grep -rnw 'directory' -e "pattern" | |
#replaces string inside files, recursive | |
cd /home/www | |
find . -type f -print0 | xargs -0 sed -i 's/split(/explode(/g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def genFibo(arr): | |
arr.append( arr[-1]+arr[-2] ) | |
def isFibo(n, fibos): | |
if n in fibos: | |
foo = 'IsFibo' | |
else: | |
foo = 'IsNotFibo' | |
return foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
class Utopiantree | |
def cycle n | |
size = 1 | |
if n > 0 | |
for val in 0..n-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo /usr/sbin/useradd --shell /bin/bash --home /home/adminwebsite -g www-data adminwebsite | |
sudo mkdir /home/adminwebsite | |
sudo chown -R adminwebsite:www-data /home/adminwebsite | |
sudo chmod 0700 /home/adminwebsite | |
sudo passwd adminwebsite |
OlderNewer