Skip to content

Instantly share code, notes, and snippets.

{
"_id" : "bBhFY4iLYtrmhzmDE",
"type" : "ai1",
"input" : [
0.996078431372549,
0.996078431372549,
0.996078431372549,
0.996078431372549,
0.996078431372549,
0.996078431372549,
@karantir
karantir / index.js
Created January 26, 2019 09:09
Play sound with Howler from blob stored in IndexedDB
(function () {
// IndexedDB
var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.OIndexedDB || window.msIndexedDB,
IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.OIDBTransaction || window.msIDBTransaction,
dbVersion = 2.0;
// Create/open database
var request = indexedDB.open("soundScapeFiles", dbVersion),
db,
createObjectStore = function (dataBase) {
@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
@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 / 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 / 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 / .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 / 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 / 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: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'