Skip to content

Instantly share code, notes, and snippets.

@tkihira
tkihira / gist:3014700
Created June 28, 2012 23:28
mkdir, rmdir and copyDir(deep-copy a directory) in node.js
var mkdir = function(dir) {
// making directory without exception if exists
try {
fs.mkdirSync(dir, 0755);
} catch(e) {
if(e.code != "EEXIST") {
throw e;
}
}
};
(function() {
var canvas;
var ctx;
var isWorking = false;
var exchangeRate = 0;
var timerId;
var found = false;
var maxHPS = 0;
var hpsList = [];
@tkihira
tkihira / hack version.c
Created March 22, 2012 19:09
switch hack on C
void switch_func(int n) {
char *s;
switch(n) {
case 0:
s = "Sun";
if(0)
case 1:
{ s = "Mon"; }
if(0)
case 2:
@tkihira
tkihira / output.txt
Created October 2, 2022 02:30
Wordle Solver Output
{
maxCount: 6,
maxWord: 'shave',
minCount: 2,
minWord: 'hello',
average: 3.798704103671706
}
2 guesses: 80
3 guesses: 706
4 guesses: 1160
@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
@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 / 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();
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;
}
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;
}
}
/* 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
*/