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
@whitfin
whitfin / runner.js
Last active August 29, 2015 13:57
Simple way to include all tests in Mocha with simple handling.
var fs = require('fs'),
Mocha = require("mocha"),
path = require('path');
// Our Mocha runner
var mocha = new Mocha({
ui:"bdd",
reporter:"spec",
timeout:60000,
slow:10000
#include <conio.h> // For C stuff
#include <ctime> // For the current time
#include <fstream> // Needed for the file stream
#include <iostream> // Needed for input and output
#include <winsock2.h> // Needed for socket connection
using namespace std;
#define SERVER_PORT 12345 // Server port to connect on
#define BUF_SIZE 4096 // Block transfer size
@whitfin
whitfin / ConnectUtils.java
Last active January 4, 2016 20:49
Simple class to control connection detection. Just call `isConnected()` with the Context, and an optional URL to ping.
package com.zackehh.example;
import java.net.URI;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
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 / 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'
]
};
@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
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
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<>();

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:

# 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."""