Skip to content

Instantly share code, notes, and snippets.

@s-shin
s-shin / animator.coffee
Last active August 29, 2015 13:56
Small Animation Utility for CoffeeScript (JavaScript)
###
animator.coffee
(C) 2014 Shintaro Seki <s2pch.luck@gmail.com>
The MIT License
###
#
# Usage:
# fps = 15
# animator = new Animator fps, (frameCount) ->
# console.log frameCount
@s-shin
s-shin / vector2.coffee
Created February 22, 2014 14:34
Simple 2d vector class. Public domain :)
class Vector2
@fromArray: (a) -> new Vector2 a[0], a[1]
constructor: (x, y) -> @set x, y
set: (x, y) -> @[0] = x; @[1] = y; @x = x; @y = y; @
clone: -> new Vector2 @x, @y
add: (v) -> @clone().iadd v
iadd: (v) -> @set @x+v.x, @y+v.y
sub: (v) -> @clone().isub v
isub: (v) -> @set @x-v.x, @y-v.y
muls: (s) -> @clone().imuls s
@s-shin
s-shin / ua.coffee
Last active August 29, 2015 13:56
Detect user agent by CoffeeScript. Public domain :)
# ref: https://w3g.jp/blog/tools/js_browser_sniffing
UA =
ie: do ->
ie = false
ael = window.addEventListener?
ie = 6 if ael and not document.documentElement.style.maxHeight?
ie = 7 if not ie and ael and not document.querySelectorAll?
ie = 8 if not ie and ael and not document.getElementsByClassName?
ie = 9 if not ie and document.uniqueID and not window.matchMedia
ie = document.documentMode if not ie and document.uniqueID
@s-shin
s-shin / .vimrc
Last active August 29, 2015 13:58
my .vimrc
""" Extentions
if has('vim_starting')
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/.vim/bundle'))
NeoBundleFetch 'Shougo/neobundle.vim'
" Bundle lists
@s-shin
s-shin / cpan-list
Created April 9, 2014 13:04
A script listing installed modules.
perl -MExtUtils::Installed -le 'print join "\n" => sort ExtUtils::Installed->new->modules;'
@s-shin
s-shin / ios7icon
Created April 9, 2014 13:05
icon generator for iOS 7 with ImageMagick.
#!/usr/bin/env bash
convert $1 -geometry 40x40 Icon-40.png
convert $1 -geometry 80x80 Icon-40@2x.png
convert $1 -geometry 60x60 Icon-60.png
convert $1 -geometry 120x120 Icon-60@2x.png
convert $1 -geometry 72x72 Icon-72.png
convert $1 -geometry 144x144 Icon-72@2x.png
convert $1 -geometry 76x76 Icon-76.png
convert $1 -geometry 152x152 Icon-76@2x.png
convert $1 -geometry 50x50 Icon-Small-50.png
@s-shin
s-shin / create_disk.rb
Created May 22, 2014 00:42
Snippet for Vagrantfile v2.
# http://momijiame.tumblr.com/post/67058805910/vagrant-vm
# http://qiita.com/kakipo/items/57186721eaf6b83630ee
def create_disk(vb, name, size_gb, port)
file_path = "./tmp/#{name}.vdi"
unless File.exist?(file_path)
vb.customize ["createhd",
"--filename", file_path, "--size", size_gb * 1024]
vb.customize ["storageattach", :id,
"--storagectl", "SATA", "--port", port, "--device", 0,
"--type", "hdd", "--medium", file_path]
package Cmdline;
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Carp;
use parent qw(Exporter);
our @EXPORT = qw(cmdline);
@s-shin
s-shin / vue-js-1.html
Created June 9, 2014 16:09
My first practice of vue.js
<!DOCTYPE html>
<html>
<head>
<title>Vue.js Test</title>
<style>
.btn {
background-color: #333;
color: #FFF;
border-radius: 3px;
cursor: pointer;
// http://stackoverflow.com/q/3454526
function getNodeXPath(node, prefix) {
prefix = prefix ? prefix + ":" : "";
var getNodeName = function(node) {
return {
1: prefix + node.nodeName.toLowerCase(), // instanceof Element
3: "text()"
}[node.nodeType];
};