Skip to content

Instantly share code, notes, and snippets.

View bertolo1988's full-sized avatar
🎯
Focusing

Tiago Bértolo bertolo1988

🎯
Focusing
View GitHub Profile
@bertolo1988
bertolo1988 / functions-vs-no-functions.js
Last active November 25, 2016 19:19
Do functions decrease performance? Answer: No. Notice the extra let obj=[].
var debug = require('debug')('test');
function sum(a, b) {
return a + b;
}
function multiplyTwo(a) {
return a * 2;
}
@bertolo1988
bertolo1988 / LetsEncrypt.md
Created July 30, 2017 00:50 — forked from davestevens/LetsEncrypt.md
Let’s Encrypt setup for Apache, NGINX & Node.js

Let's Encrypt

Examples of getting certificates from Let's Encrypt working on Apache, NGINX and Node.js servers.

Obtain certificates

I chose to use the manual method, you have to make a file available to verify you own the domain. Follow the commands from running

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
@bertolo1988
bertolo1988 / coinbase_eth_price_tab_title.js
Last active September 14, 2017 15:16
How to get Ethereum price on the title of a Coinbase.com tab
/*
Unable to find a chrome extension to display ethereum price
on my browser in EUROS, i decided to make a small script to
set the tab title with it every 2 seconds
All you need to do to use this script is to paste it in
your browser console.
*/
window.setInterval(function() {
@bertolo1988
bertolo1988 / hotjar_exercise.js
Created October 24, 2017 15:56
Write a JavaScript method receiving an array of objects containing name+age+gender, returning everyone between 30 and 40 years old grouped by gender.
function retrievePeople(people) {
function sortByGender(people) {
return people.sort((personA, personB) => {
if (personA.gender > personB.gender) {
return 1;
}
if (personA.gender < personB.gender) {
return -1;
}
return 0;
@bertolo1988
bertolo1988 / compare-object-proporties.js
Last active April 30, 2018 18:12
Util functions that help comparing object properties
/**
* @returns { * } - An object with properties alphabetically sorted
*/
function sortObjectKeys(obj){
let ordered = {}
Object.keys(obj).sort().forEach(key => {
ordered[key] = obj[key];
});
return ordered;
}
@bertolo1988
bertolo1988 / aws-s3-upload-pic-demo.js
Last active January 3, 2020 21:28
Connect and upload a picture into s3
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`
@bertolo1988
bertolo1988 / connect_linkedin.js
Last active February 27, 2025 14:08
Quickly your LinkedIn network
// 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
/* @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;
@bertolo1988
bertolo1988 / Ownable.sol
Last active September 5, 2019 23:57
Wheel of fortune using vulnerable pseudo random generator.
/* @author https://github.com/bertolo1988 */
pragma solidity ^0.5.10;
contract Ownable {
address public owner;
constructor() public {
owner = msg.sender;
}
@bertolo1988
bertolo1988 / Cheat.solidity
Last active September 6, 2019 00:09
To attack pseudo randoms.
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));
}