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
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 / 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;
#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 / 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