Skip to content

Instantly share code, notes, and snippets.

Sebastian Friedrich feldpost

Block or report user

Report or block feldpost

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@feldpost
feldpost / rails_server.sh
Created Nov 18, 2015
Starting Pow w/ Log
View rails_server.sh
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
}
View env.sample.js
module.exports = {
pivotal: {
TOKEN: 'TOKEN'
PID: 'PID',
},
sprintly: {
USER: "USER_EMAIL",
ID: 'PRODUCT_ID',
KEY: 'API_KEY'
},
View .bash_config
console () {
eilzug $*
rails_version=`bundle exec rails -v`
if [[ $rails_version == *2.3* ]]
then
./script/console --irb=pry
elif [[ $rails_version == *3.* ]]
then
View datasize.rake
# 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
View generate_rails_app.rb
#!/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
View epic snow leopard upgrade guide.txt
=== 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
View .kindle_export.rb
# 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
A custom RSpec Matcher for XML documents
View custom_matchers.rb
# 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>
View rack_honeypot.rb
# 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
View nginx.sh
#!/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
You can’t perform that action at this time.