Skip to content

Instantly share code, notes, and snippets.

View g761007's full-sized avatar

Daniel Hsieh g761007

View GitHub Profile
@g761007
g761007 / walk.cpp
Created January 16, 2013 08:41
C++ like python os.walk
#include <vector>
#include <tuple>
#include <boost/filesystem.hpp>
typedef std::tuple<boost::filesystem::path, std::vector<boost::filesystem::path>, std::vector<boost::filesystem::path>> WALK_ITEM;
typedef std::vector<WALK_ITEM> WALK_PATHS;
void display(const WALK_ITEM &item)
{
boost::filesystem::path p(get<0>(item));
@g761007
g761007 / tra.user.js
Last active November 27, 2016 16:56
The UserScript which booking the TRA ticket at the same page.
// ==UserScript==
// @name TRA
// @namespace http://danielhsieh.com/tra
// @description booking the ticket
// @include http://railway.hinet.net/ctkind1.htm
// @include http://railway.hinet.net/ctno1.htm
// @version 1
// @require http://code.jquery.com/jquery-latest.js
// @grant GM_getValue
// @grant GM_setValue
DB.prototype.getCurrentOpStats = function() {
intervals = [1,5,10,30]
waitingForLock = 0;
secsRunningStats = {};
inProg = db.currentOp()["inprog"]
inProg.forEach(function (op) {
if(op["waitingForLock"]) {
waitingForLock += 1;
}
/*!
* dump.js, dump mongodb.
* Copyright(c) 2012 Taobao.com
* Author: busi.hyy <[email protected]>
*
* 每天凌晨3点从mongo dump一份到指定文件夹,前缀为20121113_
* 只保留最近七天的dump文件
* Example: `node dump 127.0.0.1:27071 back database collection1 collection2 ...`
*/
@g761007
g761007 / setup.py
Last active August 29, 2015 14:27
setup.py sample
from setuptools import setup, find_packages
setup(
name='Sample',
version='0.0.0',
description='setup.py sample',
author='Daniel Hsieh',
author_email='[email protected]',
packages = find_packages(),
entry_points = {
@g761007
g761007 / gist:05f6b0100076113a7c7c
Last active August 29, 2015 14:27
Python project structure sample
/sample
/__init__.py
/models
/__init__.py
/users.py
/permissions.py
/views
/__init__.py
/api.py
/core.py
@g761007
g761007 / UIApplication+DisableNetworkActivityIndicatorVisible.m
Created October 21, 2015 03:11
Hacking UIApplication that replace original method 'setNetworkActivityIndicatorVisible' to hidden network activity indicator forever.
/// UIApplication+DisableNetworkActivityIndicatorVisible.h
#import <UIKit/UIKit.h>
@interface UIApplication (DisableNetworkActivityIndicatorVisible)
@end
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
# -*-: coding:utf8 -*-
import os
from StringIO import StringIO
from lxml import etree
import requests
import click
def download_images(url, output_dir='output'):
@g761007
g761007 / uncrustify.cfg
Created December 28, 2015 03:06 — forked from chiahsien/uncrustify.cfg
My Uncrustify config for Objective-C
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.4.3 (252)
#
# Alignment
# ---------
## Alignment