Skip to content

Instantly share code, notes, and snippets.

View todokr's full-sized avatar
😻
Focusing

Shunsuke Tadokoro todokr

😻
Focusing
View GitHub Profile
@todokr
todokr / gulpfile.coffee
Created July 7, 2015 13:53
gulpfile (CoffeeScript)
gulp = require 'gulp'
sass = require 'gulp-sass'
uglify = require 'gulp-uglify'
minifyCss = require 'gulp-minify-css'
concat = require 'gulp-concat'
watch = require 'gulp-watch'
webserver = require 'gulp-webserver'
runSequence = require 'run-sequence'
gulp.task 'uglify', ->
@todokr
todokr / clear_favicon_cache_chrome.rb
Last active August 29, 2015 14:27
Clear favicon cache of localhost (Google Chrome v.44.0)
require 'sqlite3'
favicon_path = File.join(ENV['HOME'], '/Library/Application Support/Google/Chrome/Default/Favicons')
db = SQLite3::Database.new favicon_path
begin
command = "delete from favicons where url like '%localhost%'"
db.execute(command)
p "Done: #{command}"
rescue SQLite3::BusyException => ex
@todokr
todokr / Play2_serialize_char.scala
Last active November 10, 2015 05:50
Play2/Scala JSON Serialize for Char type
class HogeController {
implicit var charFormat = new Writes[Char] {
def writes(c: Char): JsString = JsString(String.valueOf(c))
}
}
@todokr
todokr / gist:5462873
Created April 25, 2013 20:28
VIのJS
(function($){
//フェードロールオ−バー
$(function(){
$("img.roll").imgOvAnime();
});
$.fn.imgOvAnime = function(option){
var o = $.extend({
ovStr: "_o",
speed: 300,
type: "fade"
@todokr
todokr / ssh-color.sh
Last active April 19, 2016 09:18
本番環境とかでiTermの文字や背景色を切り替える
#!/bin/bash
# 1. Save as ~/bin/ssh-color
# 2. chmod 755 ~/bin/ssh-color
# 3. alias ssh='~/bin/ssh-color'
# 4. change host name
# 5. ssh {your host name}
set_color() {
local hex_fg=$1
local hex_bg=$2
@todokr
todokr / HjsonSample.scala
Last active April 23, 2016 15:30
hjson-javaをScalaから利用するサンプル
package io.ShunsukeTadokoro
import org.hjson._
import play.api.libs.json.Json
object HjsonSample {
def main(args: Array[String]) {
val hjson =
import java.io.File
import com.github.tototoshi.csv.CSVWriter
object Mojibake extends App {
val f = new File("./mojibake-patterns.csv")
val writer = CSVWriter.open(f)
val targetString = "入れ替わってる〜!?"
val encodings = List("UTF-8", "EUC_JP", "Shift-JIS", "ISO-2022-JP")
@todokr
todokr / scalaz-disjunction.scala
Created November 30, 2016 01:01 — forked from manjuraj/scalaz-disjunction.scala
scalaz disjunction
//
// Disjunction - aka Scalaz Either
// \/[A, B] is an alternative to Either[A, B]
// -\/ is Left (usually represents failure by convention)
// \/- is Right (usually represents success by convention)
// Left or Right - which side of the Disjunction does the "-" appear?
//
// Prefer infix notation to express Disjunction Type v: String \/ Double
//
// References
@todokr
todokr / scalaz-validation.scala
Created November 30, 2016 01:03 — forked from manjuraj/scalaz-validation.scala
scalaz validation
//
// Validation[E, A] represents either:
// - Success[A]
// - Failure[E]
//
// Isomporphic to scala.Either[E, A] and scalaz.\/[E, A]
//
// Unlike \/[E, A], Validation is not a Monad, but an Applicative
// Functor. So if you want to use it as a Monad you can convert back
// and forth using the `validation` and `disjunction` method
"👨‍👩‍👧‍👧".replace("👩","👨");