Skip to content

Instantly share code, notes, and snippets.

View erkattak's full-sized avatar

Erik Straub erkattak

View GitHub Profile
@erkattak
erkattak / cash_transaction_spec.rb
Created October 22, 2012 14:50
BigDecimal Float comparison
require 'spec_helper'
describe CashTransaction do
context "when transaction is not a refund" do
subject { CashTransaction.new refund: false }
context "when an amount is positive" do
before(:each) do
subject.amount = 19.90
subject.save
end
@erkattak
erkattak / convert_to_utf8_unicode_ci.sql
Created August 28, 2012 15:08
Get all queries to convert base tables in a given database to specific character set and collation
SELECT
DISTINCT CONCAT(
'ALTER TABLE `',
`COLUMNS`.`TABLE_SCHEMA`,
'`.`',
`COLUMNS`.`TABLE_NAME`,
'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'
)
FROM
`information_schema`.`COLUMNS`
@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
{
"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,
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
@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;
}
@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 / 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. ##
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 / 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