Skip to content

Instantly share code, notes, and snippets.

robinchew

Block or report user

Report or block robinchew

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pceftpos-development.md

Setting up PC-EFTPOS is a P-ITA, so do the following dance, and things might work.

  1. During setup, remember to select "PINPad will be attached..." PINPad will be attached....
  2. After setting up the virtual pinpad with the 7410 dance, you might have to close it and open it again, until you see PC_EFTPOS DEMO READY.
View timesheet.py
import re
import sys
from decimal import Decimal
def in_seconds(time_str):
hour, minute = map(int, time_str.split(':'))
return hour * 60 * 60 + minute * 60
def seconds_to_hours(seconds):
return seconds / 60 / 60
View browserify-one-liner
node_modules/browserify/bin/cmd.js --standalone bundle --debug main.js -t [ babelify --presets [ env ] --plugins [ mopt ] ] -o $BUNDLE_FILE_NAME
View xmodmap
! Caps_Lock behaves as Control_L
remove Lock = Caps_Lock
keysym Caps_Lock = Control_L
add Control = Control_L
! Disable Control_L
keycode 37 = NoSymbol
! Left-handed mouse
pointer = 3 2 1
View example-using-mithril.cljs
(defn quote-form [{:keys [floor-plan-update-url floor-plan-create-url] :as urls} data-atom history-atom quote-id db-index search-index variant-search-index after-save]
(let [a (deref data-atom)
q (a :quote)
floor-plan-create-update-url (if quote-id floor-plan-update-url floor-plan-create-url)
field-errors (a :field-errors)
quoted-product-errors ((a :field-errors) "quoted_products")
quote-id ((a :quote) "id")
pdf-list ((a :quote) "pdfs")
client-list (a :clients)
staff-list (a :staffs)
View mithril.cljs
(ns cloject.mithril)
(defn build [l]
(if (vector? l)
(apply js/m
(clj->js (for [i l]
(build i))))
(if (seq? l)
(clj->js (for [i l]
(build i)))
View server_more_pythonic.py
# http://slides.com/robinchew/deck
from collections import defaultdict
from textwrap import dedent
from urllib.parse import urlparse, parse_qs
from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server
import csv
View server_unpythonic.py
# http://slides.com/robinchew/deck
from collections import defaultdict
from textwrap import dedent
from urllib.parse import urlparse, parse_qs
from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server
import csv
View server_old.py
import SimpleHTTPServer
import SocketServer
from textwrap import dedent
from urlparse import urlparse, parse_qs
from collections import defaultdict
import csv
import os
import sys
@robinchew
robinchew / beautiful_idiomatic_python.md
Last active May 24, 2016 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!
View beautiful_idiomatic_python.md

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
You can’t perform that action at this time.