Skip to content

Instantly share code, notes, and snippets.

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

Rodrigo Setti rodrigosetti

🏠
Working from home
View GitHub Profile
@rodrigosetti
rodrigosetti / Riddles.sol
Created February 9, 2019 05:21
Riddles smart contract
pragma solidity ^0.5.0;
contract Owned {
constructor() public { owner = msg.sender; }
address payable owner;
modifier onlyOwner {
require(
msg.sender == owner,
"Only owner can call this function."
@rodrigosetti
rodrigosetti / GasToken.sol
Last active February 16, 2024 07:38
Ethereum ERC20 Token backed by gas price
pragma solidity ^0.5.0;
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
@rodrigosetti
rodrigosetti / bettingpool.sol
Created December 29, 2018 18:44
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.5.2+commit.1df8f40c.js&optimize=true&gist=
pragma solidity >=0.4.22 <0.6.0;
contract BettingPool {
// constructor
uint public betDeadline;
uint public secretDeadline;
// phase 1 (bets)
mapping (address => uint256) bets;
;
; Bot: Vegas
; Scenario: Multi-Player end quiz special cases
;
(set-bot 131)
(set-mention true)
(join alice)
(join bob)
@rodrigosetti
rodrigosetti / sherpa.js
Created October 15, 2016 00:08
Sherpa Node Library
"use strict";
var request = require("request");
var async = require("async");
module.exports = {
get : function(sherpaHost, dbName, tableName, ycaProxy, ycaRole, key, callback) {
var url = "http://" + sherpaHost + "/YDHTWebService/V1/get/" + dbName + "." + tableName + "/" + key;
@rodrigosetti
rodrigosetti / parse-trips.py
Created April 25, 2016 20:49
Parse Trips Helper Script
#! /usr/bin/env python
# coding: utf-8
import json, sys, time
def to_iso_time(ts):
return time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(ts))
def list_localities(city):
s = ["woeid=%d" % city["location"]["woeid"]]
@rodrigosetti
rodrigosetti / gist:ffff56fd59aafb393de7
Last active August 5, 2022 22:46
A case for tabular formatting

Look at the following code snippet. Can you spot the error? (yes, there's an error).

result.rankingValue = phraseValue( result, queryData ) +
                      noSpacesPhraseValue( result, queryData ) +
                      keywordInResultValue( result, queryData ) +
                      hiddenKeywordInResultValue( result, queryData ) +
                      keywordPositionValue( result, queryData ) +
                      isDomainRootValue( result, queryData )
 urlStartWithWWWValue( result, queryData ) +
@rodrigosetti
rodrigosetti / cat-feeder.ino
Last active August 29, 2015 14:13
Automatic Cat Feeder
#define MOTOR_PIN 9
#define FEED_INTERVAL_MS 21600000 // 6 hours
#define MOTOR_TIME_MS 1000 // 1 second (about ~ 1/4 cup)
void setup() {
pinMode(MOTOR_PIN, OUTPUT);
}
void loop() {
feed(MOTOR_TIME_MS);
@rodrigosetti
rodrigosetti / php-pearls.php
Last active February 1, 2019 22:33
PHP pearls
<?php
$x = NULL;
$x['foo'] = 'bar';
print_r($x);
// Array
// (
// [foo] => bar
@rodrigosetti
rodrigosetti / node-single-thread-server.js
Created June 19, 2014 19:46
Simple demonstration with node on the limitations of being single threaded
/**
* Run this file with node, and point your browser to localhost:3000,
* you'll get a simple "Hello world." back immediately.
*
* If you go to localhost:3000/wait though, it will wait for 10 seconds
* before getting the "Hello world." - this is a CPU block, not an I/O.
*
* That means it blocks every other request to the server as well (you can
* test by going to localhost:3000 in another browser tab while you wait
* for the localhost:3000/wait).