Skip to content

Instantly share code, notes, and snippets.

Thorsten Böttger alto

Block or report user

Report or block alto

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
@alto
alto / ash_ffffind.py
Last active Apr 13, 2017 — forked from ashildebrandt/ash_ffffind.py
Ffffind (downloads every image from a given FFFFOUND! account)
View ash_ffffind.py
"""
ash_ffffind.py
v1.1 (September 14, 2015)
by me@aaronhildebrandt.com
Automatically downloads all images from ffffound saved by a specific user.
Will first try to download the image from the original source (to get the highest quality possible).
If that fails, it'll download the cached version from ffffound.
View fixtures_test.rb
require 'test_helper'
class FixturesTest < ActiveSupport::TestCase
def test_fixtures_for_validity
fixture_tables = all_fixture_tables
assert_not_equal 0, fixture_tables.size, "Unable to find any fixtures in #{fixture_files_path}"
fixture_tables.each do |table_name|
ActiveRecord::Fixtures.all_loaded_fixtures[table_name].each do |f|
fixture_name = f[0]
@alto
alto / job.rb
Created Oct 3, 2012
Adding to_s to classes
View job.rb
class Job
def initialize(items_to_process)
@items = items_to_process
@timestamp = Time.now
# start_processing in the background...
end
def to_s
if finished?
"All work is done, all #{@items.size} items are processed."
View my_helper_test.rb
require 'test_helper'
class MyHelperTest < ActionView::TestCase
test "title" do
assert_select_in '<h1>My Awesome App</h1>', 'h1'
end
test "nav" do
html = '<div id="nav"><a href="/">Home</a></div>'
assert_select_in html, 'div' do
@alto
alto / bigdecimal
Created Jun 28, 2012
Now with using BigDecimal for more precision we really have nice numbers with more than 1 million digits.
View bigdecimal
This file has been truncated, but you can view the full file.
@alto
alto / Default (OSX).sublime-keymap
Created Jun 27, 2012
My Keymapping and Preferences for Sublime Text 2
View Default (OSX).sublime-keymap
[
{ "keys": ["ctrl+shift+b"], "command": "git_blame" },
{ "keys": ["ctrl+w"], "command": "find_under_expand" },
{ "keys": ["super+ctrl+r"], "command": "reveal_in_side_bar" },
{ "keys": ["super+ctrl+w"], "command": "close_all" },
{ "keys": ["super+shift+t"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
{ "keys": ["ctrl+shift+d"], "command": "duplicate_line" },
{ "keys": ["ctrl+l"], "command": "insert", "args": {"characters": " => "} },
{ "keys": ["super+shift+l"], "command": "expand_selection", "args": {"to": "line"} },
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
@alto
alto / gist:2823468
Created May 29, 2012 — forked from jacqui/gist:983051
Redis SORT command examples
View gist:2823468
# Optimized for writes, sort on read
# LVC
redis.hset("bonds|1", "bid_price", 96.01)
redis.hset("bonds|1", "ask_price", 97.53)
redis.hset("bonds|2", "bid_price", 95.50)
redis.hset("bonds|2", "ask_price", 98.25)
redis.sadd("bond_ids", 1)
redis.sadd("bond_ids", 2)
View gist:2575111
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@alto
alto / hack.sh
Created Apr 1, 2012 — forked from erikh/hack.sh
OSX For Hackers
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@alto
alto / calculate_until_saved.rb
Created Mar 11, 2012
Calculate a certain attribute only until the (active) record has been saved to the database.
View calculate_until_saved.rb
module CalculateUntilSaved
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def calculate_until_saved(attribute_name)
attr_protected attribute_name
You can’t perform that action at this time.