Skip to content

Instantly share code, notes, and snippets.

View srameshr's full-sized avatar

Siddharth Ramesh srameshr

View GitHub Profile
@fabdarice
fabdarice / Dispatcher.sol
Created February 7, 2018 07:35
OldContract
pragma solidity ^0.4.4;
/**
* The dispatcher is a minimal 'shim' that dispatches calls to a targeted
* contract. Calls are made using 'delegatecall', meaning all storage and value
* is kept on the dispatcher. As a result, when the target is updated, the new
* contract inherits all the stored data and value from the old contract.
*/
import './Upgradeable.sol';
contract Dispatcher is Upgradeable {
const fs = require("fs");
const solc = require('solc')
let Web3 = require('web3');
let web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));
var input = {
'strings.sol': fs.readFileSync('strings.sol', 'utf8'),
'StringLib.sol': fs.readFileSync('StringLib.sol', 'utf8'),
@fabdarice
fabdarice / Contract Verification & Publication
Last active August 23, 2022 10:30
Useful Solidity/Web3/Truffle commands
1) go to https://ropsten.etherscan.io/verifyContract?a=0xa32b21ba14fd476757e392db5d1bbc833eaedaf5
2) enter contract address, name, compiler
3) copy code of contract flatten out (delete import and replace by actual code)
4) truffle console
5) var Eth = require('ethjs')
6) Eth.abi.encodeParams(["uint256", "uint256", "uint256", "address", "uint256"], ["1508105298", "1508710098", "200", "0x3d208fabaf7e919985d5d2f068f28d6a9022e8d5", "5000000000000000000000000000"])
7) copy paste result of encodeParams without '0x'
@fabdarice
fabdarice / Donation.sol
Last active July 11, 2019 20:04
Relay contract that contains only one state variable 'user_amounts' - Link first to Donation contract, then update to DonationNew to add the cancelDonation function.
contract Donation {
mapping (address => uint) user_amounts;
/* DOES THIS METHODS MODIFY user_amounts of the Relay contract ??? */
function sendDonation(uint n) {
user_amounts[msg.sender] = user_amounts[msg.sender] + n
}
}
@shayanb
shayanb / eventListener.js
Created September 15, 2016 22:26
simple NodeJS app to display triggered events on a smart contract
// This is a simple NodeJS app to display triggered events on a smart contract
// you need your contract ABI and deployed address and also a synced geth running
// github.com/shayanb
var optionsABI = [YOUR_CONTRACT_ABI]
var contractAddress = "0xYOUR_CONTRACT_ADDRESS"
var Web3 = require('web3');

Excerpt from For The Win, by Cory Doctorow

Once, when he'd been working on his Masters, he'd participated in a study for a pal in the economics department. They'd locked twenty five grad students into a room and given each of them a poker chip. "You can do whatever you want with those chips," the experimenter had said. "But you might want to hang onto them. Every hour, on the hour, I'm going to unlock this door and give you twenty dollars for each poker chip you're holding. I'll do this eight times, for the next eight hours. Then I'll unlock the door for a final time and you can go home and your poker chips will be worthless -- though you'll be able to keep all the money you've acquired over the course of the experiment."

He'd snorted and rolled his eyes at the other grad students, who were mostly doing the same. It was going to be a loooong eight hours. After all, everyone knew what the value of the poker chips were: $160 in the first hour, $140 in the next, $120 in th

@noelboss
noelboss / git-deployment.md
Last active May 2, 2024 15:47
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

/**
* Base contract that all upgradeable contracts should use.
*
* Contracts implementing this interface are all called using delegatecall from
* a dispatcher. As a result, the _sizes and _dest variables are shared with the
* dispatcher contract, which allows the called contract to update these at will.
*
* _sizes is a map of function signatures to return value sizes. Due to EVM
* limitations, these need to be populated by the target contract, so the
* dispatcher knows how many bytes of data to return from called functions.
@protrolium
protrolium / ffmpeg.md
Last active May 3, 2024 18:58
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with:

var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],