Skip to content

Instantly share code, notes, and snippets.

@girvo
girvo / errors.js
Last active August 29, 2015 14:21 — forked from gr0uch/errors.js
// TypedError class which other typed errors subclass from.
class TypedError extends Error {
constructor (message) {
super();
if (Error.hasOwnProperty('captureStackTrace'))
Error.captureStackTrace(this, this.constructor);
else
Object.defineProperty(this, 'stack', {
@girvo
girvo / device.css
Last active August 29, 2015 14:21 — forked from jsoverson/device.css
.visible-android {
display:none;
}
.visible-ios {
display:none;
}
.on-device .visible-android, .on-device .visible-android {
display:inherit;
}
.device-ios .visible-android {
@girvo
girvo / immutable.js
Last active August 29, 2015 14:27 — forked from kastermester/immutable.js
Flowtype definition for immutable.js
declare module "immutable" {
declare class Iterable<K, V> {
static isIterable(maybeIterable: any): boolean;
static isKeyed(maybeKeyed: any): boolean;
static isIndexed(maybeIndexed: any): boolean;
static isAssociative(maybeAssociative: any): boolean;
static isOrdered(maybeOrdered: any): boolean;
toArray(): Array<V>;
toIndexedSeq(): IndexedSeq<V>;
@girvo
girvo / private-query-vars.js
Last active August 29, 2015 14:27 — forked from kadamwhite/private-query-vars.js
Query vars for WP-API, trying to understand how everything works
module.exports = [
'offset', // (int) - number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination (Click here for a workaround). The 'offset' parameter is ignored when 'posts_per_page'=>-1 (show all posts) is used.
'posts_per_archive_page', // (int) - number of posts to show per page - on archive pages only. Over-rides posts_per_page and showposts on pages where is_archive() or is_search() would be true.
// 'showposts', // <replaced by posts_per_page>
'nopaging', // (boolean) - show all posts or use pagination. Default value is 'false', use paging.
'post_type', // (string / array) - use post types. Retrieves posts by Post Types, default value is 'post'.
'post_status', // (string / array) - use post status. Retrieves posts by Post Status. Default value is 'publish', but if the user is logged in, 'private' is added.
'category__in', // (array) - use ca
@girvo
girvo / gist:3144864
Created July 19, 2012 15:51
The Withdrawal
The Withdrawal
No junkie ever goes through withdrawal willingly. Oh no, we’ll do anything we can to stave off the sickness, but it’s not something that most will understand. For a Normal person, robbing your parents and cheating your friends and burning all the bridges around you for just a “high” makes no sense... But what they can’t understand is what we’re avoiding.
William S. Burroughs described it as a “thirst”, and I quite honestly can’t find a more apt description. It’s a thirst at the most basic level; your very cells and soul cry out to be quenched. It starts innocently enough: sniffles, like the beginning of a cold. That’s just the beginning. It takes a day or so for a junkie to start to feel the thirst, the hunger. But once it’s a hold of you, the agony and terror and fear that consumes your every waking thought (and most of your unwaking thoughts too) will bring even the strongest person into a place they could never imagine.
The first time I experienced it, I was 18. My best friend had a girlf
@girvo
girvo / sdl2_opengl.c
Created January 6, 2016 03:33 — forked from exavolt/sdl2_opengl.c
Very basic SDL2 OpenGL application
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
@girvo
girvo / redux-inject.js
Created March 8, 2016 02:45 — forked from AdamMaras/redux-inject.js
Redux dependency injection middleware
export default function createInjectMiddleware(map) {
return store => next => action => {
if (typeof action !== "object"
|| typeof action.payload !== "function"
|| action.meta == null
|| action.meta.inject == null) {
return next(action);
}
const defaultInjections = {
/**
* Tiny module to generate an Express middleware that maps the request path to
* a specified folder, allowing for "semi-static" routes without needing to
* define them ahead of time.
*
* Configuration can be passed to the `semiStatic` function when registering the
* middleware. The format is described below, with the "context" property being
* passed to the template's render call, and `context.req` being the request
* object itself.
*
@girvo
girvo / Parser.fs
Created December 10, 2016 00:31 — forked from xavierzwirtz/Parser.fs
module Emly.Parser
open Emly.UntypedAST
open FParsec
open FParsec.CharParsers
open Emly.ParserUtils
open Emly.ParserUtils.IndentationParserWithoutBacktracking
let keywords =
Set.ofList ["let"; "fun"; "rec"; "impure"; "in"; "of"; "if"; "then"; "else"; "match"; "with"; "type"; "foreign"; "mutable"]