Skip to content

Instantly share code, notes, and snippets.

@foo9
foo9 / gist:9461980
Last active August 29, 2015 13:57
Get image dimensions. (use PHP)
path = ARGV[0]
if File.file?(path) and /\.(?:jpeg|jpg|gif|png|bmp)/i =~ File.extname(path)
system(%{php -r '$w = getimagesize("#{path}"); echo("width: ${w[0]}px; height: ${w[1]}px;");'})
else
puts ""
end
@foo9
foo9 / gist:9458096
Last active August 29, 2015 13:57
Geolocation API
function geolocation() {
var deferred = $.Deferred();
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
deferred.resolve(position.coords);
}, function (error) {
deferred.reject(error.code);
});
} else {

ブラックボックステスト

関数の入出力だけに着目したテスト

ホワイトボックステスト

関数の内部実装を踏まえて、すべての条件分岐、判定処理を少なくとも一回は検証するテスト

{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"default_line_ending": "windows",
"font_size": 12.0,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
],
filenames = Dir.glob("*.png")
filenames.each do |filename|
name = filename.gsub('_', '_0')
p name
File.rename(filename, name)
end
@foo9
foo9 / gist:9069054
Created February 18, 2014 11:17
pixi.js empty texture
var emptyBase64;
var emptyTexture;
emptyBase64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAAAnRSTlMAAHaTzTgAAAAKSURBVHgBY2AAAAACAAFzdQEYAAAAAElFTkSuQmCC';
emptyTexture = PIXI.Texture.fromImage(emptyBase64);
@foo9
foo9 / gist:8994609
Last active March 8, 2018 04:04
pixi.js renderer resize
var STAGE_WIDTH = 320;
var STAGE_HEIGHT = 480;
var $window = $(window);
// XXX: debounce
$window.resize(onResize);
function onResize() {
var width;
$ npm init
$ npm install grunt --save-dev
$ npm install grunt-contrib-jade grunt-contrib-stylus grunt-contrib-watch --save-dev
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p>姓:<input data-bind='value: firstName' /></p>
<p>名:<input data-bind='value: lastName' /></p>