Skip to content

Instantly share code, notes, and snippets.

View cognitom's full-sized avatar

Tsutomu Kawamura cognitom

View GitHub Profile
@cognitom
cognitom / no-more-auto-rotate.sh
Created February 12, 2014 07:52
No more Auto-Rotate & Scale in Preview
defaults write com.apple.Preview PVImagePrintingAutoRotate 0
@cognitom
cognitom / h26tochijisen.csv
Created February 9, 2014 17:36
東京都知事選市区町村別得票データ (暫定) - 2014年2月
市区町村 ますぞえ 要一 宇都宮 けんじ 細川 護熙 田母神 としお 家入 かずま ドクター・中松
千代田区 9106 3303 5054 4082 499 373
中央区 23161 8430 11130 8980 1527 872
港区 34808 12968 19792 12738 2515 1073
新宿区 47568 23910 23949 17484 2928 1528
文京区 35767 19094 19416 12683 2092 1294
台東区 30465 12873 13654 10603 1466 1137
墨田区 43318 16661 15805 12785 1683 1400
江東区 85994 34553 30676 24372 3238 2733
品川区 61078 27925 27334 20133 3297 2052
@cognitom
cognitom / number_format.coffee
Created July 26, 2013 16:14
Format numbers with comma.
numberFormat = (n) ->s = n + ''; s = s.replace(/(\d+)(\d{3})$/, '$1,$2') while /(\d+)(\d{3})$/.test s; s
numberFormat2 = (n) -> (n + '').replace /(\d+)(\d{3})?(\d{3})?(\d{3})?(\d{3})?(\d{3})$/, (match...) -> (match[p] + '' for p in [1..6] when match[p]).join ','
numberFormat3 = (n) -> (n = '00' + n).substr(n.length % 3).match(/\d{3}/g).reduce((x,y) -> x + ',' + y if y).replace /^0*/, ''
numberFormat4 = (n) -> (n + '').split('').reduceRight (x, y) -> if (x.length + 1) % 4 then y + x else y + ',' + x
# usage
s = numberFormat4 1234567 # "1,234,567"
var MyNamespace = {};
MyNamespace.Person = function(){
/* Public Fields */
this.name = '';
this.sex = 'M';
/* Private Fields */
var _age = 0;
/* Constructor */
this.initialize = function(name, sex, age){
@cognitom
cognitom / gist:5500409
Created May 2, 2013 06:00
サイト全体をダウンロードして、相対パスに書き換える。ローカルでも表示可能。
wget -m -k -K -E http://url/of/web/site
var widget;widget={server:"http://librize.com",root:"https://raw.github.com/librize/widgets/master",default_params:{},style_loaded:{},addStyle:function(a){return $("head").append('<link rel="stylesheet" type="text/css" href="'+a+'" />')},getQueryParams:function(a){var b,c,d,e,f,g,h,i;d={};h=a.replace(/^.*\?/,"").split("&");for(f=0,g=h.length;f<g;f++){c=h[f];i=c.split("="),b=i[0],e=i[1];d[b]=e}return d},getDefaultParams:function(a){var b;b=this.getQueryParams(a);return this.default_params={place:b.place||void 0,limit:b.limit||5,height:b.height||75,width:b.width||0,theme:b.theme||"simple"}},show:function(a){var b,c,d,e,f,g,h=this;d=a.attr("data-place")||this.default_params.place;c=a.attr("data-limit")||this.default_params.limit;b=a.attr("data-height")||this.default_params.height;g=a.attr("data-width")||this.default_params.width;e=a.attr("data-theme")||this.default_params.theme;if(d){(this.style_loaded[e]==null?e!=="none":void 0)&&this.addStyle(""+widget.root+"/css/"+e+".css");this.style_loaded[e]=!0;f=""+widget
@cognitom
cognitom / getfeed.js
Created May 26, 2012 09:24
Retrieve Facebook page feed from jQuery
$(function(){
var fbpage_id = 131130253626713;// change to your facebook page id.
var fbpage_feed = 'https://www.facebook.com/feeds/page.php?format=atom10&id=' + fbpage_id;
var feed_api = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=' + encodeURIComponent(fbpage_feed);
$.getJSON(feed_api + '&callback=?', function(data){
$(data.responseData.feed.entries).each(function(index){
$('ul#update-feed').append($('<li />', {
'data-role': "list-divider"
}).append($('<a />', {
'href': this.link,
@cognitom
cognitom / not-pass.html
Created April 25, 2012 18:42
Safari doesn't say "PASS"
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.js"></script>
</head>
<body>
<script>
url = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://www.engadget.com/rss.xml&callback=?';
$.getJSON(url, function(){
alert('PASS');
@cognitom
cognitom / level1-challenge5.lolcode
Created April 1, 2012 05:06
LEVEL 1 CHALLENGE 5
HAI
I HAS A ANIMAL
GIMMEH ANIMAL
BOTH SAEM ANIMAL AN "CAT", O RLY?
YA RLY
VISIBLE "U HAS KITTEH"
NO WAI
VISIBLE "KITTEH R 2 GUD 4 U"
OIC
@cognitom
cognitom / gist:2192416
Created March 25, 2012 08:41
Syntax check multiple PHP files in the current directory
find . -name \*.php -exec php -l "{}" \;