Skip to content

Instantly share code, notes, and snippets.

View styx's full-sized avatar
🌴
¯\_(ツ)_/¯

Mikhail S. Pabalavets styx

🌴
¯\_(ツ)_/¯
View GitHub Profile
@styx
styx / active_record_introspection.rb
Created June 1, 2012 05:59 — forked from german/active_record_introspection.rb
adding introspection to all ActiveRecord methods (putting method's name when it's invoked)
module ActiveRecord
Base.singleton_methods.each do |m|
Base.class_eval <<-EOS
class << self
puts "redefining #{m}"
define_method "#{m}_with_introspection" do |*args|
puts "#{m}"
send(:"#{m}_without_introspection", *args)
end
@styx
styx / method_logger.rb
Created September 25, 2012 07:02 — forked from nhance/method_logger.rb
Rails compatible method logging. Use this to log all calls to instance methods of a class to the log.
Model.new.foo
require ENV_PATH
class String
# http://www.devarticles.com/c/a/Development-Cycles/Tame-the-Beast-by-Matching-Similar-Strings/3/
module Soundex
Codes = {
'b' => 1,
'f' => 1,
'p' => 1,
'v' => 1,
@styx
styx / gist:4193584
Created December 3, 2012 08:12
Gemfile.local
# Use `bundle --gemfile Gemfile.local` to activate
# Include global Gemfile
eval File.read('Gemfile')
# Gems for local host (same syntax as for Gemfile)
group :development do
gem 'hacker'
end
@styx
styx / gist:4227413
Created December 6, 2012 19:18
JS to delete files on amazon
jQuery('.rowBodyCollapsed').each(function(i, ele)
{
var asin = jQuery(ele).attr('asin');
Fion.deleteItem('deleteItem_' + asin);
});
@styx
styx / databases.rake
Created December 19, 2012 10:52 — forked from ak47/databases.rake
# #{Rails.root}/lib/tasks/databases.rake
=begin
Monkey Patch
activerecord-3.0.9/lib/active_record/railties/databases.rake
clears obstinate stale PG session to get parallel_tests working
also, PG user must be superuser to use these low level PG functions
=end
def drop_database(config)
case config['adapter']
when /mysql/
# #{Rails.root}/lib/tasks/databases.rake
=begin
Monkey Patch
activerecord-3.0.9/lib/active_record/railties/databases.rake
clears obstinate stale PG session to get parallel_tests working
also, PG user must be superuser to use these low level PG functions
=end
def drop_database(config)
case config['adapter']
when /mysql/
@styx
styx / production.rb
Last active December 17, 2015 17:39
Rails 3 -> Rails 4 upgrade. Assets compression.
AppName::Application.configure do
# ...
# Compress JavaScripts and CSS
# config.assets.compress = true <- remove the Rails 3 setting
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :sass
end
# bundler state
/.bundle
/vendor/bundle/
/vendor/ruby/
# minimal Rails specific artifacts
db/*.sqlite3
/log/*
/tmp/*
/**
* Angular needs to send the Rails CSRF token with each post request.
*
* Here we get the token from the meta tags (make sure <%= csrf_meta_tags %>
* is present in your layout.)
*/
angular.module('myapp',[]).
// configure our http requests to include the Rails CSRF token
config(["$httpProvider", function(p) {
var m = document.getElementsByTagName('meta');