Skip to content

Instantly share code, notes, and snippets.

View joshuakfarrar's full-sized avatar
💻
Purely Functional

Joshua K. Farrar joshuakfarrar

💻
Purely Functional
View GitHub Profile
@thoughtpolice
thoughtpolice / Foobar.hs
Last active July 21, 2018 16:59
Opaleye + resource-pool + postgresql-simple
-- | Simple alias for PostgreSQL connection pools.
type PostgresPool = Pool.Pool PGS.Connection
-- | Execute a query against the PostgreSQL database, using
-- a connection pool.
runQueryPool :: Default QueryRunner cols vals
=> Pool.Pool PGS.Connection
-> Query cols
-> IO [vals]
runQueryPool p q = Pool.withResource p (`runQuery` q)
@smarter
smarter / gadt.md
Last active September 6, 2024 17:18
GADTs in Scala

Generalized Algebraic Data Types in Scala

Basic GADTs

Here's an ADT which is not a GADT, in Haskell:

data Expr = IntExpr Int | BoolExpr Bool
@karpathy
karpathy / min-char-rnn.py
Last active November 20, 2024 02:50
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@cletusw
cletusw / .eslintrc
Last active February 29, 2024 20:24
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@fversnel
fversnel / SmartSortable.js
Created December 30, 2014 11:36
React SmartSortable
var cloneWithProps = React.addons.cloneWithProps;
var SmartSortable = React.createClass({
getDefaultProps: function() {
return {component: "ul", childComponent: "li"};
},
render: function() {
var props = jQuery.extend({}, this.props);
@konklone
konklone / 1-government-hsts.rb
Last active October 21, 2024 00:19
Script that detects government domains in Chrome's HSTS preload list.
#!/usr/bin/env ruby
# Script by Eric Mill to detect government domains in the Chrome HSTS Preload list.
#
# The Chrome HSTS Preload list is a hardcoded set of domains for which the browser
# will *only* ever access the site using HTTPS. If an http:// link to that site is
# encountered, the browser will just rewrite the URL to https:// before following
# it.
#
# This list is also incorporated into Firefox and Safari, making it a nice list to
@tokestermw
tokestermw / visualizing_topic_models.py
Last active September 7, 2021 16:57
visualization topic models in four different ways
import json
import urlparse
from itertools import chain
flatten = chain.from_iterable
from nltk import word_tokenize
from gensim.corpora import Dictionary
from gensim.models.ldamodel import LdaModel
from gensim.models.tfidfmodel import TfidfModel
@david-christiansen
david-christiansen / FizzBuzzC.idr
Last active August 29, 2022 20:00
Dependently typed FizzBuzz, now with 30% more constructive thinking
module FizzBuzzC
%default total
-- Dependently typed FizzBuzz, constructively
-- A number is fizzy if it is evenly divisible by 3
data Fizzy : Nat -> Type where
ZeroFizzy : Fizzy 0
Fizz : Fizzy n -> Fizzy (3 + n)
@staltz
staltz / introrx.md
Last active November 19, 2024 18:00
The introduction to Reactive Programming you've been missing
(function() {
// Do not use this library. This is just a fun example to prove a
// point.
var Bloop = window.Bloop = {};
var mountId = 0;
function newMountId() {
return mountId++;
}