Skip to content

Instantly share code, notes, and snippets.

View localredhead's full-sized avatar

Levi Strope localredhead

View GitHub Profile
@localredhead
localredhead / scratch
Created November 17, 2012 01:10
custom preferences
Android applications can maintain their own internal preferences (and allow them to be modified by users) with very little coding. In fact, you don't even need to write an code to explicitly save these preferences, it's all handled automatically!
Create a new Android project, with an intial activity title Main.
Create two more activities:
ShowPrefs, which extends Activity
Set Prefs, which extends PreferenceActivity
Add these two to your AndroidManifest.xml file:
@localredhead
localredhead / gist:4063686
Created November 13, 2012 03:00
check disk usage for large files to be deleted
du -h / | grep ^[0-9.]*G
@localredhead
localredhead / emacs.el
Created October 11, 2012 20:44
emacs config WIP. Combo Emacs Start Kit + Emacs Kicker
;; emacs kicker --- kick start emacs setup
;; Copyright (C) 2010 Dimitri Fontaine
;;
;; Author: Dimitri Fontaine <dim@tapoueh.org>
;; URL: https://github.com/dimitri/emacs-kicker
;; Created: 2011-04-15
;; Keywords: emacs setup el-get kick-start starter-kit
;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
;;
;; This file is NOT part of GNU Emacs.
@localredhead
localredhead / tz_from_dst_using_offset
Created September 27, 2012 00:23
Adjust for DST when finding timezone using UTC_OFFSET
#where OFFSET is seconds
ActiveSupport::TimeZone.all.find { |z| ((z.now.dst? && z.utc_offset == OFFSET-3600) || (!z.now.dst? && z.utc_offset == OFFSET))}
@localredhead
localredhead / gist:3616381
Created September 4, 2012 03:59
Uninstall all local gems (not in a gemset)
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@localredhead
localredhead / gist:3616303
Created September 4, 2012 03:42 — forked from Irio/gist:1496746
Solution for "cannot load such file -- openssl" on RVM
When I tried run "rake test", I received:
rake aborted!
cannot load such file -- openssl
Tasks: TOP => test:units => test:prepare => db:test:prepare => db:abort_if_pending_migrations => environment
(See full trace by running task with --trace)
@localredhead
localredhead / gist:3120881
Created July 16, 2012 05:42 — forked from kwdowicz/gist:1435813
Forward any requestes to port 80 to port 3000 (Mac OSX)
sudo ipfw add 1 forward 127.0.0.1,3000 ip from any to any 80 in
@localredhead
localredhead / omniauth.rb
Created July 5, 2012 17:57 — forked from dira/omniauth.rb
OmniAuth strategy for a custom provider
# config/initializers/omniauth.rb
module OmniAuth
module Strategies
# tell OmniAuth to load our strategy
autoload :Pixelation, 'lib/pixelation_strategy'
end
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, "app_name", "secret"
@localredhead
localredhead / rails31init.md
Created May 31, 2012 21:55 — forked from docwhat/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

(defun ruby-generate-tags()
(interactive)
(let ((root (ffip-project-root)))
(let ((my-tags-file (concat root "TAGS")))
(message "Regenerating TAGS file: %s" my-tags-file)
(if (file-exists-p my-tags-file)
(delete-file my-tags-file))
(shell-command
(format "find %s -iname '*.rb' | grep -v db | xargs ctags -a -e -f %s"
root my-tags-file))