Skip to content

Instantly share code, notes, and snippets.

Avatar

David Strauß stravid

View GitHub Profile
@hoffmanc
hoffmanc / en.yml
Last active Dec 20, 2015
Hand rolled ICS support
View en.yml
# locales/en.yml
en:
time:
formats:
ical: "%Y%m%dT%H%M%SZ"
@maxhoffmann
maxhoffmann / gist:7373563
Last active Dec 27, 2015
run local php server and open browser
View gist:7373563
# local PHP Server
server() {
url="localhost:${2:-8000}"
if [ -z "$1" ]; then
php -S $url & # run server in background
else
php -S $url -t $1 &
fi
sleep 0.3s # wait for server to start
View gist:7463148
div.description a.autolink
{
display: inline-block;
max-width: 250px;
text-overflow: ellipsis;
overflow: hidden;
}
@markbates
markbates / config.ru
Created Aug 31, 2011
Sprockets with a simple Rack app
View config.ru
require 'sprockets'
project_root = File.expand_path(File.dirname(__FILE__))
assets = Sprockets::Environment.new(project_root) do |env|
env.logger = Logger.new(STDOUT)
end
assets.append_path(File.join(project_root, 'app', 'assets'))
assets.append_path(File.join(project_root, 'app', 'assets', 'javascripts'))
assets.append_path(File.join(project_root, 'app', 'assets', 'stylesheets'))
View group_by_levenshtein.rb
emails = Customer.select(:email).map(&:email)
emails.map do |email|
grouping = emails
.group_by{|em| Levenshtein.distance(email, em) }
.select {|k,v| k < 5 && != 0 } # ignore exact matches and ones far off
if !grouping.empty?
[email, grouping]
end
@searls
searls / app.css
Created May 18, 2014
Handy trick for debugging to see which parts of your app are being re-rendering in the DOM (without keeping your eyes glued to web inspector)
View app.css
body * {
-webkit-animation: fade-in 2s ease-out;
animation: fade-in 2s ease-out;
}
@madrobby
madrobby / i18n.coffee
Created Nov 14, 2011
Backbone i18n with CoffeeScript
View i18n.coffee
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
@reyjrar
reyjrar / New-iTerm-Window.scpt
Created Feb 8, 2012
AppleScript to Open a New iTerm Window and bring it to the front
View New-iTerm-Window.scpt
(*
* New-iTerm-Window.scpt
*
* Intended for use with QuickSilver
* I mapped option-y to running this script to create
* a new iTerm window on the current workspace
*
* Based on much Googling - very little "original" code here
* Comments/Suggestions to brad.lhotsky@gmail.com
*)
@runemadsen
runemadsen / app.rb
Created Oct 17, 2012
Sinatra File Upload
View app.rb
require 'sinatra'
get "/" do
erb :form
end
post '/save_image' do
@filename = params[:file][:filename]
file = params[:file][:tempfile]
@jeffreyiacono
jeffreyiacono / Rakefile
Created Feb 8, 2012
rake task for precompiling assets using sprockets within a sinatra app + view helpers
View Rakefile
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
You can’t perform that action at this time.