Skip to content

Instantly share code, notes, and snippets.

View safareli's full-sized avatar

Irakli Safareli safareli

View GitHub Profile
class GetLabelType (rl ∷ RowList) (s ∷ Symbol) (a ∷ Type) | rl s → a where
labelType ∷ RLProxy rl → SProxy s → Proxy a
instance getLabelTypeFound ∷ GetLabelType (Cons s a tail) s a where
labelType _ _ = Proxy
else instance getLabelTypeNotFound ∷ GetLabelType (Cons s a tail) s Void where
labelType _ _ = Proxy
else instance getLabelTypeInd ∷ GetLabelType tail ss b ⇒ GetLabelType (Cons s a tail) ss b where
labelType _ _ = labelType (RLProxy ∷ RLProxy tail) (SProxy ∷ SProxy ss)
else instance getLabelTypeVoid ∷ GetLabelType Nil s Void where
@hallettj
hallettj / adt.js
Last active March 21, 2019 12:56
Proposed implementation of GADTs with Javascript and Flow
/*
* `match` is a helper function for writing pattern matches on types that are
* implemented using Scott encoding.
*
* @flow
*/
export function match<A,B>(matcher: A): (match: (matcher: A) => B) => B {
return match => match(matcher)
}
@DrBoolean
DrBoolean / mcft.js
Created December 30, 2015 04:44
Monoidal Contravariant Functors and Transducers
const daggy = require('daggy');
const {foldMap} = require('pointfree-fantasy')
const {concat, toUpper, prop, identity, range, compose} = require('ramda');
// Contravariant functors usually have this shape F(a -> ConcreteType).
// In other words, some type holding a function which is parametric on its input, but not output.
// They don't always have that shape, but it's a good intuition
// Covariant functors are what we're used to, which are parametric in their output
//================================================================
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@webdesserts
webdesserts / Gulpfile.js
Last active April 3, 2023 08:16
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@Stichoza
Stichoza / fbShare.js
Created February 13, 2013 06:56
Facebook share popup JS function, popup window in screen center.
function fbShare(url, title, descr, image, winWidth, winHeight) {
var winTop = (screen.height / 2) - (winHeight / 2);
var winLeft = (screen.width / 2) - (winWidth / 2);
window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
}
@alexargo
alexargo / proxysetup.sh
Last active October 22, 2022 04:15
Script to set your proxy information based on the current default service on Mac OS X... usefull to configure the http_proxy/https_proxy variables when you have a mac running on a corporate network. - Updated for Mountain Lion
#!/bin/bash
#take a configurable service from first argument
if [ $# = 1 ]
then
SERVICE_NAME=$1
fi
#otherwise get the active one
if [ $# = 0 ]
@defunctzombie
defunctzombie / browser.md
Last active April 10, 2024 17:45
browser field spec for package.json
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@afeld
afeld / gist:1254889
Created September 30, 2011 20:28
YouTube video ID regex
# Parses YouTube URLs directly or from iframe code. Handles:
# * Address bar on YouTube url (ex: http://www.youtube.com/watch?v=ZFqlHhCNBOI)
# * Direct http://youtu.be/ url (ex: http://youtu.be/ZFqlHhCNBOI)
# * Full iframe embed code (ex: <iframe src="http://www.youtube.com/embed/ZFqlHhCNBOI">)
# * Old <object> tag embed code (ex: <object><param name="movie" value="http://www.youtube.com/v/ZFqlHhCNBOI">...)
/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
$5 #=> the video ID
# test it on Rubular: http://rubular.com/r/eaJeSMkJvo