Skip to content

Instantly share code, notes, and snippets.

View raypulver's full-sized avatar

Raymond Pulver IV raypulver

  • North Stonington, CT
View GitHub Profile
@raypulver
raypulver / ast.c
Created December 8, 2017 22:41
cyclic struct definitions
typedef struct _ast_binop_t {
ast_node_t *left;
ast_node_t *right;
} ast_binop_t;
typedef union _ast_data_t {
int integer;
ast_node_t node;
char *id;
ast_binop_t binop;
@raypulver
raypulver / double.js
Created December 1, 2017 21:39
show me that double
'use strict';
const number = 100;
// see the actual bits, since JS uses 64-bit doubles
let buffer = new ArrayBuffer(8);
let doubleLoader = new Float64Array(buffer);
doubleLoader[0] = number;
let bytes = new Uint8Array(buffer);
// output the bytes
console.log([].slice.call(bytes));
@raypulver
raypulver / edog.json
Created December 1, 2017 01:21
edog dump
[
{
"date": "2017-11-25 14:30:00",
"amount": "5168879.91350462",
"type": "buy",
"total": "0.004393547926478927",
"price": "0.00000000085",
"orderHash": "0x78b320a475ca58c17370c5de8850dbd5665358f2d3216f9e954dacb610198961",
"uuid": "1e799bb0-d1ed-11e7-ab09-d9e379eeee7a",
"buyerFee": "130337.759827009238855819",
@raypulver
raypulver / order.js
Created November 20, 2017 19:32
creating an order with IDEX API
const { soliditySha3 } = require('web3-utils');
const {
hashPersonalMessage,
bufferToHex,
toBuffer,
ecsign
} = require('ethereumjs-util')
const { mapValues } = require('lodash');
const contractAddress = '0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208';
const { create, assign } = Object,
{ dispatch, getState } = (function () {
let state = {
a: 5
};
const reduce = (last, action) => {
const { type, payload } = action;
switch (type) {
case 'INCREMENT_A':
return assign({ a: last.a + payload }, last);
var log = console.log;
var assign = Object.assign;
var MyClass = (function () {
var state = new Map();
function makeDefaultState() {
return { a: 0 };
}
function getState() {
return state.get(this);
}
@raypulver
raypulver / static.js
Created June 9, 2016 20:06
function static storage example
function myFunc() {
if (!myFunc.static) myFunc.static = Object.create(null);
// now we can access this hash every time we call the function, export it along with the function, and it is purely associated with the function
if (!myFunc.static.x) myFunc.static.x = 0;
myFunc.static.x++;
return myFunc.static.x;
}
myFunc();
myFunc();
Program received signal SIGSEGV, Segmentation fault.
#0 0x00007ffff72d5853 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x00000000004becbf in boost::io::detail::put_last<char, std::char_traits<char>, std::string> (os=...,
x=<error reading variable: Cannot access memory at address 0xfeffffffffffffe9>) at /usr/local/include/boost/format/feed_args.hpp:114
#2 0x00000000004bcbc6 in boost::io::detail::call_put_last<char, std::char_traits<char>, std::string> (os=..., x=0x7fffffffe0e0)
at /usr/local/include/boost/format/feed_args.hpp:126
#3 0x00000000004c11e5 in boost::io::detail::put_last<char, std::char_traits<char> > (os=..., t=...) at /usr/local/include/boost/format/feed_args.hpp:149
#4 0x00000000004bf169 in boost::io::detail::put<char, st
@raypulver
raypulver / gist:9845a12e2a53dcdc85ca
Created March 20, 2015 15:09
wait for transaction to be mined (blocking)
var filter = web3.eth.filter({ address: web3.eth.accounts[0] });
filter.watch(function () {
filter.stopWatching();
callback();
});
@raypulver
raypulver / gist:3354afd66c256c186800
Created August 9, 2014 20:11
soundManager states
angular.module('soundManager', ['ui.router']).config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/main/nested');
$stateProvider.state('main', {
url: '/main',
controller: function (sm) { // code with sm (sound manager) here },
templateUrl: 'index.html',
resolve: {
sm: function (soundManager) {
return soundManager();
}