Skip to content

Instantly share code, notes, and snippets.

View amezhenin's full-sized avatar

Artem Mezhenin amezhenin

View GitHub Profile
###
Module dependencies
###
require.paths.unshift "#{__dirname}/lib/support/express-csrf/"
require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/"
express = require 'express'
app = module.exports = express.createServer()
RedisStore = require 'connect-redis'
@amezhenin
amezhenin / right_buttons_1304
Created December 26, 2013 12:26
Move control buttons to the right in Ubuntu 13.04(old school)
gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close'
@amezhenin
amezhenin / tunnel_mysql.sh
Created December 26, 2013 12:24
ssh tunnel to you remote server(MySQL server in this case)
ssh -L 3308:127.0.0.1:3306 <remote_host>
# connect:
# mysql -h 127.0.0.1 -u root --port 3308
@amezhenin
amezhenin / profile.js
Created December 26, 2013 11:37
This script simplify some profiling tasks in MongoDB. Import it on startup: $ mongo [db_name] --shell profile.js Usage: > profile_hist() > profile_ns() > profile_op() Links to original posts in my blog about profiling in MongoDB [1](http://amezhenin.ru/mongodb/mongodb-profiling-part-1.html) and [2](http://amezhenin.ru/mongodb/mongodb-profiling-p…
function profile_hist(){
res = db.system.profile.aggregate([{$project: {'ms':{'$subtract':['$millis',{$mod:['$millis', 50]}]}}}, {$group:{_id:'$ms', sum:{$sum:1}}}, {$sort:{_id:1}}]);
res['result'].forEach(function(i) { print(i['_id'], '\t',i['sum']); });
}
function profile_ns(){
res = db.system.profile.aggregate([{$group:{_id:'$ns', count:{$sum:1}, avg_ms:{$avg:'$millis'}, min_ms:{$min:'$millis'}, max_ms:{$max:'$millis'}}}])
print('ns min_ms max_ms avg_ms count total_ms')
@amezhenin
amezhenin / simple_plot.ipynb
Last active January 1, 2016 06:28
ipython notebook test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite backup.sql | sqlite3 database.sqlite