Skip to content

Instantly share code, notes, and snippets.

@AGoblinKing
AGoblinKing / component.js
Last active August 29, 2015 14:14
Mithril Components using a Module Loader
var m = require("mithril");
module.exports = function Component(ctrl) {
var foo = ctrl.Component.foo = m.prop(5);
ctrl.Component.clicked = function() {
ctrl.Component.foo(++foo);
};
return function ComponentView() {
@webcss
webcss / eventsmixin.js
Last active August 9, 2016 12:44
PubSub mixin using CustomEvents
// utilizes the browser eventsystem
// usefull in cases where you need communication between independent components
// registered events are automatically removed onunload with preserving any other onunload handler
var eventsMixin = function(target) {
var _subscriptions = [];
target.broadcast = function(type, payload) {
var ev = new CustomEvent(type, {
detail: payload,
@keis
keis / coro.py
Created April 14, 2014 08:27
asyncio examples
import asyncio
@asyncio.coroutine
def waiting(r):
print("hello from waiting -", r)
yield from asyncio.sleep(2)
print("bye from waiting -", r)
return r
@elad
elad / neural-style-ec2.txt
Created September 7, 2015 08:09
Running neural-style in EC2
Start a g2.2xlarge or better (GPU instance) with https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-ffba7b94
Login, username is ubuntu
Update a bunch of stuff and make sure cudnn R2 is used:
luarocks install image
luarocks install loadcaffe
luarocks install torch
export LD_LIBRARY_PATH=/home/ubuntu/torch-distro/install/lib:/home/ubuntu/torch-distro/install/lib:/home/ubuntu/cudnn-6.5-linux-x64-v2-rc2
@jprante
jprante / gist:10666960
Last active March 19, 2019 11:22
Elasticsearch configuration for high sustainable bulk feed

Elasticsearch configuration for high sustainable bulk feed

Test on single node, MacBook Pro, 16 GB RAM, 1TB SSD, OS X Maverick

ES 1.1.0 with Java 8, G1 GC, 12 GB heap

/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java -Xms12g -Xmx12g -Djava.awt.headless=true -XX:+UseG1GC -Delasticsearch -Des.foreground=yes -Des.path.home=/Users/es/elasticsearch-1.1.0 -cp :/Users/es/elasticsearch-1.1.0/lib/elasticsearch-1.1.0.jar:/Users/es/elasticsearch-1.1.0/lib/:/Users/es/elasticsearch-1.1.0/lib/sigar/ org.elasticsearch.bootstrap.Elasticsearch

Node

@leolord
leolord / vim.sh
Last active August 4, 2021 19:45
Compiling vim on Ubuntu 18 with LUA-support
# Remove previous installations
sudo apt-get remove vim vim-runtime vim-tiny vim-common
# Install dependencies
sudo apt-get install libncurses5-dev python-dev liblua5.3-dev lua5.3 python3-dev
# Fix liblua paths
# You have to compile luajit for yourself.
sudo ln -s /usr/include/lua5.3 /usr/include/lua
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/local/lib/liblua.so
@charlee
charlee / ffmpeg.sh
Last active January 19, 2022 15:05
ffmpeg tips
# losslessly concat mp4 files
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
# concat files with the same format
# 1. create a file list
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
@LeCoupa
LeCoupa / casperjs.cheatsheet.js
Last active January 23, 2022 07:56
Cheatsheet: CasperJS, PhantomJS & Spooky --> https://github.com/LeCoupa/awesome-cheatsheets
// PhantomJS Cheatsheet
$ brew update && brew install phantomjs // install PhantomJS with brew
phantom.exit();
var page = require('webpage').create();
page.open('http://example.com', function() {});
page.evaluate(function() { return document.title; });
@StephanHoyer
StephanHoyer / gist:bddccd9e159828867d2a
Last active March 29, 2022 11:46
Isomorphic applications with mithril

Attention

This post described how to create an application with mithril 0.2.x. Now that ver 1.0 is out, some things are a little differnent.

The example is updated with the current version of mithril, though.

Isomorphic applications with mithril

@demisx
demisx / gulpfile.js
Last active July 14, 2022 16:06
Gulp 4 gulpfile.js
// Gulp 4
var gulp = require('gulp');
var using = require('gulp-using');
var grep = require('gulp-grep');
var changed = require('gulp-changed');
var del = require('del');
var coffee = require('gulp-coffee');
var less = require('gulp-less');
var coffeelint = require('gulp-coffeelint');
var sourcemaps = require('gulp-sourcemaps');