Skip to content

Instantly share code, notes, and snippets.

View ngsmrk's full-sized avatar

Angus Mark ngsmrk

  • London
  • 22:55 (UTC)
View GitHub Profile
@ngsmrk
ngsmrk / gist:00c9486931834d8e8e1b
Created February 19, 2015 21:57
Clojure -> import, instantiate and call java.util.Random
(import '(java.util Random)
(def rnd (new Random))
(. rnd nextInt)
@ngsmrk
ngsmrk / gist:e0bf7a0cec044eb615a1
Last active August 29, 2015 14:15
Clojure -> Example of record defintion
(defrecord Team [name])
(defrecord Player [name team])
(def player-1 (Player. 'Joe (Team. 'Arsenal)))
(print (:name player-1))
(print (:name (:team player-1)))
@ngsmrk
ngsmrk / sidekiq_monitoring
Created August 11, 2014 11:51
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
static void in_received_handler(DictionaryIterator *iter, void *context) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "App Message Received");
Tuple *word_tuple = dict_find(iter, QUOTE_KEY_INIT);
strncpy(word, word_tuple->value->cstring, 100);
text_layer_set_text(text_layer, word);
}
function fetch_random_word() {
var req = new XMLHttpRequest();
req.open('GET', 'http://thesaurus-rex.herokuapp.com/random_word/', true);
req.onload = function (e) {
var status = req.status;
var readyState = req.readyState;
console.log("Status: " + status + ", state: " + readyState);
if (req.readyState == 4 && req.status == 200) {
Pebble.addEventListener("appmessage",
function (e) {
console.log("message");
fetch_random_word();
}
);
static void init(void) {
window = window_create();
window_set_click_config_provider(window, click_config_provider);
}
static void click_config_provider(void *context) {
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
}
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
@ngsmrk
ngsmrk / gist:badb1c84c7aef98b4f01
Last active August 29, 2015 14:00
docker_express_10
[ec2-user@<ip_address> ~]$ curl 0.0.0.0:49154
<!DOCTYPE html><html><head><title>Express</title>
<link rel="stylesheet" href="/stylesheets/style.css">
</head><body><h1>Express</h1>
<p>Welcome to Express</p></body></html>
@ngsmrk
ngsmrk / gist:4dbcca017d7e9a457443
Created April 30, 2014 10:49
docker_express_9
[ec2-user@<ip_address> ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc1b8759a328 ngsmrk/express_image_01:latest /bin/bash 15 seconds ago Up 13 seconds 0.0.0.0:49154->3000/tcp loving_pare
@ngsmrk
ngsmrk / gist:540e06c2c8a20350fbd7
Created April 30, 2014 10:47
docker_express_8
cd /home/docker/dev/test_app
DEBUG=my-application ./bin/www