Skip to content

Instantly share code, notes, and snippets.

View fearphage's full-sized avatar
⌨️
Cache rules everything around me.

Phred Lane fearphage

⌨️
Cache rules everything around me.
View GitHub Profile
[
{
"use_channel":true,
"allow_empty_post_data":true,
"app_id":"edaded98-5119-4c8a-afc1-de722da03562",
"url":"http://chromecast.redbull.tv/receiver.php",
"dial_enabled":true
},
{
"use_channel":true,
@fearphage
fearphage / nginx.conf
Created February 15, 2014 03:48 — forked from plentz/nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048

JavaScript Templates Engines

A quick comparison/ benchmark between Hogan, Dust, doT and underscore

Presentation and Readability

Hogan.js

Developed by Twitter (same team as Bootstrap), use exactly the same syntax as Mustache, but more performant and more stuff available server side.

My name is {{ name }}

# Build
IMAGEID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1) && sudo docker build -t $IMAGEID .
# Run new container
CONTAINER_ID=$(sudo docker run -t -d -p 0.0.0.0:81:80 $IMAGEID)
# Login into running container
FULL_CONTAINER_ID=$(sudo docker ps -a -notrunc -q | grep -F $CONTAINER_ID) && sudo lxc-attach -n $FULL_CONTAINER_ID /bin/bash
# Container stdout
#!/bin/sh -e
export DEBIAN_FRONTEND=noninteractive
HOSTNAME=${1}
DOMAINNAME=${2}
PUPPET_MANIFEST=${3}
PUPPETMASTER_IP=${4}
FQDN=${HOSTNAME}.${DOMAINNAME}
@fearphage
fearphage / gist:eb439159c7adfc327acd
Created January 7, 2015 21:51
Python's defaultdict
function defaultDict(constructor) {
return new Proxy({}, {
get: function(object, property) {
return property in object
? object[property]
: object[property] = constructor()
;
}
});
}

This short code will show how to sync database file using Realm, but can be used for any file that you need to send to Wear (using Data API). It just takes any file, change it to Asset object and send it over to Wear device. Also it can be used Mobile->Wear, and Wear->Mobile.

When you need to sync database just call FileSender.syncRealm(context);, that is it!

DISCLAIMER "Proper" way would be to synchronize each transaction to DB, but it in most cases Wear is used very rarely comparing to mobile, so it would most likely cause a battery drain. My idea was to synchronize it only whene it is needed (so for example when app closes). If you want to make sure that you are using latest DB, just send trigger data using MessageAPI from Wear to Phone with ask of syncing over its database, or keep some timestapm of last edit and check it.

#!/usr/bin/env bash
# On OS X, use this script to generate an encrypted deployment key for Travis CI.
# Dependencies:
# gem install travis
# brew install coreutils
if [ $# -lt 1 ]; then
echo "usage: $0 <user>/<repo>"
function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;
this.connect = function(sURL, sMethod, sVars, fnDone)
{