This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPrime(num) { | |
for (let i = 2, s = Math.sqrt(num); i <= s; i++) | |
if (num % i === 0) return false; | |
return num > 1; | |
} | |
function getMapOfPrimeNumbersUpTo(n) { | |
const result = new Map(); | |
for (let i = 0; i < n; i++) { | |
if (isPrime(i)) result.set(i, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deleteFbComments() { | |
let postDeleted = 0; | |
const CLICK_DELAY = 50; | |
function randomIntFromInterval(min, max) { | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
} | |
function sleep(ms = 200) { | |
return new Promise((resolve) => setTimeout(resolve, ms)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoize(func) { | |
var memo = {}; | |
var slice = Array.prototype.slice; | |
return function () { | |
var args = slice.call(arguments); | |
if (args in memo) return memo[args]; | |
else return (memo[args] = func.apply(this, args)); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function __callback( bytes32 _queryId, string memory _result, bytes memory _proof ) public { | |
require(msg.sender == provable_cbAddress()); | |
require(ongoingBets[_queryId].sender != address(0x0) , 'query does not exist'); | |
if(provable_randomDS_proofVerify__returnCode( _queryId, _result, _proof) != 0){ | |
revert(); | |
} else { | |
uint ceiling = (MAX_INT_FROM_BYTE ** NUM_RANDOM_BYTES_REQUESTED) - 1; | |
uint randomNumber = uint(keccak256(abi.encodePacked(_result))) % ceiling; | |
uint spin = (randomNumber % 100) + 1; | |
Bet memory bet = ongoingBets[_queryId]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bet(uint stake, uint spinUnder)external notOwner returns (uint spinUnderInput, uint stakeInput, uint prize, uint payout, uint previousBalance){ | |
require(stake >= minBet && maxBet >= stake , 'stake is outside allowed limits'); | |
require(spinUnder >= MIN_ROLL_UNDER && spinUnder <= MAX_ROLL_UNDER, 'spinUnder must be between or equal to 11 and 91'); | |
require(balances[msg.sender] >= stake, 'insufficient balance to cover stake'); | |
(payout, prize) = getPrizeAndPayout(stake, spinUnder); | |
require(balances[owner] >= (prize.sub(stake)), 'insufficient contract balance to cover the prize'); | |
previousBalance = balances[msg.sender]; | |
subtractAmountFromUser(stake); | |
uint QUERY_EXECUTION_DELAY = 0; | |
uint GAS_FOR_CALLBACK = 200000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cheat(uint nonce, uint256 amount) external returns (uint stakeInput, uint spinUnderInput, uint spin, uint payout, uint prize, uint previousBalance, uint newBalance) { | |
uint randomnumber = uint(keccak256(abi.encodePacked(now, address(this), nonce))) % 100; | |
require(randomnumber >= 11, "rolled number too low"); | |
require(randomnumber <= 89, "rolled number too high"); | |
return instance.bet(amount, (randomnumber + 2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @author https://github.com/bertolo1988 */ | |
pragma solidity ^0.5.10; | |
contract Ownable { | |
address public owner; | |
constructor() public { | |
owner = msg.sender; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @author https://github.com/bertolo1988 */ | |
pragma solidity ^0.5.10; | |
import './provableAPI_0.5.sol'; | |
import './Ownable.sol'; | |
import './SafeMath.sol'; | |
contract Gamble is Ownable, usingProvable { | |
using SafeMath for uint; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. load https://www.linkedin.com/mynetwork/ | |
// 2. make sure your LinkedIn is in English | |
// 3. paste this script on chrome dev tools at your own risk | |
async function moreConnectionsPlease() { | |
// maximum limit of Connect buttons clicked | |
const LIMIT = 500; | |
// wait in ms before each scroll | |
const SCROLL_TIMEOUT = 600; | |
// bulk scroll will scroll this amount of times |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require('aws-sdk') | |
const fs = require('fs') | |
const BUCKET = 'bucket' | |
const REGION = 'eu-west-1' | |
const ACCESS_KEY = 'AWS_ACCESS_KEY' | |
const SECRET_KEY = 'AWS_SECRET_KEY' | |
const localImage = './cat.png' | |
const imageRemoteName = `catImage_${new Date().getTime()}.png` |