Skip to content

Instantly share code, notes, and snippets.

View joona's full-sized avatar

Joona Kulmala joona

  • Rootz LTD
  • Finland
View GitHub Profile
class ChunkingObjectStream extends WriteableStream {
constructor(options) {
options.objectMode = true;
super(options);
this.chunkSize = options.chunkSize || 100;
this.queue = [];
this.counter = 0;
this.emitted = 0;
@joona
joona / store_factory.js
Created December 15, 2016 11:47
Store factory, to be used with flux implementation, using CustomEvents
export default function storeFactory(obj) {
var element = document.createElement('div');
element.setAttribute('data-store', true);
var store = {};
store._element = element;
store._listeners = {};
store.listen = (name, callback) => {
element.addEventListener(name, e => {
export function dispatch(el, eventName, payload) {
el || (el = document);
el = el.el || el;
var event = new CustomEvent(eventName);
event.details = payload || {};
el.dispatchEvent(event);
}
export function listen(el, eventName, callback) {
el || (el = document);
@joona
joona / env.js
Last active November 30, 2016 16:44
const fs = require('fs');
const qs = require('querystring');
const buf = fs.readFileSync('.env').toString();
const env = qs.parse(buf, "\n");
function getHash(env) {
return new Promise((resolve, reject) => {
require('child_process').exec('git rev-parse HEAD', (err, hash) => {
if(err) return reject(err);
env.COMMIT_HASH = hash;
@joona
joona / brightnessctl.sh
Last active October 17, 2016 18:55
Backlight control helper for laptops running intel and NVIDIA cards.
#!/bin/bash
PRIME_MODE=`prime-select query`
IS_NVIDIA=false
if [ "$PRIME_MODE" == "nvidia" ]; then
IS_NVIDIA=true
fi
@joona
joona / main.java
Created March 13, 2015 12:45
Google service account JSON key to Google OAuth2 access token request
package io.inbot;
import com.github.jsonj.JsonObject;
import com.github.jsonj.tools.JsonParser;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.security.InvalidKeyException;
# It'd be great to get this running via AppleScript and sans Alfred if anyone with more knowledge than me knows how :)
### STEP 1
#!/bin/sh
# Save this file as /bin/rvm_ruby, and do chmod 755 /bin/rvm_ruby
# to give it the proper permissions
# From http://www.aeonscope.net/2011/05/29/connecting-alfred-to-bitly-via-ruby/
if [[ -s ~/.rvm/scripts/rvm ]]; then
@joona
joona / deploy.rb
Created November 15, 2012 15:12 — forked from alkema/deploy.rb
Capistrano task for a Node.js app with github Forever and NPM.
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
@joona
joona / .bash_profile
Created November 14, 2012 22:09
Recipe for success with NVM on CentOS with default Python 2.4 and Python 2.6 installed.
# add these modifications to your path
export PATH="$HOME/bin:$PATH"
# activate NVM
. ~/.nvm/nvm.sh
@joona
joona / gist:3825826
Created October 3, 2012 08:39 — forked from leplatrem/gist:1415795
Tiles serialization in base64 using django and landez
import base64
from StringIO import StringIO
from django.http import HttpResponse
from django.utils import simplejson
from easydict import EasyDict as edict
from landez import TilesManager
from . import app_settings