Skip to content

Instantly share code, notes, and snippets.

View tokenvolt's full-sized avatar

Alex Khrustalev tokenvolt

View GitHub Profile
contextTypes:
router: React.PropTypes.func
tree: React.PropTypes.func
componentDidMount: ->
# TODO: set initial currentPath on page load
CurrentPathCursor = @props.tree.select('currentPath')
CurrentPathCursor.on 'update', (e) =>
@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)
@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 / 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 / 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 / sidekiq_colorful_logger.rb
Created September 18, 2014 12:07
Sidekiq Colorful Logger Formatter
Sidekiq.logger.formatter = proc do |severity, time, context, message|
colorized_time = "#{time.utc.iso8601}".colorize(:cyan)
case severity
when 'INFO'
colorized_severity = "#{severity}:".colorize(:green)
"#{colorized_time} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{context} #{colorized_severity} #{message}\n"
when 'ERROR'
colorized_severity = "#{severity}:".colorize(:red)
"#{colorized_time} #{Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{context} #{colorized_severity} #{message}\n"
{acl, admin, {user, "adminname", "yyyy.ru"}}.
{hosts, ["yyyy.ru"]}.
{loglevel, 4}.
{listen,
[
{5222, ejabberd_c2s, [
{access, c2s},
{shaper, c2s_shaper},
{max_stanza_size, 65536},
function globalpath(){
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}
class InterestingBehaviour
def perform
if var1.blank?
var1 = 56
end
pp var1 # prints nil
end
@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();