Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
¯\_(ツ)_/¯

Mikhail S. Pabalavets styx

🌴
¯\_(ツ)_/¯
View GitHub Profile
@styx
styx / active_record_introspection.rb
Created Jun 1, 2012 — forked from german/active_record_introspection.rb
adding introspection to all ActiveRecord methods (putting method's name when it's invoked)
View active_record_introspection.rb
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 Sep 25, 2012 — 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.
View find_bad_queries.rb
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,
View gist:4193584
# 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 Dec 6, 2012
JS to delete files on amazon
View gist:4227413
jQuery('.rowBodyCollapsed').each(function(i, ele)
{
var asin = jQuery(ele).attr('asin');
Fion.deleteItem('deleteItem_' + asin);
});
View 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/
View 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/
@styx
styx / production.rb
Last active Dec 17, 2015
Rails 3 -> Rails 4 upgrade. Assets compression.
View production.rb
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
View .gitignore
# bundler state
/.bundle
/vendor/bundle/
/vendor/ruby/
# minimal Rails specific artifacts
db/*.sqlite3
/log/*
/tmp/*
View app.js
/**
* 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');