View parse-yarn-lock.nix
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
# Parse a yarn.lock file using pure Nix | |
# yarn.lock v1 files are basically YAML with support for having multiple keys for a single value in a map and without array support. | |
# Inspired by https://github.com/yarnpkg/yarn/blob/158d96dce95313d9a00218302631cd263877d164/src/lockfile/parse.js | |
with builtins; | |
let | |
# Add index to a list of elements | |
enumerate = list: genList (i: ({ inherit i; e = elemAt list i; })) (length list); | |
mkToken = type: value: { inherit type value; }; | |
parseLockfile = str: let |
View allthemodels.rb
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
Rails.application.eager_load! | |
ApplicationRecord.subclasses.sort_by(&:name).each do |klass| | |
puts "#{klass.table_name}" | |
puts "===" | |
puts | |
puts "| Column | Type |" | |
puts "|--------|------|" | |
klass.columns.each do |column| |
View up.sh
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
#!/usr/bin/env bash | |
# Exit on fail | |
set -euo pipefail | |
check_or_install() { | |
brew list --versions "$1" &>/dev/null || brew install "$1" | |
} | |
export PGDATA="$PWD/dev/postgres" |
View quine.go
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 main | |
import "fmt" | |
func main() { | |
p := "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tp := %q\n\tfmt.Printf(p, p)\n}" | |
fmt.Printf(p, p) | |
} |
View PKGBUILD
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
# Maintainer: Serge Bakharev <serge.bakharev@gmail.com> | |
# Contributor: Bouke van der Bijl <me@bou.ke> | |
pkgname=openconnect-palo-git | |
_pkgname=openconnect | |
pkgver=7.08.r157.ge5fe063a | |
pkgrel=1 | |
pkgdesc="VPN client for Palo Alto GlobalProtect VPN" | |
arch=('i686' 'x86_64') | |
license=('GPL') |
View just-hosts.rb
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
#!/usr/bin/env ruby | |
# Copyright Bouke van der Bijl | |
require 'nokogiri' | |
# This script interpretes the HTTPS everywhere rulesets and extracts a list of hosts which are eligible for a 'simple' redirect, | |
# e.g. where http://example.com needs to be redirected to https://example.com | |
def is_simple?(rule) | |
rule.attributes['from'].value == "^http:" && rule.attributes['to'].value == "https:" | |
end |
View lmdb_cache_store.rb
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
require 'lmdb' | |
require 'snappy' | |
class LMDBCacheStore | |
attr_reader :max_size, :env, :db, :lru | |
delegate :size, to: :db | |
# The LMDB Gem has a bug where the Environment garbage collection handler will crash sometimes | |
# if the environment wasn't closed explicitely before the reference was lost. | |
# As a shitty workaround, we can make sure that we never lose a reference to the Environment by |
View server.go
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 main | |
import ( | |
"crypto/tls" | |
"github.com/facebookgo/grace/gracehttp" | |
"log" | |
"net/http" | |
"rsc.io/letsencrypt" | |
) |
View immutable.js
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
// Copyright 2004-present Facebook. All Rights Reserved. | |
/** | |
* Immutable data encourages pure functions (data-in, data-out) and lends itself | |
* to much simpler application development and enabling techniques from | |
* functional programming such as lazy evaluation. | |
* | |
* While designed to bring these powerful functional concepts to JavaScript, it | |
* presents an Object-Oriented API familiar to JavaScript engineers and closely | |
* mirroring that of Array, Map, and Set. It is easy and efficient to convert to |
View index.html
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
* { | |
padding:0; | |
margin:0; | |
} | |
#canvas { | |
width:400px; |
NewerOlder