Skip to content

Instantly share code, notes, and snippets.

@JLarky
JLarky / file.jade
Last active August 29, 2015 14:14
How to use react elements inside knockout
span(data-bind='reactElement: someElement')
@JLarky
JLarky / routerecognizer.d.ts
Created February 16, 2015 23:47
routerecognizer typescrip type definitions (incomplete)
// Type definitions for RouteRecognizer 0.1.4
// Project: https://github.com/tildeio/route-recognizer
declare class RouteRecognizer {
add(routes: Object[], options?: Object): void;
map(callback: RouteRecognizer.Callback): void;
recognize(path: string): RouteRecognizer.Result;
}
declare module RouteRecognizer {
@JLarky
JLarky / FluxContainer.ts
Created March 5, 2015 06:37
react.js container helping to subscribe to changes in Flux store written in typescript (es6)
module something {
// inspired by https://github.com/acdlite/flummox/blob/master/docs/api/FluxComponent.md
/* example usage
class SimpleContainer extends FluxSimpleContainer {
stores = {
userStore: App.userStore,
}
getState = () => ({
users: this.stores.userStore.getUsers(),
case <<"first middle last">> of
<<"first", Bin/binary>>
when binary_part(Bin, {byte_size(Bin), -4}) =:= <<"last">> ->
ok
end.
@JLarky
JLarky / docker_pause.sh
Created January 9, 2016 06:09
Bash script to pause docker container after INACTIVE_SEC of inactivity in project files
#!/bin/bash
cd -- "${0%/*}"
CHECK_SEC=60
INACTIVE_SEC=600
DIRECTORY="sameroom"
TIMEOUT_TMP_FILE="./timeout"
DOCKER_NAME="sameroom-dev"
constructor(dispatcher) {
super(dispatcher, () => ({
greetings: 123,
newGreeting: 123
}));
}
const onDispatch = (action: Event) => {
switch(action.type) {
case GreetingActionTypes.ADD_GREETING:
let payload1 = (<AddGreetingEvent> action).payload;
this._state.newGreeting = '';
this._state.greetings = this._state.greetings.concat(payload1);
this.emitChange();
break;
case GreetingActionTypes.REMOVE_GREETING:
let payload2 = (<RemoveGreeting> action).payload;
const onDispatch = (action: Event) => {
if (action instanceof AddGreetingEvent) {
const {payload} = action;
this._state.newGreeting = '';
this._state.greetings = this._state.greetings.concat(payload);
this.emitChange();
} else if (action instanceof RemoveGreeting) {
const {payload} = action;
this._state.greetings = this._state.greetings.filter(g => g !== payload);
this.emitChange();
const StatusIcon = () => {
const color1 = "green";
const color2 = "#74ba74";
const color3 = "#74ba74";
const radius = 50;
return <div id="status_icon"><style>{`
#status_icon{
width: ${radius}px;
height: ${radius}px;
border-radius: ${radius}px;
constructor(dispatcher) {
super(dispatcher, () => ({
greetings: [],
newGreeting: ''
}));
}