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 Account < ActiveRecord::Base | |
has_many :users | |
has_many :companies | |
accepts_nested_attributes_for :users | |
accepts_nested_attributes_for :companies | |
validates_presence_of :name | |
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
class Account | |
has_many :users | |
has_many :offices | |
end | |
class Office | |
belongs_to :account | |
has_many :users | |
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
fixed |
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
#include <stdio.h> | |
#define WRAP 10 | |
int main(void) | |
{ | |
char buf[WRAP]; | |
int bufpos = 0; | |
int linepos = 0; | |
int beg=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
net = require('net'); | |
people = []; | |
s = net.createServer(function (socket) { | |
people.push(socket); | |
socket.on("data", function(data) { | |
for (var i = 0; i < people.length; i++) { |
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
while (acc < UINT_MAX / 16) { | |
if ( s[i] >= '0' && s[i] <= '9' ) { | |
acc *= 16; | |
acc += s[i] - '0'; | |
} else if (s[i] >= 'A' && s[i] <= 'F') { | |
acc *= 16; | |
acc += s[i] - 'A' + 10; | |
} else if (s[i] >= 'a' && s[i] <= 'f') { | |
acc *= 16; | |
acc += s[i] - 'a' + 10; |
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
Stolen from ry | |
sudo sysctl -w net.inet.ip.portrange.first=12000 | |
sudo sysctl -w net.inet.tcp.msl=1000 | |
sudo sysctl -w kern.maxfiles=1000000 kern.maxfilesperproc=1000000 |
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
Crystal's | |
traceroute to google.com (74.125.91.103), 64 hops max, 40 byte packets | |
1 192.168.5.1 (192.168.5.1) 2.058 ms 0.580 ms 0.540 ms <- your 'router/box' | |
2 67-223-202-254.townes.net (67.223.202.254) 98.444 ms 268.135 ms 147.804 ms <-- your ISP | |
3 67-223-202-249.townes.net (67.223.202.249) 596.398 ms 167.816 ms 191.609 ms <-- OUCH | |
4 serial1-2-0.gw10.stl3.alter.net (157.130.164.137) 668.083 ms 391.727 ms * <-- ouch | |
5 0.ge-2-0-0.xt3.stl3.alter.net (152.63.88.106) 319.354 ms 120.151 ms 523.547 ms | |
6 0.xe-4-0-3.xl3.chi13.alter.net (152.63.64.118) 372.671 ms 463.899 ms 235.596 ms | |
7 tengige0-6-4-0.gw2.chi13.alter.net (152.63.66.114) 755.693 ms |
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
var mongoose = require('mongoose'), | |
Schema = mongoose.Schema; | |
mongoose.connect('mongodb://localhost/lol', function(err) { | |
if (err) { console.log(err) } | |
}); | |
var ChatSchema = new Schema({ | |
name: String | |
}); |
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
Postgres 9 with node-postgres and console.log | |
node data_init2.js 6.74s user 1.94s system 37% cpu 23.000 total | |
Mongo 1.8 with mongoose/native | |
node data_init.js 23.20s user 0.68s system 92% cpu 25.936 total | |
Mongo 1.8 with mongoose/native AND --journal | |
node data_init.js 30.87s user 1.25s system 93% cpu 34.254 total |
OlderNewer