Skip to content

Instantly share code, notes, and snippets.

@tkihira
tkihira / gist:3035490
Created July 2, 2012 20:26
convert SJIS to UTF-8 using AJAX and ecl.js
<!doctype html>
<html><head><title>escape sample</title></head>
// http://www.vector.co.jp/soft/other/java/se342855.html
<script src="ecl.js"></script>
<script>
onload = function() {
var xhr = new XMLHttpRequest();
xhr.overrideMimeType('text/plain; charset=x-user-defined'); // binary
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) { // DONE
@tkihira
tkihira / daida.js
Last active November 3, 2015 11:20
代打って効果あるの?
var originalRatios = [
.259, .337, .330, .267, .188, .274, .224, .227, .091
];
function calcHit(h, bases) {
if(h > 2) {
// homerun
var s = 1 + (bases[0]?1:0) + (bases[1]?1:0) + (bases[2]?1:0);
bases[0] = bases[1] = bases[2] = false;
return s;
package com.example.hellogl;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
var check = function(digits) {
var make_equations = function(digits, strict) {
var numbers = digits.length;
var equations = {};
var current = [];
var make_recursive = function(num_list, nums, operations) {
if(num_list.length == 0 && operations == 0) {
equations[current.join("")] = true;
return;
/* Smooth scrolling
Changes links that link to other parts of this page to scroll
smoothly to those links rather than jump to them directly, which
can be a little disorienting.
sil, http://www.kryogenix.org/
v1.0 2003-11-11
v1.1 2005-06-16 wrap it up in an object
*/
class _Main {
static function main(args:string[]): void {
var v = JSON.parse('["a", "b", "c"]');
var i: int;
i = (v as Array.<int>)[0];
log i;
}
}
var data = [1, 4, 5, 6, 7, 8];
//var data = [2, 3, 5, 7, 11, 13, 17];
//var data = [2, 3, 5, 10, 20];
var a = [];
var r = function(u) {
if(a.length == data.length - 1) {
if(u) return solve();
else return false;
}
@tkihira
tkihira / fib.html
Last active February 18, 2018 12:47
<html><head><title>WebAssembly: JavaScript binding profiling</title>
<script>
onload = function() {
var textarea = document.getElementById("textarea");
var log = function(message) {
var now = performance.now();
textarea.value += (now - time).toFixed(3) + ": " + message + "\n";
time = performance.now();
};
var time = performance.now();
@tkihira
tkihira / gist:2367067
Created April 12, 2012 13:02
rmdir recursively in node.js
var fs = require("fs");
var path = require("path");
var rmdir = function(dir) {
var list = fs.readdirSync(dir);
for(var i = 0; i < list.length; i++) {
var filename = path.join(dir, list[i]);
var stat = fs.statSync(filename);
if(filename == "." || filename == "..") {
@tkihira
tkihira / words.js
Created February 1, 2022 07:13
wordle words
// ["cigar","rebut","sissy","humph","awake","blush","focal","evade","naval","serve","heath","dwarf","model","karma","stink","grade","quiet","bench","abate","feign","major","death","fresh","crust","stool","colon","abase","marry","react","batty","pride","floss","helix","croak","staff","paper","unfed","whelp","trawl","outdo","adobe","crazy","sower","repay","digit","crate","cluck","spike","mimic","pound","maxim","linen","unmet","flesh","booby","forth","first","stand","belly","ivory","seedy","print","yearn","drain","bribe","stout","panel","crass","flume","offal","agree","error","swirl","argue","bleed","delta","flick","totem","wooer","front","shrub","parry","biome","lapel","start","greet","goner","golem","lusty","loopy","round","audit","lying","gamma","labor","islet","civic","forge","corny","moult","basic","salad","agate","spicy","spray","essay","fjord","spend","kebab","guild","aback","motor","alone","hatch","hyper","thumb","dowry","ought","belch","dutch","pilot","tweed","comet","jaunt","enema","steed","abyss","gro