Skip to content

Instantly share code, notes, and snippets.

View qhwa's full-sized avatar

Qiu Hua qhwa

View GitHub Profile
@qhwa
qhwa / flatten.rb
Last active October 7, 2015 15:39
implementation of Array#flatten in ruby
# implementation of Array#flatten with ruby
def flatten arr
return arr unless arr.is_a? Array
arr.reduce([]) do |out, item|
out.push *flatten(item)
end
end
@qhwa
qhwa / auto_dnspod.rb
Created May 26, 2015 06:49
automatically update DNSPod record with internal IP address
#!/usr/bin/env ruby
require 'socket'
require 'net/http'
require 'net/https'
require 'open-uri'
require 'logger'
class AutoDNS
PARAMS = {
@qhwa
qhwa / httparty.rb
Last active October 7, 2022 01:46
log and record HTTParty request time in Rails
# file: config/initialize/httparty.rb
require 'httparty'
module HTTParty
class Request
alias_method :_original_perform, :perform
def perform(&block)
payload = {
method: http_method.const_get(:METHOD),
url: uri
@qhwa
qhwa / .vimrc
Created February 2, 2015 02:36
my vim config
fun! MySys()
return "mac"
endfun
set runtimepath=~/.vim_runtime,~/.vim_runtime/after,\$VIMRUNTIME
source ~/.vim_runtime/vimrc
"helptags ~/.vim_runtime/doc
set guifont=Lucida\ Sans\ Typewriter\ Regular:h13
if has("gui_running")
set guioptions-=T
set t_Co=256
package com.alibaba.ad.vas.example
{
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import flash.system.*;
import com.alibaba.ad.vas.toolkit.AdManager;
import com.alibaba.ad.vas.vast.model.AdUnit;
@qhwa
qhwa / Main.as
Created May 27, 2014 08:16
VAST SDK Usage Example
/**
* Basic AS3 VAST OVA Video Player Example
* Released as open source under the BSD License
* http://www.opensource.org/licenses/bsd-license.php
*
* hua.qiuh copied from dehash.com
*/
package {
import com.apdevblog.events.video.VideoControlsEvent;
@qhwa
qhwa / from-now-filter.coffee
Created May 8, 2014 02:06
angularjs filter of display time as 'xxx ago'
angular.module('fromNowFilter',[]).filter 'from_now', () ->
(date) ->
moment(date).fromNow()
@qhwa
qhwa / linksprite_jpeg_camera.rb
Created March 18, 2014 15:28
ruby script that grab pictures from LinkSprite TTL JPEG camera
require 'serialport'
require 'colored'
require 'ruby-progressbar'
class Y201Grab
def self.a2s(*arr)
arr.pack 'c*'
end
@qhwa
qhwa / texts.svg
Created July 16, 2013 05:56
SVG samples
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@qhwa
qhwa / 统计
Last active December 15, 2015 16:29
威客名单
3.11-4.1