Skip to content

Instantly share code, notes, and snippets.

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;
}
}
@tkihira
tkihira / max
Last active August 29, 2015 14:10
function max(a, b) {
// 差のある最上位のビットを立てる
// (例えば 11010010 と 10110101 の場合、 x は 01000000 )
var x = a ^ b;
x |= x >>> 1;
x |= x >>> 2;
x |= x >>> 4;
x |= x >>> 8;
x |= x >>> 16;
var h = x ^ (x >>> 1);
@tkihira
tkihira / meta.cpp
Created December 26, 2014 03:53
Meta-programming for ten puzzle
#include <stdio.h>
template<int a_bunshi, int a_bunbo>
struct Calc1 {
enum { result = (a_bunbo != 0 && a_bunbo * 10 == a_bunshi) };
};
template<int a_bunshi, int a_bunbo, int b_bunshi, int b_bunbo>
struct Calc2 {
enum {
// http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
"use strict";
// Optional. You will see this name in eg. 'ps' or 'top' command
process.title = 'node-chat';
// Port where we'll run the websocket server
var webSocketsServerPort = 1337;
// websocket and http servers
@tkihira
tkihira / gist:1483c90f26eb92021306
Created May 27, 2015 03:05
1+23-4+56+7+8+9 = 100
#include <stdio.h>
void recursive(int level, int* op) {
if(level == 8) {
int result = 0;
int lastOp = 1;
int stack = 0;
for(int i = 0; i < 9; i++) {
int num = i + 1;
stack *= 10;
@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;
(function() {
var canvas;
var ctx;
var isWorking = false;
var exchangeRate = 0;
var timerId;
var found = false;
var maxHPS = 0;
var hpsList = [];