Skip to content

Instantly share code, notes, and snippets.

@hiroshido
hiroshido / js
Created August 14, 2014 08:30
AngularJSでURL末尾の"/"スラッシュを削除 ref: http://qiita.com/unamu/items/c0cba8ace1cd1cc11b94
$urlRouterProvider.rule(function ($injector, $location) {
var path = $location.url()
// check to see if the path has a trailing slash
if ('/' === path[path.length - 1]) return path.replace(/\/$/, '')
if (path.indexOf('/?') > 0) return path.replace('/?', '?')
return false;
})
});
@hiroshido
hiroshido / js
Created May 8, 2014 12:55
gulp-ruby-sass で source map が使えない場合 ref: http://qiita.com/unamu/items/5ae7a926342357161836
gulp.task('sass', function() {
.pipe(sass({sourcemap: true, style: 'compressed'}))
});
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@hiroshido
hiroshido / file0.txt
Created February 27, 2014 05:19
nvmで管理するnode.jsの実行ファイルはいずこ? ref: http://qiita.com/unamu/items/83aff50c77a4ed68d543
/usr/local/bin/node
@hiroshido
hiroshido / file0.txt
Created February 14, 2014 06:44
node.jsをnpmでアップデート ref: http://qiita.com/unamu/items/2cc38fbb743d16d004d7
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
$ node -v
@hiroshido
hiroshido / file0.m
Created December 17, 2013 10:51
Webviewのnavigator.userAgentを独自のユーザーエージェントにする方法と、その他諸注意(Googel Analytics etc..) ref: http://qiita.com/unamu/items/078ca02c0e3444247ac4
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSString *customUserAgent = [userAgent stringByAppendingString:@" HOGEHOGE"];
@hiroshido
hiroshido / cookieplugintest.js
Created December 16, 2013 04:23
jquery.cookie.jsの使い方とCOOKIEの寿命(保存期間)を秒・分・時間で指定する方法 ref: http://qiita.com/unamu/items/06e88a53f101ae8d2700
// jsonの自動パース:
$.cookie.json = true;
// オブジェクトにまとめてといてそのまま突っ込める
var jsonData = new Object();
jsonData.title = "タイトル";
jsonData.url = "exsample.com";
jsonData.description = "概要";
$.cookie("jsonData", jsonData);
@hiroshido
hiroshido / file0.txt
Created November 28, 2013 06:44
UIColorでRGBをHex(16進数)で指定出来てアルファもキメちゃうマクロ ref: http://qiita.com/unamu/items/61ec0a99419d5afafdb9
//RGB color macro
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
//RGB color macro with alpha
#define UIColorFromRGBWithAlpha(rgbValue,a) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
@hiroshido
hiroshido / fladdict.js
Last active December 11, 2015 04:19 — forked from imaya/fladdict.js
function Fladdict(img) {
this.image = img;
this.canvas;
this.context;
this.backgroundColor;
this.textColor = [];
this.edgeColor;
this.colorHistogram;
}
function Fladdict(img) {
this.image = img;
this.canvas;
this.context;
this.backgroundColor;
this.textColor = [];
this.edgeColor;
this.colorHistogram;
}