Skip to content

Instantly share code, notes, and snippets.

View whitfin's full-sized avatar
🏠
Working from home

Isaac Whitfield whitfin

🏠
Working from home
View GitHub Profile
path = _{ SOI ~ base ~ accessor* ~ EOI }
base = @{ ("$" | "_" | ASCII_ALPHA) ~ identifier }
accessor = _{ ("." ~ identifier ) | ("[\"" ~ inner ~ "\"]") | index }
identifier = { ("$" | "_" | ASCII_ALPHANUMERIC)* }
inner = @{ char* }
char = {
!("\"" | "\\") ~ ANY
@whitfin
whitfin / Cargo.toml
Last active March 1, 2019 20:56
Example of piping request body to a file in Gotham
[package]
name = "gotham_request_pipe"
version = "0.1.0"
authors = ["Isaac Whitfield <[email protected]>"]
edition = "2018"
[dependencies]
gotham = "0.3"
hyper = "0.12"
tokio = "0.1"
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Libimobiledevice(AutotoolsPackage):
"""Library to communicate with iOS devices natively."""

Keybase proof

I hereby claim:

  • I am whitfin on github.
  • I am whitfin (https://keybase.io/whitfin) on keybase.
  • I have a public key ASBIcyeqhID9fEJiNyYMaKpyS67OGMiNNXGibXxQ8Hzzngo

To claim this, I am signing this object:

package com.appcelerator.binding;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class Broadcaster {
private static final Map<String, List<Listener>> LISTENERS = new ConcurrentHashMap<>();
client
.refresh()
.then(function () {
return client.get(); // return your promise
})
.then(function (result) {
// result is the return of client.get()
})
.catch(function (err) {
// common handler for any broken promise now
@whitfin
whitfin / poor_persons_with.exs
Last active September 6, 2016 23:06
If you're working against Elixir v1.1, here's a simple (single tier) with statement
defmodule MyModule do
defmacro exec_with(left, right, do: fun) do
quote do
case unquote(right) do
unquote(left) ->
unquote(fun)
v -> v
end
end
end
@whitfin
whitfin / elasticsearch.js
Created July 6, 2016 21:25
dockserv recipes
module.exports = {
image: 'elasticsearch',
binds: [
'$DOCKSERV_DATA/elasticsearch/data:/usr/share/elasticsearch/data'
],
ports: [
'9200',
'9300'
]
};
exports.parse = function parse(mdown) {
console.log('<p align="center" style="margin: 2em auto auto auto; width:70%;">');
mdown.match(/\[\!.*?\)\].*?\)/g).forEach(function (badge) {
var segments = badge.match(/\[!\[(.*?)\]\((.*?)\)\]\((.*?)\)/);
var altText = segments[1];
var svgPath = segments[2];
var urlHref = segments[3];
console.log(` <a href="${urlHref}">`);
@whitfin
whitfin / ArrayNodeCollector.java
Created September 19, 2015 22:46
Collecting to a Jackson ArrayNode from a Java 8 Stream.
package com.zackehh.example;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.util.EnumSet;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;