Skip to content

Instantly share code, notes, and snippets.

#! /bin/sh
xcode-select --install
brew install php@5.6 postgresql@9.4 brew-php-switcher libmemcached
brew link --force php@5.6
brew link --force postgresql@9.4
#
@wtnabe
wtnabe / csv_encode.php
Last active November 17, 2017 20:40
csv_encode.php
<?php
/**
* @param object $obj ( may be array )
* @return mixed string or null
*/
function csv_encode($obj)
{
$csv = null;
$rows = is_object($obj) ? json_decode(json_encode($obj), true) : $obj;
@wtnabe
wtnabe / CacheInitiator.php
Last active November 11, 2017 13:00
Laravel Cache Initiator ( mainly for auth requiring Memcached server )
<?php
class CacheInitiator
{
static function run()
{
$initializer = "init".ucfirst(strtolower(Cache::getDefaultDriver()));
$self = new CacheInitiator();
if ( method_exists($self, $initializer) ) {
@wtnabe
wtnabe / weinre.py
Last active April 19, 2017 15:48
mitmproxy script for injecting script tag for loading weinre
import argparse
class Weinrer:
def __init__(self, host, port):
self.host = host
self.port = port
def response(self, flow):
text = flow.response.text
@wtnabe
wtnabe / collect-screen-sizes.rb
Last active December 14, 2016 09:04
Google Analyticsの画面の解像度とセッションのデータだけ抜き出したCSVを正規化して返す
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# Usage:
# cat src.csv | ruby collect-screen-sizes.rb > dest.csv
#
require 'csv'
class NotExpectedHeaders < RuntimeError; end
@wtnabe
wtnabe / jquery-deferred-and-es2015-promise.md
Last active May 27, 2018 16:56
trial and comparison between jQuery.deferred and es6 Promise object

Promise試してみた

jQuery.deferred

jQuery.deferred で実験。fail() は jQuery 用語で、ES2015 だと catch() になる。

1) 単純な成否

$.getJSON('/api1')
@wtnabe
wtnabe / from-jekyll-document.rb
Last active May 5, 2016 14:04
Jekyll drafts
# Returns whether the document is a draft. This is only the case if
# the document is in the 'posts' collection but in a different
# directory than '_posts'.
#
# Returns whether the document is a draft.
def draft?
data['draft'] ||= relative_path.index(collection.relative_directory).nil? && collection.label == "posts"
end
@wtnabe
wtnabe / meetup-45-circleci-hands-on.md
Last active May 1, 2016 00:56
Kanazawa.rb meetup #45 CircleCI Hands-on program
@wtnabe
wtnabe / Rakefile
Created April 17, 2016 14:09
pickup latest todomvc vanillajs app's code
# -*- mode: ruby -*-
desc 'latest-todomvc-vanilla'
task 'latest-todomvc-vanilla' => ['clean:dest', 'todomvc:fetch'] do
sh <<EOD
cd #{File.join(todomvc_dir, 'examples')}
git ls-files vanillajs | cpio -pud ../../
EOD
end
@wtnabe
wtnabe / package.json
Created March 9, 2016 12:35
npm development environment with browserify and babelify
{
"dependencies": {
"babelify": "^7.2.0",
"browserify": "^13.0.0",
"licensify": "^2.2.0",
"uglifyjs": "^2.4.10"
},
"devDependencies": {
"watchify": "^3.7.0"
},