Skip to content

Instantly share code, notes, and snippets.

View feldpost's full-sized avatar

Sebastian Friedrich feldpost

View GitHub Profile
@feldpost
feldpost / rails_server.sh
Created November 18, 2015 21:57
Starting Pow w/ Log
rails_server () {
cd /Library/WebServer/railsapps/$*;
touch tmp/restart.txt
# clear the screen
/usr/bin/open -a Terminal
/usr/bin/osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "k" using command down'
return 0
#See a log
tail -f -n 0 log/development.log
}
@feldpost
feldpost / env.sample.js
Last active August 29, 2015 14:10 — forked from obra/env.sample.js
module.exports = {
pivotal: {
TOKEN: 'TOKEN'
PID: 'PID',
},
sprintly: {
USER: "USER_EMAIL",
ID: 'PRODUCT_ID',
KEY: 'API_KEY'
},
@feldpost
feldpost / .bash_config
Created September 9, 2011 20:02
Rails Console
console () {
eilzug $*
rails_version=`bundle exec rails -v`
if [[ $rails_version == *2.3* ]]
then
./script/console --irb=pry
elif [[ $rails_version == *3.* ]]
then
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
#!/usr/bin/env ruby
# Written by Kieran P
# http://github.com/KieranP
# http://twitter.com/k776
# http://k776.tumblr.com
#
# Feel free to fork and modify.
# If you do, send me a message on
# Github details changes and I'll
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
@feldpost
feldpost / .kindle_export.rb
Created June 12, 2009 03:00
Print To Kindle
# PRINT TO KINDLE in Mac OSX (for Kindle DX)
#
# HUH?
# - Kindle file depository:
# - drag any supported Kindle file to a local folder
# - file will be automatically transfered whenever Kindle is connected
# - "Print To Kindle" Print menu option (PDF):
# - when Kindle is connected it will print as PDF straight to the Kindle (from anywhere)
# - when Kindle is not connected, it will print to the local folder and is transfered as soon as Kindle is connected
@feldpost
feldpost / custom_matchers.rb
Created May 16, 2009 01:12
A custom RSpec Matcher for XML documents
# Check if element exists:
# <tt>xml.should have_xml_element("account")<tt>
# Use REXML syntax to address nested elements:
# <tt>xml.should have_xml_element("account/name")<tt>
# Check if element has certain value:
# <tt>xml.should have_xml_element("account/name").with_value("foo")<tt>
# or:
# <tt>xml.should have_xml_element("account", :value => "foo")<tt>
# Check if element has certain attribute:
# <tt>xml.should have_xml_element("account").with_attribute("type")<tt>
# When a spammer wants to attack your site, they'll likely send an automated bot
# that will blindly fill out any forms it encounters. The idea of a "honeypot" is that
# you place a hidden field in a form. That's the honeypot. If this field is filled in, then
# it's almost certain to be a spammer (since a normal user wouldn't have even seen the
# field), and the contents of the form can safely be discarded.
# Normally, you would implement a "honeypot" in a Rails app with some combination of a
# special field in a particular form, and then some logic in the corresponding controller that
# would check for content in the "honeypot" field. This is somewhat of an inefficient
# approach, because it requires special code (not DRY), and bots are still going through an
#!/bin/sh
#This is a start script for nginx. Tested on Unbuntu Edge.
#Should work on Ubuntu, Debian and probably a few other Linux distros.
#Change DAEMON and CONFIG_FILE if neccessary
PATH=/sbin:/bin:/usr/sbin:/usr/bin
#Location of nginx binary. Change path as neccessary