Skip to content

Instantly share code, notes, and snippets.

View ichord's full-sized avatar

lhl ichord

  • Anywhere the Internet is
View GitHub Profile
@ichord
ichord / distance_between.js
Last active October 29, 2019 04:32
Calculate the distance of two geo points.
function distanceBetween(startPoint, endPoint) {
console.log(startPoint, endPoint)
let earthRadius = 6371.0
let startRadians = [
startPoint.latitude * Math.PI / 180,
startPoint.longitude * Math.PI / 180
]
let endRadians = [
endPoint.latitude * Math.PI / 180,
@ichord
ichord / gist:9808444
Created March 27, 2014 14:12
demo of using pdf.js to extract pages to images
<script src="http://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing-api.min.js"></script><html>
<!--
Created using jsbin.com
Source can be edited via http://jsbin.com/pdfjs-helloworld-v2/8598/edit
-->
<body>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
<input id='pdf' type='file'/>
<!-- Use latest PDF.js build from Github -->
@ichord
ichord / Decorator.coffee
Created January 8, 2013 03:24
javascript Decorator pattern.
class Demo
@filter: (func, args...) ->
console.log "hello"
(args...) ->
console.log this, "before filter", args
re = func.apply(this, args)
console.log "after filter", re.hi "ahahahha"
constructor: ->
@ichord
ichord / gist:4467901
Last active December 10, 2015 17:28 — forked from lucasfais/gist:1207002

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@ichord
ichord / gist:3037054
Created July 3, 2012 02:01
decorator for django oauth2app authencation
#-*- coding: utf-8 -*-
from oauth2app.models import AccessRange
from oauth2app.authenticate import JSONAuthenticator, AuthenticationException
import functools
def decorator(decorator):
def func_wrapper(func):
def functor(*args, **kw):
functools.wraps(func)(decorator)
@ichord
ichord / speedMouseUp.sh
Created June 23, 2012 11:49
thinkpad i61 seep up trackpoint
echo -n 250 > /sys/devices/platform/i8042/serio1/sensitivity
echo -n 120 > /sys/devices/platform/i8042/serio1/speed
@ichord
ichord / gist:2786290
Created May 25, 2012 06:59
SAE storage for Django
# -*- coding: utf-8 -*-
import os, time, random
from django.core.files.base import File
from django.core.files.storage import Storage
from django.conf import settings
from django.core.files import File
import sae.storage
try:
from cStringIO import StringIO
except ImportError: