Skip to content

Instantly share code, notes, and snippets.

@foo9
foo9 / mockimg.rb
Last active December 14, 2015 16:19
# encoding: utf-8
require 'csv'
require 'rubygems'
require 'bundler/setup'
require 'rmagick'
def create_image(width, height, filename, ext)
@import "compass/css3/background-size";
$map: sprite-map("sprites/*.png", $layout:smart);
$map-img: sprite-url($map);
@mixin sprite-background($name) {
display: inline-block;
width: image-width(sprite-file($map, $name)) / 2;
height: image-height(sprite-file($map, $name)) / 2;
background-image: $map-img;
var palette = {
"Butter": ["#fce94f", "#edd400", "#c4a000"],
"Orange": ["#fcaf3e", "#f57900", "#ce5c00"],
"Chocolate": ["#e9b96e", "#c17d11", "#8f5902"],
"Chameleon": ["#8ae234", "#73d216", "#4e9a06"],
"Sky Blue": ["#729fcf", "#3465a4", "#204a87"],
"Plum": ["#ad7fa8", "#75507b", "#5c3566"],
"Scarlet Red": ["#ef2929", "#cc0000", "#a40000"]
};
class Hoge extends createjs.Container
constructor: () ->
@initialize()
@foo9
foo9 / jquery.simpletab.min.js
Created March 22, 2013 15:51
minimum tab jquery plugin (577 bytes)
;(function(a){a.fn.simpletab=function(){return this.each(function(){for(var b,c,d,e,f=a(this).find("a"),g=0,h=f.length;h>g;g++)c=a(f[g]),d=c.attr("href"),d=a(d),d.hide().bind("stactive stinactive",function(b,c){e=a(this),c=="#"+e.attr("id")&&("stactive"==b.type?e.show():e.hide())}),c.hasClass("active")&&d.show();f.click(function(){if(e=a(this),!e.hasClass("active")){a.event.trigger("stactive",[e.attr("href")]);for(var d=0,g=f.length;g>d;d++)b=f[d],c=a(b),b!=this?(c.removeClass("active"),a.event.trigger("stinactive",[c.attr("href")])):c.addClass("active")}})})}})(jQuery);
@foo9
foo9 / gist:5230897
Last active December 15, 2015 08:29
var elementId = "testCanvas";
var stageWidth = 300;
var stageHeight = 300;
var backgroundColor = "#abc";
var stage;
function init() {
var canvas = document.getElementById(elementId);
canvas.style.width = stageWidth + "px";
@foo9
foo9 / gist:5333658
Last active December 15, 2015 22:29
simple checkbox css (webkit only)
<form>
<input type="checkbox" checked="checked" />
<input type="checkbox" />
</form>
@foo9
foo9 / gist:5336802
Last active December 15, 2015 22:59
remove forcus dotted outline (for firefox)
var selectElems = document.getElementsByTagName("select");
for (var i = 0, iz = selectElems.length; i < iz; i++) {
selectElems[i].onfocus = selectElems[i].blur;
}
@foo9
foo9 / gist:5360249
Last active December 16, 2015 02:09
// how to use $("#hoge").visible(function () { console.log("(<●>д<●>)", this); }, function () { console.log("( ― д ― )", this); });
// uncompress
;(function ($) {
$.fn.visible = function (visible, invisible) {
if ((typeof visible !== "function") && (typeof invisible !== "function")) {
return this;
}
return this.each(function () {
if ($(this).css('display') === 'none') {
invisible.apply(this);
@foo9
foo9 / gist:5362367
Last active December 16, 2015 02:28
背景いっぱいにドット
$(function () {
var dotSize = 3;
var dotColor = "#abc";
var canvas = $("<canvas/>").attr({
width: dotSize * 2,
height: dotSize * 2
})[0];
var ctx = canvas.getContext('2d');
ctx.fillStyle = dotColor;
ctx.beginPath();