Skip to content

Instantly share code, notes, and snippets.

View carlosgj94's full-sized avatar
💭
Even more focused

Carlos Gonzalez Juarez carlosgj94

💭
Even more focused
View GitHub Profile
const ethers = require('ethers');
async function main() {
let privatekey = '<<PRIVATE_KEY>>'; // Yeah this should be done through an env var, I know but this is a f gist
let wallet = new ethers.Wallet(privatekey);
console.log('Using wallet address ' + wallet.address);
let transaction = {
import { TestToken, ValidatorShare, StakingInfo, EventsHub } from '../../helpers/artifacts'
import { BN, expectEvent, expectRevert } from '@openzeppelin/test-helpers'
import { checkPoint, assertBigNumberEquality, updateSlashedAmounts } from '../../helpers/utils.js'
import { wallets, freshDeploy, approveAndStake } from './deployment'
import { buyVoucher, sellVoucher, sellVoucherNew } from './ValidatorShareHelper.js'
import { web3 } from '@openzeppelin/test-helpers/src/setup'
const toWei = web3.utils.toWei
const ZeroAddr = '0x0000000000000000000000000000000000000000'
const ExchangeRatePrecision = new BN('100000000000000000000000000000')
const Augur = require('augur.js');
const augur = new Augur();
const augurConnection = 'ws://predictions.market:9001';
const connect = () => new Promise((resolve, reject) => {
augur.augurNode.connect(
augurConnection,
(error, wsTransport) => {
if (error) reject(error);
pragma solidity ^0.4.25;
contract StandardToken {
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
// Optional
string public name;
uint8 public decimals;
@carlosgj94
carlosgj94 / GunExamples.html
Created September 26, 2018 10:50
Basic examples for the Gun database
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/webrtc.js"></script>
<script>
// Emiter
var gun = Gun(['http://localhost:8765/gun', '<<YOUR GUN SERVER>>']);
// This function adds a new user to a list
function addUser(userName) {
var users = gun.get('users');
@carlosgj94
carlosgj94 / SingleObject.java
Created April 19, 2017 09:36
Singleton Pattern
public class SingleObject {
//create an object of SingleObject
private static SingleObject instance = new SingleObject();
//make the constructor private so that this class cannot be
//instantiated
private SingleObject(){}
//Get the only object available
@carlosgj94
carlosgj94 / Circle.java
Created April 19, 2017 09:33
Factory Pattern
public class Circle implements Shape {
@Override
public void draw() {
System.out.println("Inside Circle::draw() method.");
}
}
@carlosgj94
carlosgj94 / Circle.java
Created April 19, 2017 09:27
Decorator Pattern
public class Circle implements Shape {
@Override
public void draw() {
System.out.println("Shape: Circle");
}
}
@carlosgj94
carlosgj94 / BinaryObserver.java
Created April 18, 2017 20:15
Observer Pattern
public class BinaryObserver extends Observer{
public BinaryObserver(Subject subject){
this.subject = subject;
this.subject.attach(this);
}
@Override
public void update() {
System.out.println( "Binary String: " + Integer.toBinaryString( subject.getState() ) );
@carlosgj94
carlosgj94 / Aliensighting
Created July 12, 2015 15:39
Program to get all data from nuforc.org and get it into a .csv
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
namespace AlienScrap
{
class Program