Skip to content

Instantly share code, notes, and snippets.

View jayliew's full-sized avatar

Jay Liew jayliew

View GitHub Profile
@jayliew
jayliew / app_extras.py
Created October 2, 2012 19:06
Django template filter: Add zero-width space to break up long strings
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe
from django import template
register = template.Library()
@register.filter
@stringfilter
def zerowidthspace_separator(value, num):
"""
@jayliew
jayliew / gist:3824822
Created October 3, 2012 03:28
jQuery example: Array of Deferreds and When / Then
var dfd_arr = []; // array of deferred objects
var get_dfd1 = function(){
var dfd1 = $.Deferred();
var req = $.ajax({
success: dfd1.resolve,
});
req.done(function(){ // dfd1 success callback
@jayliew
jayliew / gist:3868115
Created October 10, 2012 20:13
Erlang list of integers to string
L = [100, 120, 100].
lists:flatten([io_lib:format("~c", [V]) || V <- L]).
@jayliew
jayliew / exif_stripper.py
Last active September 30, 2016 22:42
Python script to remove geographic coordinates / latitude (lat) + longitude (long) EXIF data from JPG / JPEG photos / pictures / pics
#!/usr/bin/env python
#
# Purpose: This script strips out all the geo latitude + longitude data
# from JPG / JPEG files
#
# Installation: Make sure you have PIL (Python Imaging Library), or "Pillow"
#
# Usage: Put this file in directory with photos and run it from there
#
# e.g.
@jayliew
jayliew / runkeeper-healthgraph-api.py
Last active December 13, 2016 21:49
Cheatsheet to get data from Runkeeper's API using github.com/aouyar/healthgraph-api
# 1. install aouyar's healthgraph-api (via pip install or git clone. see his instructions)
# 2. signup on Runkeeper.com (as developer, not end user) as an RK app, to get client secret and key
# 3. fire up the self contained web server (bottle and beaker), installing dependencies as needed (about 1 or 2)
# 4. from previous step, you should get the user's access token
import healthgraph
access_token = "xxxxxxxxx" # enter your user access token here
session = healthgraph.Session(access_token)
@jayliew
jayliew / groupme_springhaus_bot.py
Last active March 23, 2017 18:21
groupme django python bot for springhaus
def groupme_springhaus_ops(request):
if settings.ENABLE_GROUPME_OPS == False:
return Http404
url = "https://api.groupme.com/v3/groups/" + settings.GROUPME_SPRINGHAUS_CORE_GROUP_ID_KEY + "/messages"
gmc = GroupMeControl.objects.all()[0]
last_seen_message_id = gmc.last_seen_id_str
print("starting ops. Last message id is: " + gmc.last_seen_id_str)
@jayliew
jayliew / parseCheatViewController.swift
Last active June 25, 2017 18:03
Parse server cheat sheet
//
// parseViewController.swift
// parseTest
//
// Created by Jay Liew on 6/23/17.
// Copyright © 2017 Jay Liew. All rights reserved.
//
/*
_____ __ _ __ ____ __
/\ '__`\ /'__`\ /\`'__\/',__\ /'__`\
@jayliew
jayliew / gist:880d2948d7e0382580e471b44f4bc34f
Created January 9, 2018 18:57
Ubuntu 16.04 systemd service starter script
[Unit]
Description=SSH Tunnel for MySQL
After=network.target
[Service]
Restart=always
RestartSec=20
User=unprivilegedusername
ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -L 3306:127.0.0.1:3306 username@hostactuallyrunningmysqld
@jayliew
jayliew / ramsey_beirne.md
Created June 4, 2018 13:41
ramsey beirne

Professionals exude success, and that was all the outside world saw, if it noticed Ramsey Beirne at all. Beirne would direct that a cold call open with, “Hi, we’re Ramsey Beirne, the leading retained executive search firm in high technology.”

His colleagues thought this was a bit much.

“Well, Dave, couldn’t one argue that—”

“We are. Go.”

If said to a client with sufficient force, it would not be questioned. And if a prospect laughed at the audacity of this little firm in Ossining and said, “So, let me ask you a question—how can you guys call yourself the leading firm?” Beirne and his colleagues would reply, “We brought in the COO of Central Point. We built the whole management team.” The prospect probably had never heard of Central Point Software, either, but Central Point must have been an important client for Ramsey Beirne to lay claim to it in the way that it did.

@jayliew
jayliew / robert_greene-mastery.md
Last active July 16, 2020 19:42
Robert Greene - Mastery. Talks at Google

Notes from Robert Green's talk at Google about his book titled "Mastery"

"Fight or flight" reaction, but intellectual

Min 27:00

Fear and anxiety generates a "fight or flight" response, even in an intellectual realm. It is a physiological response: our minds naturally narrow our focus into what is immediately present.

When confronted with new problems, new circumstances, or when we begin work on a project, learning something new, we're unconsciously plagued with insecurities and anxieties, and we don't like it. Mysteries, any contradiction, situations that are unfamiliar and ambiguous, and elude immediate understanding, all makes us uneasy.