Skip to content

Instantly share code, notes, and snippets.

View nobuyo's full-sized avatar
😶‍🌫️

Nobuo Takizawa nobuyo

😶‍🌫️
View GitHub Profile
@nobuyo
nobuyo / index.html
Created January 20, 2019 12:07 — forked from minikomi/index.html
Japan geojson - albers
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v2.min.js?2.10.0"></script>
<script>
var width = 960,
height = 700;
var svg = d3.select("body").append("svg")
@nobuyo
nobuyo / model.rb
Created February 14, 2018 18:09
monkey-patch for AMS::Model supports update instance attributes
module ActiveModelSerializers
class Model
def update(attrs = {})
attrs.each do |k, v|
instance_variable_set("@#{k}", v) unless (k.nil? && v.nil?)
end
self
end
end
@nobuyo
nobuyo / aggregations.rb
Created February 14, 2018 18:06
monkey-patch for rails/aggregations support Hash
module ActiveRecord
module Aggregations
module ClassMethods
private
def reader_method(name, class_name, mapping, allow_nil, constructor)
define_method(name) do
if @aggregation_cache[name].nil? && (!allow_nil || mapping.any? { |key, _| !_read_attribute(key).nil? })
attrs = mapping.collect { |key, val| [val, _read_attribute(key)] }
require 'test/unit'
class ReportFormat
file = ARGV[0]
raise ArgumentError, 'wrong number of arguments (expected 1)' if file.nil?
@@text = File.read(file).gsub!(/%.*$/,"")#s.split("\n")
# p @@text
def self.get_labels
@@text.scan(/label[={]([^,\}\]]*)/).flatten.sort.uniq
end
@nobuyo
nobuyo / pt2em.sh
Last active September 23, 2016 03:39
change the way to specify html font size(pt => em)
#!/bin/sh
file="index.html"
fontsize="14"
ptlist="$(cat $file | grep "pt" | sed -e 's/pt/@\n/g' -e 's/\s/\n/g' \|
cut -d":" -f2 | grep '@' | tr -d '@' | tr -d ' ' | sort | uniq)"
for pt in $ptlist; do
em="$(echo "scale=4; $pt * 4 / 3 / $fontsize" | bc)"
echo "$pt => $em"
@nobuyo
nobuyo / cal.rb
Last active July 7, 2016 02:44
My Calendar App
require 'date'
require 'sinatra'
require 'holiday_jp'
set :environment, :production
module HolidayJp
def self.next_holiday(day)
HOLIDAYS.find do |date, holiday|
day < date
@nobuyo
nobuyo / picnic
Last active April 17, 2016 01:01
rootless Git deployer
#!/bin/bash
#
# picnic - deploy git without sudo/root
#
INSTALL_DIR=${INSTALL_DIR:-"$HOME/picnic-tools"}
WORK_SPACE=${WORK_SPACE:-"/tmp/picnic"}
LOGFILE="$WORK_SPACE/install.log"
function warn {
@nobuyo
nobuyo / bookmarklet.md
Last active April 24, 2018 19:05
my bookmarklets

Instagram Image Get

open images (latest 10)

at the index page(you must log in)

javascript:var%20img%20=%20document.querySelectorAll(%22main%20article%20div%20img%22);for%20(var%20i%20=%200;%20i%20<%2010;%20i++)%20{window.open(img[i].src);}
@nobuyo
nobuyo / gitch.sh
Last active January 11, 2016 10:09
GitHub push protocol switcher
#/bin/env bash
# git remote repo ssh/http switcher
function warn {
# color:yellow
echo -e "\033[33mWarning:\033[m" "$*"
}
function error {
# color:red
@nobuyo
nobuyo / ReportEnvironmentInitializer
Last active August 29, 2015 14:24
Create an Environment for writing a report with LaTeX (on Cygwin)
#! /bin/bash
# =UPDATE HISTRY=
# 9 July, 2015 : New
# 12 July, 2015 : fix Makefile Form
function usage {
echo ""
echo 'The Report Environment Initialize Script'
echo 'Usage : [./Program name <Directory name>]'