Skip to content

Instantly share code, notes, and snippets.

View gmiroshnykov's full-sized avatar

George Miroshnykov gmiroshnykov

  • Dojo
View GitHub Profile

Keybase proof

I hereby claim:

  • I am gmiroshnykov on github.
  • I am laggyluke (https://keybase.io/laggyluke) on keybase.
  • I have a public key whose fingerprint is 2927 2BD0 71E1 C13A 5E33 7C09 1B89 334A B81F 3D5C

To claim this, I am signing this object:

r.tableCreate('senders');
r.tableCreate('receivers');
r.tableCreate('messages');
r.table('senders').insert({id: 1, sender: 'Sender One'});
r.table('receivers').insert({id: 1, receiver: 'Receiver One'});
r.table('messages').insert([{
senderId: 1,
receiverId: 1,
msg: 'Message One'
@gmiroshnykov
gmiroshnykov / fabfile.py
Last active December 29, 2015 11:08
fab create_user
from fabric.api import *
# Usage: fab -H <hostname> -u <ssh_username> create_user:<username>
def create_user(username):
run('adduser --disabled-password --gecos "" {0}'.format(username))
run('echo "{0} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/{0}'.format(username))
run('chmod 0440 /etc/sudoers.d/{0}'.format(username))
run('mkdir -p /home/{0}/.ssh'.format(username))
run('chmod 0755 /home/{0}/.ssh'.format(username))
run('chown {0}:{0} /home/{0}/.ssh'.format(username))
INFO global: Vagrant version: 1.3.4
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.4/plugins/commands/box/plugin.rb
INFO manager: Registered plugin: box command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.4/plugins/commands/destroy/plugin.rb
INFO manager: Registered plugin: destroy command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.4/plugins/commands/halt/plugin.rb
INFO manager: Registered plugin: halt command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.4/plugins/commands/help/plugin.rb
INFO manager: Registered plugin: help command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.4/plugins/commands/init/plugin.rb
#!/usr/bin/env bash
if [ -z "$RUBY_VERSION" ]; then
RUBY_VERSION='1.9.3-p327'
fi
which lsb_release > /dev/null
if [ $? -ne 0 ] || [ `lsb_release -s -i` != 'Ubuntu' ]; then
echo -e 'Sorry, this script only works in Ubuntu';
exit 1
@gmiroshnykov
gmiroshnykov / spawn_vim.js
Created March 24, 2012 09:54
Spawn a child process and bind it to parent's stdin, stdout and stderr in node.js
var tty = require('tty'),
spawn = require('child_process').spawn;
var child = spawn('vim');
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
process.stdin.pipe(child.stdin);
process.stdin.resume();
tty.setRawMode(true);
@gmiroshnykov
gmiroshnykov / gist:1339141
Created November 4, 2011 11:28
Good luck with debugging...
$ node server.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
RangeError: Maximum call stack size exceeded
@gmiroshnykov
gmiroshnykov / test-http.js
Created June 3, 2011 15:34
Node.js HTTPS client bug
var http = require('http');
var server = http.createServer(function(req, res) {
req.on('end', function() {
var code = 204;
console.log('Sending status code: ' + code);
res.writeHead(code);
res.end();
});
});
var vows = require('vows'),
assert = require('assert');
vows.describe('Buggy Test').addBatch({
'when async test returns error': {
topic: function() {
var callback = this.callback;
setTimeout(function() {
callback(new Error());
}, 100);
var vows = require('vows'),
assert = require('assert');
vows.describe('Buggy Test').addBatch({
'when async test returns error': {
topic: function() {
var callback = this.callback;
setTimeout(function() {
callback(new Error());
}, 100);