Skip to content

Instantly share code, notes, and snippets.

Function.prototype.inheritsFrom = function( parentClassOrObject ){
if ( parentClassOrObject.constructor == Function )
{
//Normal Inheritance
this.prototype = new parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject.prototype;
}
else
{
@karantir
karantir / ansible.install.sh
Last active December 29, 2015 00:29
Ansible installation
echo "\nUpdating system packages..."
apt-get -qq update
echo "\nInstalling main dependencies..."
apt-get install --quiet --assume-yes git curl build-essential python-setuptools python-dev sshpass
echo "\nInstalling pip..."
apt-get install python-pip
echo "\nInstalling ansible"
pip install ansible
@karantir
karantir / gist:28646dabf2f57851a3c7
Created January 9, 2015 22:01
Disable TLS for Boot2docker VM
Since Boot2docker 1.3.1, just need to set DOCKER_TLS=no at VM side.
$ boot2docker ssh -t 'sudo vi /var/lib/boot2docker/profile'
@karantir
karantir / foo.sh
Last active January 16, 2017 20:49
Run docker w/o sudo
# add the docker group if it doesn't already exist.
sudo groupadd docker
# Add the connected user to the docker group.
sudo gpasswd -a ${USER} docker
# Restart the Docker daemon
sudo service docker restart
# Activate the changes on groups
newgrp docker
@karantir
karantir / gist:b00bfb5a0eac483f9168
Created March 20, 2015 09:19
Cast date type on specific field for all documents in mongodb collection
var cursor = db.<collection>.find();
while (cursor.hasNext()) {
var doc = cursor.next();
db.<collection>.update({_id : doc._id}, { $set : { <field>: new Date(doc.<field>)} })
}
@karantir
karantir / .vagrant.ini
Last active April 26, 2016 12:25
Vagrant environment for bower based frontend
[all]
127.0.0.1
[all:vars]
project_root = /vagrant
upstart_criteria = vagrant-mounted
project_url = localhost
ansible_sudo = true
ansible_ssh_user = vagrant
ansible_ssh_port = 2222
@karantir
karantir / yotakeepalive.sh
Created May 17, 2016 09:50
Simple init.d script for OpenWRT based router, to keep alive Yota 4G Interned over USB stick
#!/bin/sh /etc/rc.common
# Yota 4G Internet keep alive script
START=10
STOP=15
start() {
echo 'starting'
ping www.ru
while [ $? -ne 0 ]; do
@karantir
karantir / cheatsheet.md
Created June 14, 2016 09:49
Using I2C on OpenWRT

Installing packages.

opkg update
opkg install kmod-i2c-gpio-custom i2c-tools

Loading I2C bus drivers. Using pins 7 (SDA) and 8 (SCL).

insmod i2c-dev
insmod i2c-gpio-custom bus0=0,7,8
@karantir
karantir / foo.js
Last active January 16, 2017 20:45
RactiveJS; RequireJS; Dynamic component; Condition based code loading
define([
'ractive',
'module'],
function(Ractive, module) {
return Ractive.extend({
template: '{{# isLoaded }}<innerComponent />{{/ isLoaded }}',
components: {
innerComponent: function() {
@karantir
karantir / docker.cleanup.sh
Last active January 16, 2017 20:41
Remove exited containers, orphanted images and volumes
#!/bin/bash
# Docker version >= 1.9
echo "Cleaning up exited containers..."
docker ps -a -qf status=exited | xargs -r docker rm
echo "Cleaning up orphanted images..."
docker images -qf dangling=true | xargs -r docker rmi
echo "Cleaning up orphanted volumes..."
docker volume ls -qf dangling=true | xargs -r docker volume rm