Skip to content

Instantly share code, notes, and snippets.

View demouth's full-sized avatar

demouth

View GitHub Profile
@demouth
demouth / gist:3217440
Created July 31, 2012 14:32
mb_strwidth on JavaScript
;(function(ns){
/**
* mb_strwidth
* @param String
* @return int
* @see http://php.net/manual/ja/function.mb-strwidth.php
*/
var mb_strwidth = function(str){
var i=0,l=str.length,c='',length=0;
for(;i<l;i++){
/*
* Porting https://gist.github.com/demouth/1986726
*
* Example
* ```
* //Example 1
* let c = new Color();
* c.rgb(250,10,10).v(c.v() * 0.8);
*
* //Example 2
<?php
/**
* Color
* 色を表すクラス。
* RGB・HSV変換できます。
*
* @example
* Example 1:
* //RGBを10進数で個別に設定する。
* $color = new Color();
<?php
namespace WebSocket;
/**
* WebSocket Connection class
*
* @author Nico Kaiser <nico@kaiser.me>
* @author Simon Samtleben <web@lemmingzshadow.net>
*/
class Connection
@demouth
demouth / boom.sh
Created February 11, 2014 17:30
爆発しろ!という気持ちを鎮める為のシェル。 このシェルを叩くとランダムで生成された爆発のアニメーションが描画されます。
#!/bin/bash
#2つの引数の間の数値をランダムで返す
#第一引数の方がより小さな値を渡すこと
function rand() {
range=$(($1 - $2))
ret=$((RANDOM % range + $1))
echo $ret
}