Skip to content

Instantly share code, notes, and snippets.

View amalkov's full-sized avatar

Alex Malkov amalkov

View GitHub Profile
@amalkov
amalkov / gist:1322010
Created October 28, 2011 10:03
Triggers
DELIMITER $$
DROP TRIGGER IF EXISTS hotel_au_trg$$
CREATE TRIGGER hotel_au_trg AFTER UPDATE ON hotels
FOR EACH ROW
BEGIN
IF (OLD.name != NEW.name OR (OLD.name IS NULL AND NEW.name IS NOT NULL)) THEN
REPLACE INTO audits values ('',NEW.id,'name',NOW(),NULL,NULL);
END IF;
IF (OLD.latitude != NEW.latitude OR (OLD.latitude IS NULL AND NEW.latitude IS NOT NULL)) THEN
REPLACE INTO audits values ('',NEW.id,'latitude',NOW(),NULL,NULL);
@amalkov
amalkov / hack.sh
Created April 17, 2012 09:35
OSX For Hackers
#!/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
#
@amalkov
amalkov / shoulda_cheatsheet.rb
Created February 25, 2013 23:47
Shoulda activemodel cheatsheet
# Shoulda activemodel cheatsheet
# DB
should have_db_column(:title).of_type(:string).with_options(default: 'Untitled', null: false)
should have_db_index(:email).unique(:true)
# Associations
should belong_to :company
should have_one(:profile).dependent(:destroy)
should have_many(:posts).dependent(:nullify)

rspec-cheatsheet

INSTALL

$ gem install rspec

RSPEC-RAILS

INSTALL

INSTALL cucumber & webrat (rspec rspec-rails)

$ [sudo] gem install rspec rspec-rails cucumber webrat

Starting from Cucumber 0.4.5 you will need the cucumber-rails gem

INSTALL DEPENDENCIES

INSTALL

INSTALL cucumber & webrat (rspec rspec-rails)

$ [sudo] gem install rspec rspec-rails cucumber webrat

Starting from Cucumber 0.4.5 you will need the cucumber-rails gem

INSTALL DEPENDENCIES

@amalkov
amalkov / foo.rb
Created February 26, 2013 08:18
bar
foo
@amalkov
amalkov / test
Created March 13, 2013 23:56
test
test
var EmailCatcher = (function($) {
// Initialiser function
var EmailCactcher = function(element) {
// Cache elements here that you will be accessing later in the class
this.$el = $(element);
this.$form = $('form', element);
this.$span = $('span', element);
// Do all your event binding for the future here too,
var EmailCatcher = (function($) {
// Initialiser function
var EmailCactcher = function(element) {
// Cache elements here that you will be accessing later in the class
this.$el = $(element);
this.$form = $('form', element);
this.$span = $('span', element);
// Do all your event binding for the future here too,