Skip to content

Instantly share code, notes, and snippets.

View berlysia's full-sized avatar
💭

berlysia

💭
View GitHub Profile
// 最新のchromeなどで実行できる
var board = [
[0,0,3,7,0,1,6,0,0],
[0,0,0,6,0,9,0,0,0],
[9,0,0,0,0,0,0,0,7],
[0,0,1,2,9,4,8,0,0],
[0,2,4,0,0,0,9,6,0],
[0,9,0,0,6,0,0,2,0],
[0,1,2,9,0,8,3,4,0],
(function() {
var br = s => s.replace(/\n/g, '&br()'),
wN = y => x => x.name === y
_r = createRequestJSONData(),
_rb = _r.base,
_rbb = _rb.bloods,
_rA = _r.baseAbility,
_rB = _r.battleAbility,
s = `* ${document.title}
[[BBTキャラクターシート>>${location.href}]]
"use strict";
class SKNode{
constructor(val){
this.left = null;
this.right = null;
this.value = val;
}
}
var ebml = require('ebml'); // npm i ebml
var fs = require('fs');
var decoder = new ebml.Decoder();
function isAsciiString(bytes){
for(var i=0,l=bytes.length; i<l; ++i){
if(!(0x20 <= bytes[i] && bytes[i] <= 0x7e)){
return false;
}
@berlysia
berlysia / testserver.rb
Created July 9, 2015 20:12
API叩く側を適当に書くときにつかうモックサーバ
require 'sinatra'
require 'json'
class MainApp < Sinatra::Base
get "/*" do
puts "get: #{params.inspect}"
end
post "/*" do
body = request.body.read
@berlysia
berlysia / parser_combinator.cpp
Created April 26, 2015 18:11
http://blog.anatoo.jp/entry/2015/04/26/220026 をなんとなくC++11で書きたかった
#include <bits/stdc++.h>
using namespace std;
typedef tuple<bool, vector<string>, int> ParseResult;
typedef function<ParseResult(const string, const int)> Parser;
bool isSucceed(const ParseResult &pr)
{
return get<0>(pr);

20160419 言語班

追記(20160419)

これは過去テキストの焼き直しです かつてはC#で書かれていましたが、C++に修正しています

今日やること

@berlysia
berlysia / gist:3c713e3557eb12cfa54d
Created April 20, 2015 17:17
Node.jsでファイルパスの配列を投げると画像はbase64にして返すしJSONは一本Stringにしてくれるやつ
compile = (args)->
result = {}
promises = []
args.forEach (x) ->
name = x.substr(0, x.lastIndexOf("."))
exp = x.substr(x.lastIndexOf("."), x.length-1).toLowerCase()
switch true
when exp == ".json"
result[name] = JSON.stringify JSON.parse fs.readFileSync x
when /\.jpe?g/.test exp
@berlysia
berlysia / gist:158948791cfb29ceac99
Last active August 29, 2015 14:19
Node.jsで特定directory以下のファイルのパスを全取得する
fs = require 'fs'
path = require 'path'
getPaths = (startPath) ->
dirs = [startPath] # push/shift
files = []
bfs = (target) ->
ls = fs.readdirSync target
ls = ls.filter((x)->x.indexOf(".")!=0).map((x)->path.join(target, x))
dirs = dirs.concat ls.filter (x)->fs.lstatSync(x).isDirectory()
@berlysia
berlysia / hoge.md
Last active August 29, 2015 14:19
RICORA言語班準備編

RICORA言語班準備編

環境準備

環境を作るのにそこそこ時間が掛かるので、事前に用意をしておいてください。