Skip to content

Instantly share code, notes, and snippets.

View mpolci's full-sized avatar

Marco Polci mpolci

View GitHub Profile
@mpolci
mpolci / sports-tracker-download.js
Last active July 25, 2020 16:20 — forked from anonymous/sports-tracker-download.js
Download all workouts from sports-tracker
// based entirely on this blog post:
// http://druss.co/2016/04/export-all-workouts-from-sports-tracker/
// unfortunately the original script no longer works, moslty because jQuery is
// no longer available on sports-tracker pages.
//
// I've compiled the changes proposed in the comments in the script below.
// to use the script, login to your sports-tracker account
// change URL to http://www.sports-tracker.com/diary/workout-list
// open browser console (Cmd-Shift-I)
diff --git a/web3deployment/reserveDeployer.js b/web3deployment/reserveDeployer.js
index 064eee8..a4d66ca 100755
--- a/web3deployment/reserveDeployer.js
+++ b/web3deployment/reserveDeployer.js
@@ -158,6 +158,7 @@ const input = {
),
'Utils.sol': fs.readFileSync(contractPath + 'Utils.sol', 'utf8'),
'Utils2.sol': fs.readFileSync(contractPath + 'Utils2.sol', 'utf8'),
+ 'Utils3.sol': fs.readFileSync(contractPath + 'Utils3.sol', 'utf8'),
'FeeBurnerInterface.sol': fs.readFileSync(
@mpolci
mpolci / TestChainID.sol
Created November 26, 2019 15:48
solidity chainid test for istanbul migration
pragma solidity ^0.5.13;
contract TestChainID {
function getChainID() external pure returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}
@mpolci
mpolci / gist:8d209d4638404cac9c750fcc759221d5
Created June 26, 2019 15:36
Ganache snaptshots for truffle
function evmSnapshot() {
const res = web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_snapshot',
params: [],
id: Date.now()
})
// if (res.error) ... not required in sync call
return res.result
}
@mpolci
mpolci / twMnemonicAdvice.directive.js
Created March 2, 2017 11:52
BIP39 Mnemonic words advice directive
'use strict';
angular.module('copayAddon.twinWallet').directive('twMnemonicAdvice', function () {
return {
restrict: 'AE',
transclude: true,
scope: {
prefix: '=',
language: '=',
words: '='
@mpolci
mpolci / dynamic-redux-sagas.md
Last active January 14, 2022 22:05
Helper function creating a dynamic saga for code splitting with redux-saga

Helper function

This function create a saga that runs the sagas in the startingSagas array and takes the actions with type indicated by changeActionType to replace the running sagas. The replacing actions must have a field sagas cointaining the array with the new sagas.

function createDynamicSaga (changeActionType, startingSagas) {
  function* _start (sagas) {
    try {
      yield sagas
@mpolci
mpolci / truffle_angular_postpone_bootstrap.md
Last active December 2, 2016 20:19
Postponed AngularJS bootstrap for Truffle since version 2.0.8

Truffle since release 2.0.8 delays the initialization of the global variable web3 after the load event, so this variable is not available during angular bootstrap, inside a .config() section, inside providers and neither inside the controllers initialized at load time and related injected services.

Accessing to the web3 variable inside a setTimeout() call could be a solution for simple projects but the only way to be sure that web3 is initialized is to postpone the angular bootstrap.

Looks at the code below:

@mpolci
mpolci / setBlockTime.js
Last active July 20, 2016 06:01
Manage evm_setTimestamp RPC call provided by the modified testrpc from https://github.com/Georgi87/testrpc
function rpc(method, arg) {
var req = {
jsonrpc: "2.0",
method: method,
id: new Date().getTime()
};
if (arg) req.params = arg;
return new Promise((resolve, reject) => {
web3.currentProvider.sendAsync(req, (err, result) => {
/* A contract to store goods with escrowed funds. */
/* Deployment:
Owner: seller
Last address: dynamic
ABI: [{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"escrows","outputs":[{"name":"buyer","type":"address"},{"name":"lockedFunds","type":"uint256"},{"name":"frozenTime","type":"uint256"},{"name":"frozenFunds","type":"uint256"},{"name":"buyerNo","type":"uint256"},{"name":"sellerNo","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"count","outputs":[{"name":"","type":"uint16"}],"type":"function"},{"constant":false,"inputs":[{"name":"datainfo","type":"string"},{"name":"_version","type":"uint256"}],"name":"cancel","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"seller","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"freezePeriod","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"datainfo","type":"string"},{"name":"_version"
@mpolci
mpolci / keybase.md
Created July 17, 2015 09:58
keybase

Keybase proof

I hereby claim:

  • I am mpolci on github.
  • I am mpolci (https://keybase.io/mpolci) on keybase.
  • I have a public key whose fingerprint is C644 E36B BF11 AA8C B4CF AA3A EBDF B31D 105A DE10

To claim this, I am signing this object: