Skip to content

Instantly share code, notes, and snippets.

View svarks's full-sized avatar

Sergey Varaksin svarks

View GitHub Profile
@svarks
svarks / gist:10689294
Created April 14, 2014 23:14
mysql largest tables
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
ORDER BY data_length + index_length DESC
LIMIT 10;
:email => user.email,
:name => user.decorate.full_name,
:created_at => user.created_at.to_i,
:last_impression_at => user.current_sign_in_at.to_i
:sign_in_count => user.sign_in_count,
:profile => user.decorate.active_admin_url,
:groups_count => user.groups.count,
:messages_count => user.messages_count,
:memberships_count => user.memberships.count,
def apply_filters!(hash_or_array)
case hash_or_array
when Array
for i in 0 ... hash_or_array.size do
apply_filters!(hash_or_array[i])
end
when Hash
hash_or_array.each do |key, value|
next if value.nil?
def destroy(async = true)
if async
AsyncMethod.perform_async(self.class.name, id, :destroy, false)
else
super
end
end
@svarks
svarks / 0_README.md
Last active December 13, 2015 23:29 — forked from nilcolor/0_README.md

ruby-1.9.3-p392 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p392 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@svarks
svarks / gist:2845631
Created May 31, 2012 19:28
Self signed SSL cert
# generate super secret private key
# (not really, this key and the certificate are "throwaway" items)
openssl genrsa -des3 -out server.key 1024
# generate the self-signed certificate
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt
# create decrypted version of key so that nginx can be started without a passphrase
openssl rsa -in server.key -out server.key.insecure
chmod 600 server.key.insecure