Skip to content

Instantly share code, notes, and snippets.

@tatat
tatat / static_html_init.sh
Last active December 12, 2015 08:48
こんな感じで行こうと思う
#!/bin/bash
jquery_version="1.9.1"
jquery_name="jquery-${jquery_version}.min.js"
jquery_url="http://code.jquery.com/$jquery_name"
mkdir -p haml coffee sass vendor public/{javascripts,stylesheets,images,lib}
touch vendor/.gitkeep
curl -L "$jquery_url" > "public/lib/$jquery_name"
<?php
class Nyan {
static public function static_method_nyan() {
echo 'static nyan', "\n";
}
static public function __callStatic($name, $args) {
$method_name = 'static_method_' . $name;
<?php
class Nyan {
static public $table = array();
public static function what_should_name_this_method() {
$args = func_get_args();
$key = array_shift($args);
#!/usr/bin/env ruby
require 'webrick'
server = WEBrick::HTTPServer.new(
:DocumentRoot => '.',
:Port => (ARGV[0] || '3001').to_i,
:MimeTypes => WEBrick::HTTPUtils::DefaultMimeTypes.merge({
'js' => 'application/javascript'
})
@tatat
tatat / r.js
Last active December 11, 2015 22:49
(function($) {
$(document).on('mousedown', function mousedown_handler(e) {
var mousemove_handler = function(e) {
// 動かしたり
};
$(this)
.on('mousemove', mousemove_handler)
.on('mouseup', function mouseup_handler(e) {
$(this)
@tatat
tatat / ryoumen.rb
Last active December 11, 2015 08:08
りょうめん!
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
begin
page = ARGV[0].to_i
raise 'invalid arguments' if page <= 0 || page % 4 != 0
column_width = 5
row_width = 17
require "digest/md5"
d = Digest::MD5.hexdigest("nyan" + Time.now.strftime("%Y%m%d")).to_i(16);
shindan = []
10.times {|n| shindan[n] = []; 99.times {|nn| shindan[n] << nn.to_s } }
result = []
!function($, start_x, start_y, target_start_x, target_start_y, $target) {
$(document).on('mousedown', function(e){
var style, target = e.target;
do {
style = document.defaultView.getComputedStyle(target, null);
} while (style.position !== 'absolute' && (target = target.parentNode));
if (!target)return;
$target = $(target);
var position = $target.position();
start_x = e.pageX;
@tatat
tatat / step.js
Last active December 10, 2015 13:18
いっこづつ
var Step = function(steps) {
if (this instanceof Step) {
this.items = [];
this.oncomplete = null;
this.onabort = null;
if (steps) {
for (var i = 0, j = steps.length; i < j; i ++)
this.add(steps[i]);
}
@tatat
tatat / ggtrim.js
Last active December 9, 2015 22:08
Googleの検索結果URLから余分なパラメータ削除するやつ - http://let.hatelabo.jp/uneco/let/gYC-yby_yIjbcQ
(function(d) {
var script = d.createElement('script');
script.textContent = '(' + function(d, l) {
var href = l.href
, hash_index = href.indexOf('#')
, query_index = href.indexOf('?')
, hash = hash_index < 0 ? '' : href.substring(hash_index + 1)
, query = query_index < 0 ? '' : href.substring(query_index + 1, hash_index < 0 ? href.length : hash_index)
, params = {}