Skip to content

Instantly share code, notes, and snippets.

View carld's full-sized avatar
🔜

Carl carld

🔜
View GitHub Profile
ftp = Net::FTP::new(site)
ftp.login(user, password)
y_combinator {|callback|
lambda {|entry|
if FileTest.directory?(entry)
entries = ftp.nlst
ftp.mkdir(File.basename(entry)) unless entries.include?(File.basename(entry))
ftp.chdir(File.basename(entry))
puts 'cd ' + File.basename(entry)
@carld
carld / gist:c17750c9eec4cb9215c0
Created June 4, 2015 06:33
sed regex to parse apache combined log
cat access.log | sed 's/^\([0-9\.]\+\) \([^ ]\+\) \([^ ]\+\) \[\(.*\)\] \("[^"]*"\) \([^ ]*\) \([^ ]*\) \("[^"]*"\) \("[^"]*"\).*/"\1"\t"\2"\t"\3"\t"\4"\t\5\t"\6"\t"\7"\t\8\t\9/'
@carld
carld / arch-linux-macbook-pro-5-5
Last active July 14, 2021 19:16
Arch Linux on Macbook Pro 5,5 notes
# Some notes on my Arch Linux install... not quite complete but something to go on
# I needed rEFInd?
# After booting from arch ISO image (from CD)
# Partition disk etc
fdisk /dev/sda
n # new partition
t # set type, 1 is EFI partition
# Install EFI bootloader
@carld
carld / .Xdefaults
Last active August 29, 2015 14:23
.Xdefaults
urxvt*inheritPixmap:true
urxvt*transparent:true
urxvt*shading:50
urxvt*font: 9x15
urxvt*font:xft:Terminus-12
urxvt*font:xft:Tamsyn-12
urxvt*loginShell: true
urxvt*vt100*geometry: 80x50
urxvt*saveLines: 2000
urxvt*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48
@carld
carld / ptr_stack.c
Last active August 29, 2015 14:24
pointers
void _pstack_init(void *stack) {
*(void **)stack = (char *)stack + sizeof (char *);
}
void _pstack_push(void *stack, void *data) {
*(void **)stack = (char *)*(void **)stack + sizeof (char *);
**(void ***)stack = data;
}
void _pstack_pop (void *stack) {
@carld
carld / .vimrc
Last active August 29, 2015 14:24
.vimrc
:filetype plugin on
set softtabstop=2
set shiftwidth=2
set tabstop=8
set expandtab
set autoindent
set lisp
set showmatch
set matchtime=5
set smartcase
-- reference Karwin
drop table closure;
drop table nodes;
create table nodes (
node serial primary key,
label varchar(32) not null
);
How to get a Rails console when script/rails won't work - particularly when you don't have readline
$ bundle exec script/console
Loading production environment (Rails 2.3.18)
/opt/rubyenterprise/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
from /opt/rubyenterprise/lib/ruby/1.8/irb/completion.rb:10
from /opt/rubyenterprise/lib/ruby/1.8/irb/init.rb:254:in `require'
from /opt/rubyenterprise/lib/ruby/1.8/irb/init.rb:254:in `load_modules'
from /opt/rubyenterprise/lib/ruby/1.8/irb/init.rb:252:in `each'
@carld
carld / multi-ssh.sh
Last active August 29, 2015 14:26
prompt for a command to run on multiple hosts via ssh
HOSTS=( host1 host2 )
USER=me
while read -e -p "-> " CMD </dev/tty
do
for host in "${HOSTS[@]}"; do
echo $host
ssh $USER@$host -C $CMD
done
done
@carld
carld / rack_show_session.rb
Last active September 13, 2021 05:17 — forked from thibautsacreste/rack_show_session.rb
Ruby: decode rack session cookie
require 'base64'
require 'cgi'
def show_session(cookie)
Marshal.load(Base64.decode64(CGI.unescape(cookie.split("\n").join).split('--').first))
end