Skip to content

Instantly share code, notes, and snippets.

View LeiHao0's full-sized avatar
😃
I may be slow to respond.

Lei Hao LeiHao0

😃
I may be slow to respond.
View GitHub Profile
@LeiHao0
LeiHao0 / gist:7a28b60e020c1a204275
Last active August 29, 2015 14:06
A Simple Pedometer
We couldn’t find that file to show.
@LeiHao0
LeiHao0 / AnalyzeGoogleCalender
Last active August 29, 2015 14:06
AnalyzeGoogleCalender
# python 3.x
import datetime, os, glob
class Event():
def __init__(self, text):
self.text = text
self.summary = self.getSummary()
self.duration = self.getDuration()
def getSummary(self):
// Playground - noun: a place where people can play
import UIKit
class Hummingbird {
var name: String
init (name:String) {
self.name = name
}
@LeiHao0
LeiHao0 / Node.m
Created September 20, 2014 12:33
//
// Node.m
// XML
//
// Created by artwalk on 9/16/14.
// Copyright (c) 2014 artwalk. All rights reserved.
//
#import "Node.h"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
@LeiHao0
LeiHao0 / ExchangeNames
Created July 15, 2015 08:31
exchange people's First and Last Name in Mac OSX Contacts
import AddressBook
let addressBook = ABAddressBook.sharedAddressBook()
let firstKey = "First"
let lastKey = "Last"
for people in addressBook.people() {
if let p = people as? ABPerson {
let f: AnyObject? = p.valueForKey(firstKey)
@LeiHao0
LeiHao0 / GetAllImagesUrl
Created December 11, 2015 08:10
get All Images Url of a webpage
var list=[];
var a=document.getElementsByTagName('img');
for (var i=0,l=a.length;i<l;i++)
{
if (/\.(jpg|gif|png|jpeg)$/im.test(a[i].getAttribute('src')))
{
list.push(a[i].getAttribute('src'));
}
}
@LeiHao0
LeiHao0 / FlooNetworkRequestGenerator
Last active December 21, 2015 04:29
Auto Generator FlooNetwork Request
$url = "api/show"
$prefix = "TF"
def className
refineStr = $url.gsub("api", '')
a , b = refineStr.split('/')
return $prefix + a.capitalize + b.capitalize
end
@LeiHao0
LeiHao0 / init.sh
Last active November 28, 2017 15:37
UpdateBrewDaily
ln -s $Path/AutoUpdateBrew/launchd.plist ~/Library/LaunchAgents/sh.brew.update
launchctl load ~/Library/LaunchAgents/sh.brew.update
@LeiHao0
LeiHao0 / DuplicateFiles.rb
Created April 20, 2016 03:29
Find duplicate Files (file < 4G)
#!/usr/bin/env ruby
# Usage
# ruby DumpFiles.rb ~/$DirPath
require 'digest/md5'
require 'find'
path = ARGV[0]
path = './' if !path