Skip to content

Instantly share code, notes, and snippets.

Avatar

Bernd Strehl Strernd

View GitHub Profile
@Strernd
Strernd / parseErc20Transfer.js
Created Jun 7, 2021
Parses an ERC20 Transfer from the Ethereum API.
View parseErc20Transfer.js
const converter = require("hex2dec");
const Eth = require("ethjs");
const eth = new Eth(new Eth.HttpProvider(process.env.INFURA));
async function getERC20TransferByHash(hash) {
const ethTxData = await eth.getTransactionByHash(hash);
if (ethTxData === null) throw "TX NOT FOUND";
if (
ethTxData.input.length !== 138 ||
ethTxData.input.slice(2, 10) !== "a9059cbb"
View ibm.js
'use strict';
const swf = require('serverless-workload-function');
let cold = true;
exports.handler = (params) => {
const options = params || {};
return swf(options.type || 'hash', options).then(result => {
const x = { ...result, cold };
cold = false;
return x
View handler.js
const laconia = require("@laconia/core");
const api = require("@laconia/adapter-api").apigateway({ inputType: "params" });
const app = async (event, { }) => {
console.log(await event);
return event;
};
exports.handler = laconia(api(app));
View serverless_cost.csv
Provider Per 1M Calls Per 1M GB/s Per 1M GHz/s
AWS 0.2 USD 16.7 USD -
Google 0.4 USD 2.5 USD 10 USD
IBM - 17 USD -
Azure 0.2 USD 16 USD -
View AdvertMarket.sol
pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
contract AdvertMarket is Ownable{
event NewAdvert(uint id, bytes32 meta, uint price, address sender);
event AdvertChangedOwner(uint id, uint price, address newOwner, uint newPrice);
event AdvertDataChanged(uint id, bytes32 data);
uint maxPriceFactor = 2; // max factor the price can increase at owner change
View voronoi.js
const Voronoi = require( 'voronoi' );
const _ = require( 'lodash' );
const canvas = document.getElementById( "canvas" );
const ctx = canvas.getContext( "2d" );
const v = new Voronoi();
const max = {
x: 800,
y: 800
};
const bbox = {
View build.js
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
const Voronoi = require( 'voronoi' );
const _ = require( 'lodash' );
const canvas = document.getElementById( "canvas" );
const ctx = canvas.getContext( "2d" );
const v = new Voronoi();
const max = {
x: 800,
y: 800
};
View index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Voronoi</title>
</head>
View CHP Homework 2
/*********************************************
* OPL 12.5.1.0 Model
* Author: BAT4769
* Creation Date: Dec 5, 2016 at 11:14:35 AM
*********************************************/
int n=4; // cargos
int m=3; // compartments
int a=2; // aircrafts
View tutorial 2
/*********************************************
* OPL 12.5.1.0 Model
* Author: BAT4769
* Creation Date: Dec 5, 2016 at 11:14:35 AM
*********************************************/
int n=4; // cargos
int m=3; // compartments
range cargos = 1..n;