Skip to content

Instantly share code, notes, and snippets.

View tokenvolt's full-sized avatar

Alex Khrustalev tokenvolt

View GitHub Profile
@tokenvolt
tokenvolt / gist:8850823
Created February 6, 2014 19:20
Sidekiq logger
Sidekiq.logger.formatter = proc do |severity, timestamp, context, message|
case severity
when 'INFO'
severity = severity.green
when 'ERROR'
severity = severity.red
else 'WARN'
severity = severity.yellow
end
// backup
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
// restore
mysql -u root -p[root_password] [database_name] < dumpfilename.sql
var data;
data = {
user: {
email_address: "joe@bloggs.com",
provider: "linkedin",
uid: "1234567",
info: {
nickname: "jbloggs",
name: "Joe Bloggs",
@tokenvolt
tokenvolt / postgres_drop_connections
Created July 16, 2014 15:23
Drop postgres connections for specific DB
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'TARGET_DB' AND pid <> pg_backend_pid();
class InterestingBehaviour
def perform
if var1.blank?
var1 = 56
end
pp var1 # prints nil
end
function globalpath(){
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}
@tokenvolt
tokenvolt / ram-monitor
Created March 9, 2015 13:24
Very simple script to monitor RAM usage on linux machine
#!/bin/sh
# 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: ./ram-monitor.sh >> logfile &
@tokenvolt
tokenvolt / remove-trailing-spaces.sh
Created March 31, 2015 13:22
Remove trailing spaces from files
find . -name "*.haml" | xargs sed -i 's/[ \t]*$//'
@tokenvolt
tokenvolt / version-checker.sh
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
tokenvolt / webpack.rake
Created May 11, 2015 13:18
Webpack rake tasks
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/')
FileUtils.mkdir_p(images_link)
FileUtils.mkdir_p(fonts_link)