Skip to content

Instantly share code, notes, and snippets.

View tkfm-yamaguchi's full-sized avatar

Takafumi Yamaguchi tkfm-yamaguchi

View GitHub Profile
@tkfm-yamaguchi
tkfm-yamaguchi / pathname.py
Last active December 28, 2015 00:09
ruby like pathname class for python
# coding: utf-8
import os
from os import path
import re
import shutil
from itertools import chain
DEFAULT_SEPARATOR = "/"
get %r|^/github(/.+\.js)$| do
require 'net/https'
uri = params[:captures].first
js = ""
github = Net::HTTP.new("raw.github.com", 443)
github.use_ssl = true # do not forget this to access with HTTPS protocol
github.start do
## XXX: verify the http response status
@tkfm-yamaguchi
tkfm-yamaguchi / fix_original_image_size_ acquisition_for_webkits.patch
Created November 17, 2013 21:19
Original : rwdImageMaps jQuery plugin v1.5 Chrome/Safari (webkit) で画像のロードに遅延が発生した場合など、画像のオリジナルサイズが正しく取得できないことがあったのを修正
--- pre.rwdImageMaps.js 2013-11-18 05:54:45.588799920 +0900
+++ post.rwdImageMaps.js 2013-11-18 05:53:19.692799931 +0900
@@ -37,6 +37,14 @@
h = temp.height;
}
+ // To get the natural width and height on Webkit, just use this.(width/height)
+ if (!w || !h) {
+ if (!w)
+ w = this.width;
require "rubygems"
require "middleman-core/load_paths"
Middleman.setup_load_paths
require "middleman-core"
require "middleman-core/preview_server"
module Middleman::PreviewServer
def self.preview_in_rack
require 'rack'
# Because String#each has taken away since RUBY_VERSION >= 1.9,
# Rack::BodyProxy#each causes error ( and when 'use Rakc::CommonLogger' ).
# This is the monkey patch to fix it.
class String
def each(*args, &block)
each_line *args, &block
end
end
diff --git a/autoload/unite/sources/outline/defaults/ruby.vim b/autoload/unite/sources/outline/defaults/ruby.vim
index eb53c82..116bf81 100644
--- a/autoload/unite/sources/outline/defaults/ruby.vim
+++ b/autoload/unite/sources/outline/defaults/ruby.vim
@@ -19,6 +19,9 @@ function! unite#sources#outline#defaults#ruby#outline_info(...)
if path =~ '_spec\.rb$'
" RSpec
return 'ruby/rspec'
+ elseif path =~ 'Rakefile$' || path =~ '\.rake$'
+ " Rake
# coding: utf-8
require 'htmlentities'
coder = HTMLEntities.new
p coder.encode('Φ', :named) #=> 'Φ'
p coder.decode('φ') #=> 'φ'
###
# $ coffee -c loop.coffee ; nodejs loop.js
###
measure = (title, f) ->
begin = new Date()
f()
console.log "#{title}: #{(new Date() - begin)}"
times = 10000000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>closure pattern</title>
</head>
<body>
<div id="target1">
<h1>Target 1</h1>
</div>
@tkfm-yamaguchi
tkfm-yamaguchi / btsrp-gmap-fix.scss
Created January 6, 2014 10:37
Bootstrap(2.3) makes Google Map(v3)'s controller skinny
// http://stackoverflow.com/questions/9141249/twitter-bootstrap-css-affecting-google-maps
// Below fixes Bootstrap(2.3)'s affection to Google Map V3's control which would be skinny looks.
// '#map' is a container of Google Map.
#map {
img {
max-width: none;
}
label {
width: auto;