This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (parts = document.title.split(///\s[-|–]\s///)).length == 2 | |
title = parts[0] | |
author = parts[1] | |
else | |
title = document.title | |
author = (document.getElementsByName("author")[0])?.content || document.location.host.replace(/^((.+)\.)?([^\.]+\.[^\.]+)$/, '$3') | |
language = (document.getElementsByTagName("html")[0])?.lang || "en" | |
pad = ((num) -> if num < 10 then "0"+num else num) | |
date_part = (date) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
salias () { | |
N=$1 | |
F=$ZSH_CUSTOM/aliases.zsh | |
shift | |
egrep -v "^alias $N" $F > $F.new | |
mv $F.new $F | |
echo "alias $N=\"$*\"" >> $F | |
source $F | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function decTime() { | |
var date = new Date(); | |
var oldSeconds = date.getSeconds()+date.getMinutes()*60+date.getHours()*60*60+date.getMilliseconds()/1000; | |
oldSeconds = oldSeconds/(1-0.136); | |
var hours = Math.floor(oldSeconds / (100*100)); | |
oldSeconds = oldSeconds % (100*100); | |
var minutes = Math.floor(oldSeconds / 100); | |
var seconds = oldSeconds % 100; | |
return hours+':'+minutes+':'+seconds; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gildedrose; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import java.io.File; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.URL; | |
import java.nio.file.Files; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// snip for production | |
const store = createStore(thunk.withExtraArgument({fetch})); | |
// snip effect | |
import { createAction } from 'redux-actions'; | |
const createEffect = (name, fun) => (...args) => dispatch => { | |
const action = createAction(name); | |
dispatch({ type: `${name}_STARTED` }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chroma from 'chroma-js'; | |
const cluster = (colors, centers) => { | |
const centerCounts = {}; | |
for(let color of colors) { | |
let bestCenter = null; | |
let bestCenterDist = Number.MAX_VALUE; | |
for(let center in centers) { | |
const dist = chroma.distance(color, centers[center]); | |
if(dist < bestCenterDist) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Event<T extends string, P> = { | |
type: T; | |
meta: { | |
time: string; | |
}; | |
payload: P; | |
}; | |
type EventCreator<T extends string, P> = ( | |
payload: P, |