Skip to content

Instantly share code, notes, and snippets.

View erkattak's full-sized avatar

Erik Straub erkattak

View GitHub Profile
@erkattak
erkattak / syntax_highlighting.py
Created December 6, 2011 15:53 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@erkattak
erkattak / hash.rb
Created January 11, 2012 15:08
flattening a multidimensional hash
ALLOWED_TYPES = {
'pdf' => ['application/pdf', 'application/x-download'],
'image' => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif'],
'text' => ['application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
'spreadsheet' => ['application/excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
}
ALLOWED_TYPES.map{ |g,s| s }.flatten # => ["application/pdf", "application/x-download", "image/jpg", "image/jpeg", "image/pjpeg", "image/png", "image/x-png", "image/gif", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]
@erkattak
erkattak / gist.py
Created January 11, 2012 19:51
ggg
import fnmatch
import re
import threading
import datetime
import time
import shutil
import _strptime
import tempfile
def chosen_select (element_id, option_number)
page.execute_script("$('##{element_id}').next('.chzn-container').trigger('mousedown')")
page.execute_script("$('##{element_id}_chzn_o_#{option_number}').trigger('mouseover').trigger('mouseup')")
end
@erkattak
erkattak / config.log
Created February 24, 2012 02:23
rvm install 1.9.3-p0
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --prefix=/Users/erik/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml --with-opt-dir=/Users/erik/.rvm/usr
## --------- ##
## Platform. ##
@erkattak
erkattak / business.rb
Created February 29, 2012 01:28
validate presence of polymorphic object when accepting nested attributes?
class Business < ActiveRecord::Base
has_one :location, as: :locatable
accepts_nested_attributes_for :location, allow_destroy: true, reject_if: -> (attributes) { attributes['address'].blank? }
end
@erkattak
erkattak / rails-pry.zsh
Created March 6, 2012 02:38
Rails Pry zsh plugin
# replaces irb in the rails console with pry
# instead of 'rails c', start the console with 'rails pry'
rails(){
if [[ $@ == "pry" ]]; then
command pry -r ./config/environment;
else
command rails "$@";
fi;
}
passenger@rails:/var/www/html/ems.domain.com/current$ redis-server
[13937] 21 Jun 13:38:02 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
[13937] 21 Jun 13:38:02 * Server started, Redis version 2.4.11
[13937] 21 Jun 13:38:02 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[13937] 21 Jun 13:38:04 * DB loaded from disk: 2 seconds
[13937] 21 Jun 13:38:04 * The server is now ready to accept connections on port 6379
[13937] 21 Jun 13:38:05 - DB 0: 21 keys (0 volatile) in 48 slots HT.
[13937] 21 Jun 13:38:05 - 0 clients connected (0 slaves), 42474312 bytes in use
[13937] 21 Jun 13:38:10 - DB 0: 21 keys (0 volatile) in 32 slots HT.
[13937] 21 Jun 13:38:10 - 0 clients connected (0 slaves), 42474312 bytes in use
{
"color_scheme": "Packages/User/Gowalla.tmTheme",
"font_face": "Inconsolata-g",
"font_options":
[
"subpixel_antialias"
],
"font_size": 14.0,
"highlight_line": true,
"highlight_modified_tabs": true,
@erkattak
erkattak / hamlhtml5boilerplate.html.haml
Created August 9, 2012 18:23
My haml version of the html 5 boiler plate code
!!! 5
/[if lt IE 7] <html lang="en" class="no-js ie6">
/[if IE 7 ] <html lang="en" class="no-js ie7">
/[if IE 8 ] <html lang="en" class="no-js ie8">
/[if IE 9 ] <html lang="en" class="no-js ie9">
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
%head
%meta{:charset => "utf-8"}/
/
Always force latest IE rendering engine (even in intranet) &amp; Chrome Frame