Skip to content

Instantly share code, notes, and snippets.

View itxtoledo's full-sized avatar
🏠
Working from home

Gustavo itxtoledo

🏠
Working from home
View GitHub Profile
@davidecaruso
davidecaruso / install-robo3t.sh
Last active October 22, 2021 07:26
Install Robo3T on Linux
#!/bin/bash
cd /tmp || exit
printf "Downloading Robo 3T...\n"
filename="${1:-robo3t-1.4.4-linux-x86_64-e6ac9ec}"; # Default: v1.4.4
wget -q https://download.studio3t.com/robomongo/linux/$filename.tar.gz
if [ $? -ne 0 ];then
printf "Invalid package given.\n"
exit 1
fi
@islishude
islishude / create2_with_eip1167_Example.md
Created March 6, 2020 02:16
Solidity proxy with CREATE2

Complete example

pragma solidity ^0.6.2;

interface IERC20 {
    function totalSupply() external view returns (uint);
    function balanceOf(address tokenOwner) external view returns (uint balance);
    function allowance(address tokenOwner, address spender) external view returns (uint remaining);
    function transfer(address to, uint tokens) external returns (bool success);
@Spyna
Spyna / push-notifications.js
Created August 29, 2019 15:13
Push notification manager
const pushServerPublicKey = "BIN2Jc5Vmkmy-S3AUrcMlpKxJpLeVRAfu9WBqUbJ70SJOCWGCGXKY-Xzyh7HDr6KbRDGYHjqZ06OcS3BjD7uAm8";
/**
* checks if Push notification and service workers are supported by your browser
*/
function isPushNotificationSupported() {
return "serviceWorker" in navigator && "PushManager" in window;
}
/**
function buildCreate2Address(senderAddress, saltHex, bytecode) {
return web3.utils.toChecksumAddress(`0x${web3.utils.sha3(`0x${[
'ff',
senderAddress,
saltHex,
web3.utils.sha3(bytecode)
].map(x => x.replace(/0x/, ''))
.join('')}`).slice(-40)}`);
}
@miguelmota
miguelmota / build_create2_address.js
Created November 17, 2018 06:28
JavaScript build ethereum create2 address (counterfactual smart contract address)
function buildCreate2Address(creatorAddress, saltHex, byteCode) {
const parts = [
'ff',
creatorAddress.slice(2),
saltHex.slice(2),
web3.utils.sha3(byteCode).slice(2),
]
const partsHash = web3.utils.sha3(`0x${parts.join('')}`)
return `0x${partsHash.slice(-40)}`.toLowerCase()
@willianmano
willianmano / Lottery.sol
Created September 5, 2018 13:39
A Lottery Solidity Smart Contract
pragma solidity ^0.4.21;
contract Lottery {
address public manager;
address[] public players;
constructor() public {
manager = msg.sender;
}
@edhaase
edhaase / SequelizeModels.js
Last active December 10, 2021 05:38
Load sequelize models from a folder
/*
* Not actually a JS file; Normally you'd break these components up.
*/
/* creating the database connection */
var db = new Sequelize('database', 'username', 'password', ...);
/* loading the models */
var fs = require('fs');
var path = require('path');
@marcoscastro
marcoscastro / grafos_lista.cpp
Created February 18, 2015 17:08
C++ - Grafos - Lista de adjacência
// Grafos - Lista de adjacência
#include <iostream>
#include <list>
#include <algorithm> // função find
using namespace std;
class Grafo
{