Skip to content

Instantly share code, notes, and snippets.

View cognitom's full-sized avatar

Tsutomu Kawamura cognitom

View GitHub Profile
@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,
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 / gist:5500409
Created May 2, 2013 06:00
サイト全体をダウンロードして、相対パスに書き換える。ローカルでも表示可能。
wget -m -k -K -E http://url/of/web/site
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 / 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"
@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 / 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 / gist:9022088
Last active August 29, 2015 13:56
Use gulpfile.coffee as default in Mac OS X environment
echo "alias gulp='gulp --require coffee-script/register'" >> ~/.profile
@cognitom
cognitom / gulpfile.coffee
Created May 10, 2014 07:47
gulpfile example to integrate with Rails
gulp = require 'gulp'
π = plugins = (require 'gulp-load-plugins')()
# Directories
CSSDIR = './app/assets/stylesheets'
JSDIR = './app/assets/javascripts'
FONTDIR = './app/assets/fonts'
# CSS
gulp.task 'css', ->
@cognitom
cognitom / file0.txt
Last active August 29, 2015 14:01
VagrantでゲストOSに直接コマンドを送る ref: http://qiita.com/cognitom/items/fc94a16c9cb53e6f7f75
$ vagrant ssh -c ifconfig