Skip to content

Instantly share code, notes, and snippets.

View tokenvolt's full-sized avatar

Alex Khrustalev tokenvolt

View GitHub Profile
tokenvolt / gist:8850823
Created February 6, 2014 19:20
Sidekiq logger
View gist:8850823
Sidekiq.logger.formatter = proc do |severity, timestamp, context, message|
case severity
when 'INFO'
severity =
when 'ERROR'
severity =
else 'WARN'
severity = severity.yellow
View mysqldump
// backup
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
// restore
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
View request.js
var data;
data = {
user: {
email_address: "",
provider: "linkedin",
uid: "1234567",
info: {
nickname: "jbloggs",
name: "Joe Bloggs",
tokenvolt / postgres_drop_connections
Created July 16, 2014 15:23
Drop postgres connections for specific DB
View postgres_drop_connections
SELECT pg_terminate_backend( FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND pid <> pg_backend_pid();
View interesting_behaviour.rb
class InterestingBehaviour
def perform
if var1.blank?
var1 = 56
pp var1 # prints nil
function globalpath(){
printf "%s\n" $PATH
tokenvolt / ram-monitor
Created March 9, 2015 13:24
Very simple script to monitor RAM usage on linux machine
View ram-monitor
# Using /bin/sh which is guaranteed to be present on any posix system.
# If you want to add shell specific parts in the script than replace this.
# E.g. if you want to use bash specific stuff then change it to:
# #!/usr/bin/env bash
# Make sure that the shebang is on the first line of the script (no comments above it!)
# While true, pause 5 seconds, then append information to Mylogfile
# Usage: ./ >> logfile &
tokenvolt /
Created March 31, 2015 13:22
Remove trailing spaces from files
find . -name "*.haml" | xargs sed -i 's/[ \t]*$//'
tokenvolt /
Last active August 29, 2015 14:18
Different commands to check versions
# Check Ubuntu version
lsb_release -a
# Check version of the kernel
uname -r
# MongoDB version
mongod --version
# PostgreSQL version
tokenvolt / webpack.rake
Created May 11, 2015 13:18
Webpack rake tasks
View webpack.rake
namespace :webpack do
desc 'create symlinks for images and fonts'
task symlink: :environment do
images_target = Rails.root.join('app', 'assets', 'images/')
fonts_target = Rails.root.join('app', 'assets', 'fonts/')
images_link = Rails.root.join('client', 'assets', 'images/')
fonts_link = Rails.root.join('client', 'assets', 'fonts/')