Skip to content

Instantly share code, notes, and snippets.

@awendland
awendland / Optional.java
Created July 20, 2015 21:13
A self contained implementation of Java 8's Optionals that can be placed in any project in order to gain the code clarity of the Optional class. This was extracted and modified from the OpenJDK 8
package com.alexwendland.example.utils;
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
@awendland
awendland / GoogleApiInstance.java
Created August 10, 2015 01:23
A management class for maintaining a single instance of a Google API Client for an application. This class will provide methods for registering actions upon status events.
import android.content.Context;
import android.os.Bundle;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.GoogleApiClient;
import java.util.ArrayList;
import java.util.List;
/**
@awendland
awendland / WebStorage.ts
Last active December 14, 2015 02:31 — forked from heyimalex/WebStorage.js
localStorage sync with redux and TypeScript
export default class WebStorage {
private key: string;
private storageArea: Storage;
constructor(key: string, storageArea = window.localStorage) {
this.key = key;
this.storageArea = storageArea;
}
@awendland
awendland / Optional.ts
Last active February 3, 2016 21:16
Basic implementation of handling null/falsy values functionally
/**
* Optional wrapper type for functional handling of nulls/falsy values
*
* @TODO Support chaining of .or()
*/
export class Optional<T> {
constructor(
private _val: T,
private _justNull = false) {}

Keybase proof

I hereby claim:

  • I am awendland on github.
  • I am awendland (https://keybase.io/awendland) on keybase.
  • I have a public key ASCXIHQRVrtIg32gDOXbZwDRIvgqnAoH-IuvcJNt911vzQo

To claim this, I am signing this object:

@awendland
awendland / til.schema.json
Created April 2, 2016 19:49
Json schema for today I learned entry
{
"id": "http://some.site.somewhere/entry-schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "schema for today I learned entry",
"type": "object",
"required": [ "title" ],
"properties": {
"title": {
"type": "string"
},
@awendland
awendland / demo.js
Created June 18, 2016 21:30
Chai unordered array equality
const expect = require('chai').expect;
const arr = ['email', 'password'];
expect(arr).to.have.members(['email', 'password']); // true
expect(arr).to.have.members(['email']); // false
expect(arr).to.have.members(['email', 'password','extra']); //false
@awendland
awendland / best_mango_lassi_in_soma.md
Last active August 9, 2016 20:03
Review of Mango Lassis in the SOMA area

Best Mango Lassi in SOMA

I'm a huge fan of mango lassi's, and since I'm spending 5 days a week working at 2nd street and Howard I decided to try out and track down the best mango lassi in the area. Here're the ongoing results of my search.

Schedule

  • Tava Kitchen
  • Mehjir
  • North India
  1. Each command in container_command runs in its own shell. Therefore, you can't rely on setting up environment variables before and using them later.
  • Solution to this is to create a file which exports the environment variables that you want. Create this with the files config property and place it somewhere accessible.
  • Then place the commands you would want to be run by command in a .sh file. In that .sh file, source the environment variables file that was created earlier. Set the command to execute the .sh file. Make sure that the .sh file has executable permissions set locally because git syncs those.
@awendland
awendland / rgb_server.py
Last active February 4, 2017 23:42
Raspoberry Pi + LED strip + UDP Server
from __future__ import print_function
import datetime
# Setup UDP server
import socket
UDPSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
listen_addr = ("", 21567)
UDPSock.bind(listen_addr)
print("Listening on port {}\n".format(listen_addr[1]))
print("Commands: `COMMAND PARAMS`")