Skip to content

Instantly share code, notes, and snippets.

Geoffrey Hing ghing

Block or report user

Report or block ghing

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
@andrewbtran
andrewbtran / gsiterator.R
Created Jun 19, 2019
gsiterator template
View gsiterator.R
library(tidyverse)
library(googlesheets)
# Authorize user on Google
gs_auth(new_user = TRUE)
# Naming the sheet
name_of_googlesheet <- "Testing out gsiterator"
# Test array
@judy2k
judy2k / parse_dotenv.bash
Created Mar 22, 2017
Parse a .env (dotenv) file directly using BASH
View parse_dotenv.bash
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@pocin
pocin / .zshrc
Last active Jan 12, 2020
Use conda+pyenv to manage python
View .zshrc
# $ brew install pyenv #pay attention to caveats ($ brew info pyenv)
# $ brew install pyenv-virtualenv
# this goes into .zshrc
export PYENV_ROOT=/usr/local/var/pyenv
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
@OnlyInAmerica
OnlyInAmerica / find_iam_user.py
Created Apr 3, 2014
Find an AWS IAM user corresponding to an AWS Access Key
View find_iam_user.py
# Find the IAM username belonging to the TARGET_ACCESS_KEY
# Useful for finding IAM user corresponding to a compromised AWS credential
# Requirements:
#
# Environmental variables:
# AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
# python:
# boto
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active Feb 21, 2020
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew
View fix-homebrew-npm.md

READ THIS Very Important Update

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@audreyr
audreyr / pypi-release-checklist.md
Last active Feb 22, 2020
My PyPI Release Checklist
View pypi-release-checklist.md
  • Update HISTORY.rst
  • Commit the changes:
git add HISTORY.rst
git commit -m "Changelog for upcoming release 0.1.1."
  • Update version number (can also be minor or major)
bumpversion patch
@ghing
ghing / server.py
Created Apr 30, 2013
Send OpenNI skeleton data over a websocket. Uses gevent-websocket for the websockety things.
View server.py
#!/usr/bin/env python
## The equivalent of:
## "Working with the Skeleton"
## in the OpenNI user guide.
"""
This shows how to identify when a new user is detected, look for a pose for
that user, calibrate the users when they are in the pose, and track them,
sending updates about joint position over a websocket.
View dynamic_fields.py
from haystack import indexes
# The easiest, per-object approach.
class CustomSearchIndex(indexes.SearchIndex, indexes.Indexable):
# The usual fields.
def prepare(self, obj):
prepared = super(CustomSearchIndex, self).prepare(obj)
@cspanring
cspanring / tastyhacks.py
Created Feb 8, 2012
Add GeoJSON support for geometry fields in django-tastypie
View tastyhacks.py
# Shamelessly stolen from https://github.com/newsapps/django-boundaryservice/blob/master/boundaryservice/tastyhacks.py
from django.contrib.gis.db.models import GeometryField
from django.utils import simplejson
from tastypie.bundle import Bundle
from tastypie.fields import ApiField, CharField
from tastypie.resources import ModelResource
@unixcharles
unixcharles / backbone.iframe.sync.js
Created Oct 11, 2011
Backbone.sync implementation that use iframe + multipart/form-data
View backbone.iframe.sync.js
(function () {
Backbone.syncWithoutUpload = Backbone.sync
Backbone.syncWithUpload = function(method, model, options) {
// Create iframe
var iframe_id = 'file_upload_iframe_' + Date.now()
, iframe = jQuery('<iframe id="' + iframe_id + '" name="' + iframe_id + '" ></iframe>').hide()
// Create an hidden form
var authToken = jQuery('meta[name=csrf-token]').attr('content')
, authParam = jQuery('meta[name=csrf-param]').attr('content')
You can’t perform that action at this time.