Skip to content

Instantly share code, notes, and snippets.

View fnobi's full-sized avatar
🏠
Working from home

Shin Fujisawa fnobi

🏠
Working from home
View GitHub Profile
@fnobi
fnobi / file0.txt
Created June 12, 2013 08:40
gaで任意のURLへのアクセスを記録 ref: http://qiita.com/items/354060051911f48d3bff
// ga登録
ga('create', 'UA-XXXX-Y');
// 現在のページへのアクセスを記録
ga('send', 'pageview');
// ページのURLをカスタムしてアクセスを記録
ga('send', 'pageview', '/toppage');
// clickがあったときにアクセスを記録
@fnobi
fnobi / file0.txt
Created June 5, 2013 16:39
Coffeeか、Typeか。 〜比較しながらの入門編〜 ref: http://qiita.com/items/8bd24c0994a2015ffbeb
npm -g install typescript
@fnobi
fnobi / file0.txt
Created May 25, 2013 12:12
nginx + foreverで、Webアプリ管理らくらく ref: http://qiita.com/items/6a1688e74da3789025da
location / {
proxy_pass http://hogehoge;
allow all;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

@fnobi
fnobi / file0.txt
Last active December 16, 2015 19:59
node.jsでこんなのもテストしたい!! という話 ref: http://qiita.com/fnobi/items/14c9f298d88fc2a2e53d
// テストしたいmoduleをrequire
var hoge = require('../hoge');
// テスト用のライブラリをrequire (mochaの場合は、shouldがあればいいはず)
var should = require('should');
// あとはテストを書くのみ
describe('hoge', function () {
it('足し算をする', function () {
hoge.add(2, 3).should.equal(5);
@fnobi
fnobi / file0.txt
Created April 24, 2013 12:47
HTMLのカラーコードから、明度を出した話 ref: http://qiita.com/items/d3464ba0e4b6596863cb
var rgb = [128, 30, 200]; // R=128, G=30, B=200
// 0〜255の値が入っているので、255で割っておく
var blightness = Math.max(rgb[0], rgb[1], rgb[2]) / 255;
@fnobi
fnobi / Gruntfile.js
Created April 16, 2013 14:48
grunt-pluginの作り方と解剖 ref: http://qiita.com/items/5590e7e92b4f2bd81d04
var grant = require('grunt');
module.exports = function () {
grunt.initConfig({
sample: {
dev: { // 開発環境
hoge: 'hogehoge'
},
prod: { // 本番環境
hoge: 'moge'
@fnobi
fnobi / .bashrc
Created February 11, 2013 15:40
terminalを棄ててEmacsと心中するための設定 ref: http://qiita.com/items/8906c8e7759751d32b6b
## create emacs env file
perl -wle \
'do { print qq/(setenv "$_" "$ENV{$_}")/ if exists $ENV{$_} } for @ARGV' \
PATH > ~/.emacs.d/shellenv.el
@fnobi
fnobi / Gemfile
Created February 6, 2013 09:55
RedmineをApacheのproxy_pass使って公開するまで ref: http://qiita.com/items/3bcdb59ab362923e640f
gem 'rails', '3.2.11'
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
gem "unicorn" # 追加
@fnobi
fnobi / watchfile.js
Created January 2, 2013 17:33
fs.watchFileを使ってみた ref: http://qiita.com/items/b4588b2b37fe7136383d
var fs = require('fs');
var filepath = 'message.txt';
// filepathが存在しなくても、watchFileはエラーとか出してくれないので、
// 先にfs.existsで調べておく
if (!fs.existsSync(filepath)) {
console.error('%s doesn\'t exist.', filepath);
process.exit();
}
@fnobi
fnobi / perlでlexer
Created December 13, 2012 07:16
string周りとか不完全だけど。
use strict;
# コマンドライン引数を、sourcecodeとする
my $sourcecode = $ARGV[0];
my $char;
my $stack = "";
my @tokens = [];
# sourcecodeを一文字ずつ見る