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
// | |
// Simplified (and mostly incorrect) definition of the Maybe monad. | |
// | |
class Maybe { } | |
class Nothing extends Maybe { } | |
class Just extends Maybe { | |
constructor(v) { |
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
defmodule Optional do | |
defmacro __using__(_opts) do | |
quote do | |
require unquote(__MODULE__) | |
import unquote(__MODULE__) | |
end | |
end | |
def unit(nil), do: {:err, nil} | |
def unit(value), do: {:ok, value} |
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 | |
CURL=$(which curl) | |
if [[ ! -x "${CURL}" ]]; then | |
echo "Missing dependency. Please install curl (https://formulae.brew.sh/formula/curl): | |
$ brew install curl" 1>&2 | |
exit 1 | |
fi | |
readonly PROGRAM=$(basename -- $0) |
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
const { asKey } = require('./utils'); | |
const text = { | |
"520407a476092ac19c671e1e75d052bd": "i18n!", | |
}; | |
const gettext = (str) => text[asKey(str)] || str | |
console.log(gettext("Iлtèrnåtïonɑlíƶatï߀ԉ")); //=> "i18n!" | |
console.log(gettext("Autre chose!")); //=> "Autre chose!" |
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
class Model { | |
constructor() { | |
this.userCollection = [ ] | |
this.selectedUser = null | |
this.listeners = { | |
'selectedUser': [ ], | |
'userCollection': [ ] | |
} | |
} |
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
@Grab('org.jfree:jfreechart:1.0.14') | |
import java.awt.* | |
import java.awt.geom.* | |
import java.io.* | |
import java.text.* | |
import org.jfree.chart.* | |
import org.jfree.chart.annotations.* | |
import org.jfree.chart.axis.* | |
import org.jfree.chart.block.* | |
import org.jfree.chart.labels.* |
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
import javax.management.* | |
import javax.management.remote.* | |
var serverUrl = "service:jmx:rmi:///jndi/rmi://0.0.0.0:9090/jmxrmi" | |
var connection = JMXConnectorFactory.connect(new JMXServiceURL(serverUrl)).getMBeanServerConnection() | |
var objectName = new ObjectName("my-domain:type=my-bean-type,name=my-bean-name") | |
var pingResult = (int) connection.invoke(objectName, "ping", null, null) // Assumes an `int ping()` method that returns the error code. | |
/exit pingResult |
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
qs = require 'querystring' | |
diagram = """ | |
title Foo bar baz | |
a -> b: do b.m() | |
b -> c: do c.m() | |
""" | |
baseUrl = "http://www.websequencediagrams.com/cgi-bin/cdraw" |
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
import sys | |
import re | |
import subprocess | |
import os | |
# | |
# Usage: | |
# $ youtube-dl -f 140 https://www.youtube.com/watch?v=Iq0xfewozjw | |
# $ python3 split.py <input file name>.m4a tracks.txt | |
# |
NewerOlder