Skip to content

Instantly share code, notes, and snippets.

View nolash's full-sized avatar

lash nolash

View GitHub Profile
@nolash
nolash / floatreassemble.c
Created June 3, 2017 14:10
Deconstructing and reconstructing a IEEE 754 float
#include <stdio.h>
#include <limits.h>
#include <math.h>
float simple(float n, int ii) {
printf("simple original float: %f %x\n", n, *((unsigned int*)&n));
float a = (float)(int)n;
float b = n - a;
float c = (float)ii + b;
@nolash
nolash / gist:62e6c872ec126594359d20cbe26cd3aa
Last active September 6, 2020 21:46
solidity contract disassembly interpretation

contract

pragma solidity ^0.4.11;

contract Simple {
	bytes32 public v;
	function set(bytes32 _v) {
		v = _v;
	}
@nolash
nolash / fusebzz.go
Created October 14, 2017 16:58
Simple fuse mount and umount
package main
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/api"
"github.com/ethereum/go-ethereum/swarm/fuse"
"github.com/ethereum/go-ethereum/swarm/storage"
"io/ioutil"
"os"
"os/signal"
@nolash
nolash / dpabig.go
Created November 28, 2017 19:31
swarm dpa bigfile test
package main
import (
"crypto/rand"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"sync"
@nolash
nolash / telegram-req_pq.c
Last active December 3, 2017 00:58
Telegram req_pq
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <openssl/rand.h>
#include <zlib.h>
#include <math.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/types.h>
@nolash
nolash / startswarm.sh
Last active December 3, 2017 23:27
Script for polling bzzd.ipc when starting swarm
#!/bin/bash
function killswarm {
kill -TERM $1
exit 1
}
# take the newest key if none is given
function latest_key {
echo -n `find $1/keystore -regex ".*--[a-fA-F0-9].*" | sort -r | head -n1 | sed -e 's/.*Z--\([a-fA-F0-9]*\)$/\1/g'`
@nolash
nolash / raw.go
Last active December 8, 2017 06:40
Ethereum raw eth transaction
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"math/big"
"os"
"os/user"
@nolash
nolash / README_truebit_simple.md
Last active April 2, 2018 16:58
Working build configuration for truebit proof-of-concept "coindrop" example

EMSCRIPTEN SETUP

https://github.com/juj/emsdk @ 2324e5d8

  • LLVM_CMAKE_ARGS="-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly" emsdk install sdk-tag-1.37.28-64bit (be patient!)

To activate correct paths for emscripten and dependencies use:

  • ./emsdk activate sdk-tag-1.37.28-64bit
  • ./emsdk_env.sh
@nolash
nolash / gist:3a0294d7722cb89120757c473f2be026
Created April 24, 2018 08:24
swarm throttling with iptables + tc
#!/bin/bash
UID=$1
iptables -A OUTPUT -t mangle -m owner --uid-owner $UID -j MARK --set-mark 6
tc qdisc add dev enp2s0 root handle 1: htb default 30
tc class add dev enp2s0 parent 1: classid 1:1 htb rate 6mbit burst 15k
tc class add dev enp2s0 parent 1: classid 1:2 htb rate 1mbit burst 15k
tc filter add dev enp2s0 protocol ip parent 1:0 prio 1 handle 6 fw flowid 1:2
@nolash
nolash / hasher_test.go
Created April 24, 2018 13:47
Benchmark swarm hash worker handling
package hasher
import (
"encoding/binary"
"math/rand"
"strconv"
"strings"
"sync"
"testing"