Skip to content

Instantly share code, notes, and snippets.

View relekang's full-sized avatar
🦀

Rolf Erik Lekang relekang

🦀
View GitHub Profile
@relekang
relekang / UrqlResponse.re
Last active October 6, 2019 12:50
Helpers for working with ReasonUrql.Types.response
type t('a) = ReasonUrql.Types.response('a);
let map: (t('a), 'a => 'b) => t('b) =
(response, fn) =>
switch (response) {
| Fetching => Fetching
| NotFound => NotFound
| Error(error) => Error(error)
| Data(data) => Data(fn(data))
};
@relekang
relekang / init-libdef.sh
Last active August 24, 2016 05:30
Init script for creating libdefs files for flowtype/flow-typed. Usage example `./init-libdef.sh lodash 4.x.x`
#!/bin/bash -eux
NAME=$1
VERSION=$2
FLOW_VERSION=0.25.x
echo $NAME@$VERSION
DIRECTORY=$(dirname $0)/definitions/npm/${NAME}_v$VERSION
@relekang
relekang / local_storage.js
Created March 15, 2016 08:26
API mock with local_storage
import _ from 'lodash'
export const get = (path, data) => {
const collection = JSON.parse(localStorage.getItem(path)) || []
if (data && data.id) {
return Promise.resolve(_.find(collection, ['id', data.id]))
}
return Promise.resolve(collection)
}
@relekang
relekang / example.js
Created December 1, 2015 14:36
Store mixin
export default React.createClass({
displayName: 'ExamplePage',
stores: [ExampleStore, OtherStore],
mixins: [StoreMixin],
render: function() {
return <h1>o/</h1>;
}
});
#!/bin/sh
CHANGED_JS_FILES=$(git diff --cached --name-only --diff-filter=ACMRTUXB -- '*.js')
echo
if [ -n "$CHANGED_JS_FILES" ]; then
eslint $CHANGED_JS_FILES
fi

Writing latex with atom

Install language-latex and:

1. In init.coffee

path = require 'path'

atom.workspaceView.eachEditorView (editorView) ->
 editor = editorView.getEditor()

Usage

curl https://gist.githubusercontent.com/relekang/6ba186afdb13297cdad4/raw/848b475ef725b6485dcd9bb137124bde1553f76c/setup.sh | sh

python-thumbnails

What is python-thumbnails

It is a python package for creating thumbnails. It is not tied to a specific web framework, but is designed to work with most of them and has planned integrations with Django and Flask.

Example site (Repo)
Documentation

Roadmap

@relekang
relekang / apm-test.sh
Created February 7, 2015 20:52
A test script for running `apm test` on a linux box
#!/bin/sh
PID_PATH=/var/run/xvfb_99/`date +%s`.pid
start-stop-daemon --start --pidfile $PID_PATH --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +extension RANDR +render -noreset > /dev/null || exit 1
sleep 3 > /dev/null
export DISPLAY=:99 > /dev/null
apm test
EXIT_CODE=$?
start-stop-daemon --stop --pidfile $PID_PATH > /dev/null
exit $EXIT_CODE
@relekang
relekang / Makefile
Created January 13, 2015 15:04
Latex project makefile
ifeq ($(shell uname -s), Darwin)
OPEN='open'
else
OPEN='see'
endif
ifeq ($(USE_BIB), false)
COMPILE = pdflatex -halt-on-error report.tex >> logs/compile \
&& echo "Compiled report" || (cat logs/compile && fail)
else