Skip to content

Instantly share code, notes, and snippets.

View Strernd's full-sized avatar

Bernd Strehl Strernd

View GitHub Profile
@Strernd
Strernd / parseErc20Transfer.js
Created June 7, 2021 11:09
Parses an ERC20 Transfer from the Ethereum API.
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"
'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
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));
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 -
@Strernd
Strernd / AdvertMarket.sol
Last active July 30, 2018 14:57
Contract code for the tutorial on https://medium.com/p/9d2341a80e7d
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
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 = {
(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
};
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Voronoi</title>
</head>
/*********************************************
* 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
/*********************************************
* 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;