Skip to content

Instantly share code, notes, and snippets.

View clarle's full-sized avatar

Clarence Leung clarle

  • Netflix
  • Los Gatos, CA
  • 06:25 (UTC -07:00)
  • X @clarler
View GitHub Profile
@clarle
clarle / app.js
Created July 26, 2012 07:35
Short tutorial on how to use Express and node-mysql
// Module dependencies
var express = require('express'),
mysql = require('mysql');
// Application initialization
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
@clarle
clarle / keybase.md
Last active September 19, 2019 19:12

Keybase proof

I hereby claim:

  • I am clarle on github.
  • I am clarle (https://keybase.io/clarle) on keybase.
  • I have a public key ASAh6aiLWK3_56wuoAALnjzZykl57rHw4osXrK4yYTmG4wo

To claim this, I am signing this object:

@clarle
clarle / hour_summary.R
Last active September 14, 2018 21:50
Summing hours in HH:MM:SS format in R
library(dplyr)
library(tidyr)
library(lubridate)
# Parse data from HH:MM:SS format into something that can be used by `lubridate`
hours %>%
separate(Duration, into = c("hours", "minutes", "seconds"), sep = ":", convert = TRUE) %>%
summarize(total_time = duration(hour = sum(hours), minute = sum(minutes), second = sum(seconds)))
@clarle
clarle / denoising.ipynb
Last active August 18, 2018 18:54
Image Denoising with OpenCV
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@clarle
clarle / align_images_masked.py
Created March 2, 2018 00:49 — forked from anonymous/align_images_masked.py
Patched alignment and merging scripts including the option for masking via the detected face points, seamless clone and erosion and blurring of the masks.
import argparse
import cv2
import dlib
import json
import numpy
import skimage
from pathlib import Path
from tqdm import tqdm
from umeyama import umeyama
@clarle
clarle / pedestrian.py
Created June 23, 2017 03:40
Pedestrian Detection
%matplotlib inline
import numpy as np
import cv2
import imutils
from matplotlib import pyplot as plt
from imutils.object_detection import non_max_suppression
hog = cv2.HOGDescriptor()
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
@clarle
clarle / app.js
Created October 24, 2015 16:06
Target API data fetching with Express and Request
var _ = require('lodash'),
express = require('express'),
request = require('request'),
app = express();
var API_KEY = '1Kfdqvy6wHmvJ4LDyAVOl7saCBoKHcSb';
app.get('/products/:id', function(req, res) {
var ourData = {
age_group: '0-1 years old',
@clarle
clarle / gene_reader.py
Created June 15, 2012 01:28
Gets unspliced gene data from Wormbase REST API, given a CSV file.
import csv
import requests
import bs4 as bs
def wormbase_url(gene_id):
"""
Return the correct REST API URL, given the gene ID.
"""
url = "http://www.wormbase.org/rest/widget/cds/" + gene_id + "/sequences"
return url
@clarle
clarle / SignupViewModel.m
Created August 7, 2016 17:42
Sign up a user with a unique username in Firebase
- (void)signUpUser:(NSString *)username password:(NSString *)password email:(NSString *)email completion:(void (^)(FIRUser *user, NSError *error))completion {
[[FIRAuth auth]
createUserWithEmail:email
password:password
completion:^(FIRUser *user, NSError *error) {
FIRDatabaseReference *ref = [[FIRDatabase database] reference];
FIRDatabaseReference *userRef = [[ref child:@"users"] child:username];
[userRef observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
if (snapshot && snapshot.value[@"uid"] == nil) {
[userRef setValue:user.uid forKey:@"uid"];
@clarle
clarle / simulate.py
Created June 29, 2016 13:17
Generate simulated phylogenetic data using DendroPy
import dendropy
from dendropy.simulate import treesim
from dendropy.model.discrete import Hky85, simulate_discrete_char_dataset
# Generate a simulated tree
taxa = dendropy.TaxonNamespace(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
tree_model = treesim.birth_death_tree(birth_rate=1.0, death_rate=0.5, taxon_namespace=taxa)
# Use the HKY85 model for character mutation
seq_model = Hky85()