Skip to content

Instantly share code, notes, and snippets.

View jdkanani's full-sized avatar
🎯
Focusing

Jaynti Kanani jdkanani

🎯
Focusing
View GitHub Profile
@jdkanani
jdkanani / ATestRLP.sol
Last active December 18, 2018 08:38
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.25+commit.59dbf8f1.js&optimize=true&gist=
pragma solidity ^0.4.24;
import "./RLP.sol";
import "./ECVerify.sol";
contract ATestRLP {
using RLP for bytes;
using RLP for RLP.RLPItem;
using RLP for RLP.Iterator;
@jdkanani
jdkanani / Verifying my Peepeth
Created August 27, 2018 07:36
Verifying my Peepeth
Verifying my identity on Peepeth.com 0x01c7664ea0e4fa975ad3b9b97794e9b0c3901985
#!/bin/bash
# Copyright 2017 Parity Technologies (UK) Ltd.
set -x
## Update this with any new relase!
VERSION_STABLE="1.11.8"
VERSION_BETA="2.0.1"
##
@jdkanani
jdkanani / gpg-import-and-export-instructions.md
Created July 6, 2018 05:34 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@jdkanani
jdkanani / walletconnect-provider.js
Created April 25, 2018 17:37
Walletconnect providers
import Web3 from 'web3'
function getCallback(payload, cb) {
return function(err, result) {
const obj = {}
const keys = ['id', 'jsonrpc']
keys.forEach(key => {
obj[key] = payload[key]
})
obj.result = result
@jdkanani
jdkanani / dagger-token-transfer.js
Created December 6, 2017 12:08
Dagger example 2
// web3 contract
var web3Contract = new web3.eth.Contract(abi, address);
// dagger contract
var contract = dagger.contract(web3Contract);
var filter = contract.events.Transfer({filter: {from: '0x123456...'}, room: 'latest'});
// watch
filter.watch(function(data, removed){
// data.returnValues.to : address to which it has been transferred to
// data.returnValues.value : value which has been transferred
Verifying my Blockstack ID is secured with the address 1BmZj9kZEstcPsVLbLmR1vYLe8QhunpApG https://explorer.blockstack.org/address/1BmZj9kZEstcPsVLbLmR1vYLe8QhunpApG
@jdkanani
jdkanani / swap.sh
Created October 25, 2017 04:55
Creating swap file for Ubuntu digitalocean
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50
@jdkanani
jdkanani / vuefire-init.js
Created August 28, 2017 19:28
vuexfire + vuefire
import Vue from 'vue';
import { VueFireMixin, firebaseMutations, bind, unbind } from '~/plugins/vuefire';
// vuefire init
export default function ({ store }) {
// use object-based merge strategy
// TODO This makes impossible to merge functions
const mergeStrats = Vue.config.optionMergeStrategies;
mergeStrats.firebase = mergeStrats.methods;
@jdkanani
jdkanani / decorators.js
Created August 2, 2017 11:06
Javascript decorators
export function sleepFor (timeInMilliSeconds = 1000) {
return new Promise((resolve, reject)=>{
setTimeout(resolve, timeInMilliSeconds);
});
}
export function waitFor (...names) {
return (target, prop, descriptor) => {
const fn = descriptor.value;
let newFn = function (...args) {