This file contains 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
set nocompatible " choose no compatibility with legacy vi | |
syntax enable | |
set encoding=utf-8 | |
set showcmd " display incomplete commands | |
filetype plugin indent on " load file type plugins + indentation | |
"" Whitespace | |
set nowrap " don't wrap lines | |
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4) | |
set expandtab " use spaces, not tabs (optional) |
This file contains 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
require 'benchmark' | |
n = 100000 | |
Benchmark.bm do |x| | |
x.report('copy') { n.times do ; h = {}; h = h.merge({1 => 2}); end } | |
x.report('no copy') { n.times do ; h = {}; h.merge!({1 => 2}); end } | |
end |
This file contains 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
show databases; | |
create database play; | |
use play; | |
create table users (username VARCHAR(20), create_date date); | |
drop table users; |
This file contains 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 Foo | |
{ | |
public: | |
Foo& operator++(); | |
private: | |
void Bar() const { | |
} | |
}; | |
Foo& Foo::operator++() |
This file contains 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
var Game = function() {} | |
Game.prototype.start = function(secret) { | |
this.secret = secret; | |
return "Hello, Enter guess:"; | |
}; | |
Game.prototype.guess = function(guess) { | |
if(guess === this.secret) { | |
return "Correct!"; |
This file contains 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
var express = require("express"); | |
var server = express.createServer(); | |
server.get('/', function(req, res) { | |
console.log(req); | |
console.log(res); | |
res.send("hello express"); | |
}); | |
server.get('/users/:id', function(req, res) { |
This file contains 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
require.paths.unshift(__dirname + "/vendor"); | |
var http = require('http'), | |
sys = require('sys'), | |
nodeStatic = require('node-static/lib/node-static'); | |
var server = http.createServer(function(request, response) { | |
var file = new nodeStatic.Server('./public', { | |
cache: false | |
}); |
This file contains 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
var http = require('http'), | |
sys = require('sys'); | |
var server = http.createServer(function(request, response) { | |
request.addListener('end', function() { | |
response.writeHead(200, { | |
'Content-Type': 'text/plain' | |
}); | |
response.write(sys.inspect(request)); | |
response.end(); |
This file contains 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
# do this | |
(5..10).reduce(0) do |sum, value| | |
sum + value | |
end | |
# not this | |
sum = 0 | |
(5..10).each do |value| | |
sum += value | |
end |
This file contains 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
#include <iostream> | |
#include <cassert> | |
class FlyStyle | |
{ | |
public: | |
virtual void Fly() const = 0; | |
}; | |
class FlyHigh : public FlyStyle |