Skip to content

Instantly share code, notes, and snippets.

View novogrammer's full-sized avatar

Yusuke Kawamoto novogrammer

View GitHub Profile
#encoding: utf-8
#erbテンプレートをhtmlに変換する
require 'erb'
require 'fileutils'
task :default => [:erb2html,:scss2css]
def Page(partials,erb)
pageBase=Class.new do|klass|
@novogrammer
novogrammer / myserver
Last active August 29, 2015 14:03
サーバーを立てるまでもないけど、絶対パスのhtmlを確認したい時のスクリプト。実行権限をつけて~/binとかに置く。実行時のフォルダをルートにする。要Rubyとsinatra
#!/bin/bash
ruby -rsinatra -e 'set :public_folder, "."'
@novogrammer
novogrammer / mySketch.ino
Last active August 29, 2015 14:14
Arduino IDE inserts forward declaration
/*
#line 1 "mySketch.ino"
*/
#include <SPI.h>
/*
#include "Arduino.h"
void foo(TwoWire bar);
void setup();
void loop();
#line 2
@novogrammer
novogrammer / index.js.coffee
Created May 25, 2015 14:58
jQueryのプラグインを見よう見まねで作ってみた
jQuery ($)->
$(".product .image").myScrollTrigger({offset:-300
,init:->
$this=$(this)
$this.css({marginLeft:"20px",opacity:0})
,appear:->
$this=$(this)
$this.transit({marginLeft:"0px",opacity:1},2000)
})
@novogrammer
novogrammer / setupHitArea.js
Created June 22, 2015 13:31
CreateJSで透明なMovieClipの当たり判定をそれっぽくするやつ
function setupHitArea(mc){
var b=mc.getBounds();
mc.hitArea=new createjs.Shape();
mc.hitArea.graphics=new createjs.Graphics().beginFill("#FFF").drawRect(b.x,b.y,b.width,b.height);
}
@novogrammer
novogrammer / 一括ダウンロード.sh
Created September 25, 2015 11:52
Automatorとかでwgetを使って一括ダウンロードするやつ
#!/bin/bash
# $ ./一括ダウンロード.sh "http://example.com"
mkdir -p ~/Desktop/一括ダウンロード/
cd ~/Desktop/一括ダウンロード/
echo "==== begin download $1 ====" >> log.txt
/usr/local/bin/wget --recursive --no-parent --page-requisites --html-ex --trust-server-names $1 >> log.txt 2>&1
echo "==== end download $1 ====" >> log.txt
@novogrammer
novogrammer / ofRectangleに欲しい.h
Created October 15, 2015 16:37
ofRectangleに欲しいメソッド
//ofRectangleにこのメソッド欲しいなー
inline ofRectangle ofRectangle_contain(const ofRectangle& _this,const ofRectangle& target){
ofRectangle rect=target;
float thisAspectRatio=_this.getAspectRatio();
float targetAspectRatio=target.getAspectRatio();
if(thisAspectRatio<targetAspectRatio){
//横が余る
rect.width=target.height*thisAspectRatio;
rect.x=(target.width-rect.width)*0.5f;
}else{
@novogrammer
novogrammer / mp42ogv.sh
Last active December 3, 2015 11:25
videoタグ用にmp4からwebmやogvを作る
#!/bin/bash
#前提
#brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-theora --with-libogg
function usage(){
cat <<EOT
Usage:
$(basename ${0}) INPUT_MP4_FILE OUTPUT_OGV_FILE
EOT
exit 1
}
@novogrammer
novogrammer / remove_same
Last active December 9, 2015 11:57
差分納品につかうやつ。変更の無いファイルを消すスクリプト。
#!/usr/bin/env ruby
require "pathname"
def usage
puts "Usage:"
puts "\t#{$0} SRC_DIR DST_DIR"
exit false
end
def is_same?(a,b)
return [a,b].all?{|i|i.file? && i.exist?} && (a.read==b.read)
#http://abrakatabura.hatenablog.com/entry/2015/08/22/095842
#を参考に、エラーが起きたのでパラメータを少し変更
mkdir release_asm
cd release asm
emcmake cmake -DBUILD_CUDA_STUBS=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_JASPER=OFF -DBUILD_JPEG=OFF -DBUILD_OPENEXR=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_PNG=OFF -DBUILD_TBB=OFF -DBUILD_TESTS=OFF -DBUILD_TIFF=OFF -DBUILD_WITH_DEBUG_INFO=OFF -DBUILD_ZLIB=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_ts=OFF -DBUILD_opencv_world=OFF -DWITH_1394=OFF -DWITH_CLP=OFF -DWITH_CUBLAS=OFF -DWITH_CUDA=OFF -DWITH_CUFFT=OFF -DWITH_FFMPEG=OFF -DWITH_GDAL=OFF -DWITH_GIGEAPI=OFF -DWITH_GSTREAMER=OFF -DWITH_GSTREAMER_0_10=OFF -DWITH_GTK=OFF -DWITH_GTK_2_X=OFF -DWITH_JASPER=OFF -DWITH_JPEG=OFF -DWITH_LIBV4L=OFF -DWITH_NVCUVID=OFF -DWITH_OPENCL=OFF -DWITH_OPENCLAMDBLAS=OFF -DWITH_OPENCLAMDFFT=OFF -DWITH_OPENEXR=OFF -DWITH_OPENGL=OFF -DWITH_OPENMP=OFF -DWITH_OPENNI=OFF -DWITH_OPENNI2=OFF -DWITH_PNG=OFF -DWITH_PVAPI=OFF -DWITH_QT=OFF -DWITH_TBB=OFF -DWITH_TIFF=OFF -DWITH_UNICAP=OFF -DWITH_V4L=OFF -DWITH_VTK=O