Skip to content

Instantly share code, notes, and snippets.

@tatat
tatat / convert_uint16_to_float32.js
Created December 1, 2012 12:14
Uint16で扱ってるサウンドデータをFloat32に変換
var convert_uint16_to_float32 = function(data_view, little_endian) {
var byte_length = data_view.byteLength
, result = new DataView(new ArrayBuffer(byte_length * 2))
, converter = new DataView(new ArrayBuffer(2));
little_endian = !! little_endian;
for (var i = 0, uint16, int16; i < byte_length; i += 2) {
uint16 = data_view.getUint16(i, little_endian);
converter.setInt16(0, (uint16 + 0x8000) * 0xFFFF);
@tatat
tatat / print_json.rb
Last active October 13, 2015 17:47
JSON見やすく表示
#!/usr/bin/env ruby
require 'optparse'
require 'json'
$options = {
:print_type => false,
:print_each => true
}
@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 = {}
@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]);
}
!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;
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 = []
@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
@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)
#!/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'
})
<?php
class Nyan {
static public $table = array();
public static function what_should_name_this_method() {
$args = func_get_args();
$key = array_shift($args);