Skip to content

Instantly share code, notes, and snippets.

View moea's full-sized avatar

Moe Aboulkheir moea

  • Nervous Systems, Ltd.
  • London
View GitHub Profile
@moea
moea / nginx.config
Created February 11, 2016 11:30
Place in .ebextensions to increase Nginx timeout in a non-Docker AWS Elastic Beanstalk Worker Environment
files:
"/tmp/proxy.conf":
mode: "000644"
owner: root
group: root
content: |
proxy_send_timeout 1200;
proxy_read_timeout 1200;
send_timeout 1200;
package io.nervous.alarmtest;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
package io.nervous.alarmtest;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
public class AlarmWakefulReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
package io.nervous.alarmtest;
import android.app.IntentService;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.Ringtone;
import android.media.RingtoneManager;
@moea
moea / file.cljs
Last active January 7, 2016 01:41
(defn exec-chan
"spawns a child process for cmd with args. routes stdout, stderr, and
the exit code to a channel. returns the channel immediately."
[cmd args & [{:keys [chan]}]]
(let [c (or chan (a/chan)), p (spawn cmd args)]
(.on (.-stdout p) "data" #(put! c [:out (str %)]))
(.on (.-stderr p) "data" #(put! c [:err (str %)]))
(.on p "close" #(a/close! c))
c))
@moea
moea / http-shim.cljs
Created November 16, 2015 19:31
Get, e.g. cljs-http or any goog.net.XmlHttp-based client working on Node
(ns ...
(:import [goog.net XmlHttp XmlHttpFactory])
(:require [cljs.nodejs :as nodejs]))
(def xml-http-request
(-> (nodejs/require "xmlhttprequest")
(.. -XMLHttpRequest)))
(defn NodeXhrFactory []
(this-as this (.call XmlHttpFactory this)))
(defn decrement! [[from-str from-chan] [to-str to-chan] & [start-value]]
(go-loop [n (or start-value (<! from-chan))]
(println from-str "sends" n "to" to-str)
(>! to-chan n)
(when-let [reply (<! from-chan)]
(println from-str "gets" reply)
(if (pos? reply)
(recur (dec reply))
(do
(close! from-chan)
var BigNumber, crypto, parseNumeric,
isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
mathceil = Math.ceil,
mathfloor = Math.floor,
notBool = ' not a boolean or binary digit',
roundingMode = 'rounding mode',
tooManyDigits = 'number type has more than 15 significant digits',
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
BASE = 1e14,
LOG_BASE = 14,
@moea
moea / gist:ed4d4f428a4cb9905c24
Created July 14, 2015 21:56
Runner for nodejs clojurescript tests w/ :optimizations :none
var path = require("path"), fs = require("fs")
var outputTo = process.argv[2]
var googBasedir = path.join(process.cwd(), outputTo, 'goog')
if (!fs.existsSync(googBasedir)) {
console.log("Error: goog directory doesn't exist: " + googBasedir)
process.exit(1)
}
var cljsOutputFile = process.argv[3]
Verifying that +nervous is my openname (Bitcoin username). https://onename.com/nervous