Skip to content

Instantly share code, notes, and snippets.

View bigeyex's full-sized avatar

Yu Wang bigeyex

  • ByteDance
  • Beijing, China
View GitHub Profile
@bigeyex
bigeyex / gist:6400686
Created August 31, 2013 21:18
PHP Script Useful for making forms: according to POST contents, insert a record into db, create the table if not exist.
<?php
//settings
define('DB_NAME', ''); //db name
define('DB_USER', 'root');
define('DB_PWD', '');
define('TABLE_NAME', '');
define('IP_FIELD', 'ip'); // the field for visitor's ip address
@bigeyex
bigeyex / police_log_scraper.py
Last active August 29, 2015 13:59
scrape cambridge police logs. Can be called multiple times to update the database.
# coding: utf-8
#!/usr/bin/python
import requests
import re
import sqlite3
from bs4 import BeautifulSoup
def has_same_record(source="cambridge", incident_no='', report_time='', report_date=''):
conn = sqlite3.connect('policelog.sqlite')
@bigeyex
bigeyex / finderNewFile.scpt
Last active August 29, 2015 14:00
applescript that create file at opening finder window
on run {input, parameters}
(* Your script goes here *)
tell application "Finder"
make new file at (target of front window as alias)
end tell
end run
///
// usage :
// scrape the list - casperjs scrape_mass_court_decisions.js scrape [the number of starting case]
// fetch the detail record - casperjs scrape_mass_court_decisions.js detail [the number of starting case]
// find the missing items - casperjs scrape_mass_court_decisions.js rinse
var casper = require('casper').create();
//var casper = require('casper').create({
// verbose: true,
@bigeyex
bigeyex / gist:dd5b75049e26ddb68f19
Created July 12, 2014 20:30
simple web audio real-time data logging
<!DOCTYPE html>
<html>
<head>
<title>Audio jack</title>
</head>
<body>
<script>
if (!navigator.getUserMedia)
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
@bigeyex
bigeyex / dispatcher.js
Created August 1, 2014 21:04
broadcast and receive global events in javascript
/*
Dispatcher module
by: wangyu (bigeyex@gmail.com)
dispatch global event
usage:
- fire an event:
dispatcher.dispatch('example.event.name', arg1, arg2...)
- subscribe an event:
dispatcher.subscribe('example.event.name', function(arg1, arg2...){});
@bigeyex
bigeyex / JSRequire.js
Created August 1, 2014 21:05
manage javascript dependancies
/*
JSRequire module
by: wangyu (bigeyex@gmail.com)
manage javascript dependancies.
usage:
jsrequire(['one.js', 'two.js'], function(){
// code after one.js and two.js loaded...
});
*/
@bigeyex
bigeyex / UIImage+Resize.h
Created December 18, 2015 12:35
UIImage+Resize.h - resize UIImages
#import <Foundation/Foundation.h>
@interface UIImage (Resize)
- (UIImage *)resizeTo:(CGSize)newSize;
@end
@bigeyex
bigeyex / UIImage+Tint.h
Created December 18, 2015 12:38
UIImage+Tint: tint an UIImage
#import <Foundation/Foundation.h>
@interface UIImage (Tint)
- (UIImage *)tintedImageWithColor:(UIColor *)tintColor;
@end
@bigeyex
bigeyex / UIColor+HexString.h
Created December 18, 2015 12:40
UIClolor+HexString: Create your UIColor from a "css color code
#import <Foundation/Foundation.h>
@interface UIColor (HexString)
+ (UIColor *) colorFromHexString:(NSString *)hexString;
@end