Skip to content

Instantly share code, notes, and snippets.

View you21979's full-sized avatar
💭
I may be slow to respond.

Yuki Akiyama you21979

💭
I may be slow to respond.
View GitHub Profile

ビット演算

ビット演算を使うと集合の判定が簡単にできる。 ただしjavascriptにおいて型サイズがint32に変換されているためそれを超える場合には使えない(0-31まで)。

const JOB = Object.freeze({
    NONE : 0,
    FIGHTER : 1,
 MAGE : 2,
@you21979
you21979 / 大豆粉のレシピ.md
Last active December 10, 2015 05:11
大豆粉のレシピ

蒸しパン

  • 大豆粉 60
  • 卵 1個
  • 牛乳 100cc
  • プロテインパウダー(人工甘味料入り) 15
  • ベーキングパウダー 3
@you21979
you21979 / gist:81e8667190d34db62def
Last active February 13, 2016 07:28
bitcoin dsl
どんなウォレットを作るか定義する
<hdwallet>
<enum name="coin_type">
<const name="bitcoin" value="0" />
<const name="testnet" value="1" />
<const name="litecoin" value="2" />
</enum>
<enum name="change_type">
<const name="external" value="0" />
'use strict'
const pipe_initialize = (ctx) => {
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
if (chunk == "") { return ;}
var lines = chunk.split("\n");
lines[0] = ctx.fragment + lines[0];
ctx.fragment = lines.pop();
@you21979
you21979 / gist:3e6e69f7efd8efd454a45793078d82dc
Last active April 20, 2016 04:28
ソケットの個別切断方法
yum -y install dsniff
tcpkill -i eth0 -9 port 50185
@you21979
you21979 / Dockerfile.txt
Last active April 26, 2016 09:26
docker install
FROM centos:7
RUN curl -sL https://rpm.nodesource.com/setup_4.x | bash -
RUN yum install -y nodejs gcc-c++ make

前提条件を整えないと呼び出せない関数

var config = require("./config");
var calcRate = function(input){
  var rate = config['xxrate'];
  return min(max(0, rate * input), 100);
}
var main = function(){
var InsightRestClient = require('insight-cli').RestClient;
var task = require('promise-util-task');
var checkTXConfirmState = function(insight, confirmation_count, txid){
var reqtime = new Date() / 1000 | 0;
return insight.transaction(txid).then(function(tx){
var state = (tx.confirmations >= confirmation_count) ? 'CONFIRM' : 'UNCONFIRM';
return [tx.txid, tx.time, tx.confirmations, state]
}).catch(function(e){
switch(e.statusCode){
@you21979
you21979 / trycatch.js
Created September 19, 2016 01:20
trycatch
var x = function(){
try{
for(var i=0;i<100;++i){}
}catch(e){
}
}
var x2 = function(){
for(var i=0;i<100;++i){}
}