Skip to content

Instantly share code, notes, and snippets.

@csexton
csexton / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@csexton
csexton / foo.rb
Created March 8, 2013 18:22 — forked from forforf/foo.rb
class Foo
def a_string
"abcdef8"
end
end
#!/usr/bin/env ruby
require 'pty'
interface = 'en0'
cmd = %W[tshark -i #{interface} -R http -T fields -e wlan.sa -e http.user_agent]
cmd = "yes"
begin
PTY.spawn( cmd ) do |r, w, pid|
@csexton
csexton / Compiling
Created December 19, 2012 18:54 — forked from cupakromer/Compiling
Compile with `gcc -Wall -lssl -lcrypto shait.c`
@csexton
csexton / Compiling
Created December 19, 2012 18:53 — forked from cupakromer/Compiling
Compile with `gcc -Wall -lssl -lcrypto shait.c`
@csexton
csexton / chef_solo_bootstrap.sh
Created September 17, 2012 02:49 — forked from charlotte-miller/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y upgrade
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
@csexton
csexton / kapow.zsh
Created June 10, 2011 21:05
Zsh function to restart an app running under pow
# Restart a rack app running under pow
# http://pow.cx/
#
# Adds a kapow command that will restart an app
#
# $ kapow myapp
#
# Supports command completion.
#
# If you are not already using completion you might need to enable it with
class Person
attr_accessor :name, :weight
#want to set a default for @weight in here
#Tried @weight ||= 45 and
# @weight = 45 and
# self.weight = 45
def initialize
@weight = 45
end
end
def update
params[:server][:network_interfaces].collect!{|x| NetworkInterface.new(x)}
@server = Server.find(params[:id])
respond_to do |format|
if @server.update_attributes(params[:server])
flash[:notice] = 'Server was successfully updated.'
format.html { redirect_to(@server) }
format.xml { head :ok }
else
@csexton
csexton / menu.mm
Created December 17, 2009 15:52 — forked from atr000/menu.mm
- (void)installButtonBeforeItem:(NSString *)beforeItem toToolbar:(NSString *)toolbarIdentifier
{
log_enter();
NSToolbar *toolbar = nil;
for (NSWindow *window in [NSApp orderedWindows]) {
if (NO == [[[window toolbar] identifier] isEqualToString:toolbarIdentifier]) continue;
toolbar = [window toolbar];
if ([toolbar respondsToSelector:@selector(onepasswordSetDelegate:)]) {
[toolbar setDelegate:[toolbar delegate]]; // this will call a swizzled method