Skip to content

Instantly share code, notes, and snippets.

View cchandler's full-sized avatar

Chris Chandler cchandler

View GitHub Profile
//Play with context
#define _XOPEN_SOURCE
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<ucontext.h>
@cchandler
cchandler / gist:326173
Last active September 4, 2015 12:55
my 100 things
Kitchen island
red vase
wallet
fleece beanie
Vibram five fingers (2x)
sneakers
santoni shoes
iPhone
belt
MissionWorkshop backpack
module CassandraAccess
def self.included(mod)
mod.class_eval do
def cassandra
@@cassandra ||= Cassandra.new(@@keyspace, @@host)
end
def self.cassandra
@@cassandra ||= Cassandra.new(@@keyspace, @@host)
end
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6vK1od2C01fFOH8ZCeio3jkL+0v4oM6MiumrXqLVUgre4O79rbxA2k2tjNv8XsAnYGxdYCfKWjlOg4OvXk+CMgmPiw+RjDdGSLw65XfGfDxQBqEMgB4O7ApodcT+RmrjmLsXvGK0TF8FWDD+x+I4scF2HsbnFGaU416kLYXvCGJkJZVxR9MJBHkIy6f3cM3b9OLkyZ89qQuPGawv3YPZ4/R4EvbvbgVCn9IBpCqKDe3LHhGS/HEMdSQ2Y+asX83R4SpFwlaFdFW5UJysUaBaaBkBiE85bKMwzAsd6NcmKcoFHIVYbayy/NOQobZhL9+4FdU0oRuu1ZuTG1pTZMxElw== [email protected]
@cchandler
cchandler / gist:603460
Created September 29, 2010 20:19
Basic Cassandra 0.7 examples
require 'cassandra/0.7'
client = Cassandra.new("Sample", "127.0.0.1:9160") # Sample is the Keyspace
# The client tries to discover all nodes the hard way. This will prevent timeouts
# from their IPs not being publicly available.
client.disable_node_auto_discovery!
### Inserting data
avg-cpu: %user %nice %system %iowait %steal %idle
0.75 0.00 4.00 0.00 0.00 95.25
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 9223372036854774.00 0.00 0.00 100.05
sda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0.00 0.00 100.05
sdb 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
dm-1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
@cchandler
cchandler / gist:753685
Created December 23, 2010 23:26
Correct opcode
4013c8: e8 eb f9 ff ff callq 400db8 <printf@plt>
4013cd: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%rbp)
4013d4: eb 45 jmp 40141b <main+0x2d7>
4013d6: 8b 45 ec mov -0x14(%rbp),%eax
4013d9: 48 98 cltq
4013db: 48 c1 e0 03 shl $0x3,%rax
4013df: 48 03 45 e0 add -0x20(%rbp),%rax
4013e3: 48 8b 00 mov (%rax),%rax
4013e6: 48 89 85 18 fe ff ff mov %rax,-0x1e8(%rbp)
4013ed: be 4b 1a 40 00 mov $0x401a4b,%esi
@cchandler
cchandler / gist:753686
Created December 23, 2010 23:27
Incorrect opcode
4015d5: e8 ce f9 ff ff callq 400fa8 <printf@plt>
4015da: 45 31 e4 xor %r12d,%r12d
4015dd: 45 85 ed test %r13d,%r13d
4015e0: 48 89 dd mov %rbx,%rbp
4015e3: 7e 32 jle 401617 <main+0x197>
4015e5: 48 8b 5d 00 mov 0x0(%rbp),%rbx <--- Line that segfaults because %rbp is empty
4015e9: be bf 1f 40 00 mov $0x401fbf,%esi
4015ee: bf 20 31 60 00 mov $0x603120,%edi
4015f3: e8 b0 fa ff ff callq 4010a8 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
4015f8: 48 89 c7 mov %rax,%rdi
histogram = {180=>0, 256=>0, 237=>1, 275=>0, 190=>1, 228=>0, 266=>0, 133=>1, 209=>0, 247=>1, 257=>1, 86=>0, 162=>1, 200=>1, 238=>1, 29=>1, 143=>1, 181=>0, 153=>0, 191=>1, 229=>0, 267=>0, 134=>1, 172=>1, 210=>1, 115=>1, 87=>1, 201=>1, 239=>1, 182=>0, 220=>1, 135=>1, 173=>1, 249=>1, 31=>0, 240=>0, 107=>0, 183=>1, 221=>1, 259=>1, 88=>0, 126=>1, 98=>0, 79=>1, 193=>1, 22=>0, 231=>0, 269=>0, 241=>0, 70=>0, 184=>1, 260=>1, 89=>0, 213=>1, 251=>0, 156=>1, 194=>0, 232=>1, 270=>0, 147=>1, 223=>0, 261=>1, 204=>0, 242=>0, 100=>0, 252=>0, 176=>0, 233=>1, 214=>0, 148=>0, 72=>0, 262=>1, 243=>0, 129=>1, 224=>0, 53=>0, 205=>0, 91=>0, 139=>1, 272=>1, 234=>0, 25=>1, 196=>0, 158=>0, 253=>0, 225=>1, 187=>1, 244=>0, 130=>1, 92=>1, 111=>0, 254=>1, 216=>0, 273=>1, 235=>0, 197=>1, 264=>0, 226=>0, 188=>0, 131=>0, 245=>0, 236=>1, 217=>1, 141=>0, 265=>0, 151=>0, 246=>0, 227=>0, 189=>0, 208=>0, 170=>1}
final_histogram = {}
histogram.sort(){|a,b| histogram[a[0]] <=> histogram[b[0]] }.map do |i|
final_histogram[i[0]] = i[1]
end
p final
@cchandler
cchandler / gist:939951
Created April 24, 2011 22:55
glpk model for cloud vs colo costs
#Colo Server costs
set ServerTypes;
set InstanceTypes;
param CoreDemand; #How many cores do we need for a workload
param OurMoney; #The maximum upper-bound of what we're willing to spend
param ColoCostPerU; #How much are we paying per U of colocation
param Months; # How many months do we know we need this hardware