Skip to content

Instantly share code, notes, and snippets.

@ku
ku / json
Created April 18, 2014 11:40
json parser
#!/usr/bin/env node
var json = ''
process.stdin.on('readable', function(chunk) {
var chunk = process.stdin.read();
json += chunk
if (chunk !== null) {
var r = JSON.parse(json)
r = JSON.stringify(r, null, ' ');
console.log(r);
@ku
ku / copen
Last active August 29, 2015 14:02
open circleCI
#!/bin/sh
GIT='git'
if test `uname` = "Darwin" ; then
SED_OPT='-E'
OPEN='open'
else
SED_OPT='-r'
OPEN=''
@ku
ku / gist:1fd091b52123e4b5dd00
Created June 24, 2014 02:21
US top 100 sites(except NSFW)
us_top_100_sites = %w(
http://google.com/ http://facebook.com/ http://youtube.com/ http://yahoo.com/ http://amazon.com/
http://wikipedia.org/ http://linkedin.com/ http://ebay.com/ http://twitter.com/ http://craigslist.org/
http://bing.com/ http://pinterest.com/ http://blogspot.com/ http://live.com/ http://go.com/
http://instagram.com/ http://cnn.com/ http://paypal.com/ http://tumblr.com/ http://reddit.com/
http://imgur.com/ http://espn.go.com/ http://huffingtonpost.com/ http://wordpress.com/ http://netflix.com/
http://yelp.com/ http://msn.com/ http://apple.com/ http://imdb.com/ http://weather.com/
http://aol.com/ http://microsoft.com/ http://chase.com/ http://nytimes.com/ http://bankofamerica.com/
http://godaddy.com/ http://zillow.com/ http://buzzfeed.com/ http://about.com/ http://walmart.com/
http://foxnews.com/ http://secureserver.net/ http://ask.com/ http://wellsfargo.com/
if ($this->posts[0]->tumblr_url) {
header( "Location: " . $this->posts[0]->tumblr_url, true, 301);
exit;
}
}
// Put sticky posts at the top of the posts array
"wp-includes/query.php" 4399 lines --76%--
@ku
ku / ticketmachine
Created October 28, 2014 04:09
ticketmachine
#!/usr/bin/env coffee
#
JiraApi = require('jira').JiraApi
#process = require 'process'
exec = require('child_process').exec
if process.argv.length < 1 + 2
console.log "usage: ticketmachine sumamry [description]"
return 1
[summary, description] = process.argv.slice 2
@ku
ku / gist:84af637e2d9b82ac307b
Created November 7, 2014 08:50
random sqwiggle snapshot changer
require 'sqwiggle-ruby'
require 'net/http'
require 'nokogiri'
require 'uri'
token = 'cli_be6cd40b6ebd25101b3450e34882412b'
flickr_rss = 'https://www.flickr.com/services/feeds/photos_public.gne?id=59591873@N00&lang=en-us'
uri = URI.parse(flickr_rss)
@ku
ku / Gemfile
Last active August 29, 2015 14:09
browserstack automation
source 'https://rubygems.org'
gem 'selenium-webdriver'
@ku
ku / locale2json
Created December 11, 2014 06:18
convert rails locale files into one json
#!/usr/bin/env ruby
#run in RAILS_ROOT directory
require 'json'
require 'yaml'
# http://stackoverflow.com/questions/9381553/ruby-merge-nested-hash
class ::Hash
def deep_merge(second)
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
@ku
ku / swfparser.js
Created October 21, 2008 15:23
swfparser.js
//
// http://gist.github.com/18326
//
// Copyright (c) KUMAGAI Kentaro ku0522a*gmail.com
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
//
@ku
ku / gist:18979
Created October 23, 2008 10:04
gzip deflate
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <zlib.h>
#define BFSIZE (32 * 1024)