Skip to content

Instantly share code, notes, and snippets.

View pfleidi's full-sized avatar

Sven Pfleiderer pfleidi

View GitHub Profile
@pfleidi
pfleidi / wordpressdotcom.rb
Created March 31, 2012 11:57
Slightly modified version of stock wordpress -> jekyll importer
# coding: utf-8
require 'rubygems'
require 'hpricot'
require 'fileutils'
require 'yaml'
require 'time'
module Jekyll
# This importer takes a wordpress.xml file, which can be exported from your
@pfleidi
pfleidi / wc.rb
Created April 3, 2012 17:07
Stupid implementation of the unix tool wc in Ruby
#!/usr/bin/env ruby
require 'optparse'
options = {}
# parse commandline options
OptionParser.new do |opts|
opts.banner = "Usage: #{__FILE__} [-lmw] [file]"
Operating system: Mac OS X
10.8.2 12C60
CPU: x86
GenuineIntel family 6 model 37 stepping 5
4 CPUs
Crash reason: EXC_BAD_ACCESS / KERN_PROTECTION_FAILURE
Crash address: 0x58
Thread 0 (crashed)
Operating system: Linux
0.0.0 Linux 2.6.32-350-ec2 #57-Ubuntu SMP Thu Nov 15 15:59:03 UTC 2012 x86_64
CPU: amd64
family 6 model 26 stepping 5
2 CPUs
Crash reason: SIGSEGV
Crash address: 0x0
Thread 0 (crashed)
after 'deploy:stop', 'puma:stop'
after 'deploy:start', 'puma:start'
after 'deploy:restart', 'puma:restart'
_cset(:puma_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec puma" }
_cset(:pumactl_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec pumactl" }
_cset(:puma_state) { "#{shared_path}/sockets/puma.state" }
_cset(:puma_role) { :app }
namespace :puma do
@pfleidi
pfleidi / Guardfile
Created June 27, 2013 12:59
Using rubber, Guard and pdflatex to build my thesis
# encoding: utf-8
require 'guard/guard'
module ::Guard
class Thesis < ::Guard::Guard
def run_all
end
def run_on_changes(paths)

Relation Management

One to One

Constraints

  • Model1 explicitly belongs_to_one Model2 (via the model2 attribute)
  • Model2 implicitly has_one Model1

Model1 Example

# Instead of globally disabling ignoring hidden elements like this
Capybara.configure do |config|
config.ignore_hidden_elements = false
end
# You can choose to selectively disable it on a per-call basis
Capybara.select 'Foo', :from => 'Bar Selection', :visible => :all
Capybara.find :css, 'select#my_id', :visible => :all

Keybase proof

I hereby claim:

  • I am pfleidi on github.
  • I am pfleidi (https://keybase.io/pfleidi) on keybase.
  • I have a public key whose fingerprint is 0187 FDE8 A967 B739 EE2B B857 48CB 26A0 5711 CE93

To claim this, I am signing this object:

@pfleidi
pfleidi / pre-push
Last active August 29, 2015 14:03
Automatically make an animated GIF of yourself and upload it to a specified slack channel.
#!/bin/sh
FILE_PATH="$(ls ~/.lolcommits/${PWD##*/}/$(git rev-parse HEAD | cut -c1-11).*)"
if [ "$?" -ne "0" ] || [ ! -f $FILE_PATH ]; then
lolcommits --capture --animate=1 --delay=4
fi
FILE_PATH="$(ls ~/.lolcommits/${PWD##*/}/$(git rev-parse HEAD | cut -c1-11).*)"
GITHUB_REPO="$(git remote -v | grep origin | head -1 | sed 's/.*git@github\.com:\(.*\/.*\)\.git.*/\1/')"