Skip to content

Instantly share code, notes, and snippets.

@naosim
naosim / jsnow.js
Created December 28, 2014 12:53
行儀のよいJavaScript
// 最近の行儀のよい JavaScript の書き方
// http://qiita.com/kaiinui/items/22a75d2adc56a40da7b7
(function(global) {
"use strict;"
// Your Module
function YourModule() {
// ...
};
@naosim
naosim / blogtweet.txt
Created December 29, 2014 09:33
ブログ更新しました!ってときに使うブックマークレット
javascript:alert(document.title + ' ' + location.href);
@naosim
naosim / links.json
Created December 30, 2014 06:46
よく使うライブラリのリンク集
@naosim
naosim / tinytest.js
Created January 2, 2015 14:29
最小限のテストフレームワーク for node.js
/* global process: false */
var logger = (function(){
var COLOR = {
RED: '\u001b[31m',
RESET: '\u001b[0m'
};
return {
log: function(){ console.log.apply(console, arguments); },
error: function() {
arguments[0] = COLOR.RED + arguments[0];
@naosim
naosim / rolledThicklyDirection.js
Created January 8, 2015 07:29
恵方巻きの方角を取得する
var getRolledThicklyDirection = function(year) {
var directions = [
"西南西微西",
"南南東微南",
"北北西微北",
"南南東微南",
"東北東微東"
];
return directions[year % 5];
};
@naosim
naosim / file0.java
Created January 13, 2015 08:03
Androidのアプリ情報を開くIntent ref: http://qiita.com/naosim_/items/253fa9edfd0fe37ecebf
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:com.your.app"));
startActivity(intent);
@naosim
naosim / file0.txt
Created February 28, 2015 10:43
HTTPステータスコード表をJSONにしてみた ref: http://qiita.com/naosim_/items/1d17d04df41f29191cc5
{
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
"201": "Created",
"202": "Accepted",
"203": "Non-Authoritative Information",
"204": "No Content",
"205": "Reset Content",
@naosim
naosim / textload.js
Last active August 29, 2015 14:16
node.jsでパイプと引数でテキストを取得する
var loadFromFile = function(file, callback) {
if(!file || file.trim().length == 0) {
callback('file not found', null);
return;
}
callback(null, ("" + require('fs').readFileSync(file)));
};
var loadFromPipe = function(callback) {
var text = "";
@naosim
naosim / zerofill.js
Created March 26, 2015 15:15
ゼロ埋め
var zerofill = function(num, zeros) { return (Array(zeros).join('0') + num).slice(-zeros); };
var replaceAll = function(org, before, after){ return org.split(before).join(after); };