Skip to content

Instantly share code, notes, and snippets.

@kallewoof
kallewoof / app.sh
Last active September 2, 2015 08:04
Shell script to symlink up links to all iOS apps in simulator. Depends on https://github.com/kallewoof/plget
#!/bin/bash
if [ ! -e ".appshfolder" ]; then
echo "Run this from the designated folder please."
echo "If this is the first time you run this script, this is recommended:"
echo " cd"
echo " mkdir iosapps"
echo " cd iosapps"
echo " touch .appshfolder"
echo " cp <path to app.sh> ."
echo " ./app.sh"
const storageHandler = {
get(obj, name) {
return obj.getItem(name) || obj[name];
},
set(obj, name, value) {
obj.setItem(name, value);
},
has(obj, name) {
return name in obj.d || name in obj;
},
@kallewoof
kallewoof / most-work.js
Last active January 8, 2017 06:24
Bitcoin picks longest chain regardless of work done. In practice, work done is based on difficulty, not on the hash, which is why this fails.
> hexstr = (i) => { a = Buffer.alloc(4); a.writeInt32LE(i); return a.toString('hex'); }
[Function: hexstr]
> f = (e,i) => { console.log(`e=${JSON.stringify(e)}; i=${JSON.stringify(i)}`)};
[Function: f]
> const { BitcoinNet, BitcoinGraph, Block, BlockHeader } = require('bitcointest')
undefined
> net = new BitcoinNet('../bitcoin/src', '/tmp/bitcointest', 22001, 22002);
{ path: '../bitcoin/src',
cfgprefix: '/tmp/bitcointest',
nextport: 22001,
@kallewoof
kallewoof / testcase-listsinceblock.js
Created January 11, 2017 08:51
Unit test for listsinceblock bug where a reorg results in an invalid depth, losing transactions made on alternate (now main) chain.
if (process.argv.length !== 3) {
console.log("syntax: <bitcoin/src path>");
process.exit(1);
}
const bitcoin = process.argv[2];
const { BitcoinNet, BitcoinGraph } = require('bitcointest');
const net = new BitcoinNet(bitcoin, '/tmp/bitcointest', 23001, 23002);
try {
console.log('starting nodes');
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <cstdio>
#include <cstring>
#include <cstdlib>
/* Compilers have a bad habit of removing "superfluous" memset calls that
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
.globl __Z14memory_cleansePvm
.p2align 4, 0x90
__Z14memory_cleansePvm: ## @_Z14memory_cleansePvm
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
.globl __Z14memory_cleansePvm
.p2align 4, 0x90
__Z14memory_cleansePvm: ## @_Z14memory_cleansePvm
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
.file "test_cleanse.cpp"
.text
.p2align 4,,15
.globl _Z14memory_cleansePvm
.type _Z14memory_cleansePvm, @function
_Z14memory_cleansePvm:
.LFB77:
.cfi_startproc
pushq %rbx
.cfi_def_cfa_offset 16
.file "test_cleanse.cpp"
.text
.p2align 4,,15
.globl _Z14memory_cleansePvm
.type _Z14memory_cleansePvm, @function
_Z14memory_cleansePvm:
.LFB77:
.cfi_startproc
movq %rsi, %rdx
xorl %esi, %esi
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 12
.globl __Z14memory_cleansePvm
.p2align 4, 0x90
__Z14memory_cleansePvm: ## @_Z14memory_cleansePvm
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16