Skip to content

Instantly share code, notes, and snippets.

@mbecker
mbecker / WhatsAppOnlineStatus.js
Last active October 23, 2018 06:29
WhatsApp Online Status
// This script identifies how long a contact is online in the WhatsApp-Webapp
// The contact must have enabled to share his online stats
// 1. Login at the WhatsApp-Webapp: https://web.whatsapp.com/
// 2. Select the contact to watch at
// 3. Open in Chrome the web console via right click and "inspect" (or press 'strg+shift+j')
// 4. Open the 'console' and copy/paste the code; press enter at the end
// 5. Open the printed array in the console and see online status with duration in milliseconds
// The script inspect every x ms if the user is online;
// Test in jsfiddle: http://jsfiddle.net/mbecker/85Lekhtc/53/
@mbecker
mbecker / Postresql_Table_Size.sql
Created November 1, 2018 21:34
Get the tables size of postgreql
SELECT
table_name,
pg_size_pretty(table_size) AS table_size,
pg_size_pretty(indexes_size) AS indexes_size,
pg_size_pretty(total_size) AS total_size
FROM (
SELECT
table_name,
pg_table_size(table_name) AS table_size,
pg_indexes_size(table_name) AS indexes_size,
@mbecker
mbecker / golang_cheathseet.md
Created March 8, 2019 22:18
Golang cheatsheet #golang #cheatsheet

mod

Migrating from dep to Go 1.11 modules

https://blog.callr.tech/migrating-from-dep-to-go-1.11-modules/

- move your code outside of GOPATH
- go mod init [module path]: this will import dependencies from Gopkg.lock.
- go mod tidy: this will remove unnecessary imports, and add indirect ones.
- rm -fr vendor/
- go build: is everthing ok?

Step 1: Commit all your changes

Before proceeding, make sure all your changes are committed, including your .gitignore file.

Step 2: Remove everything from the repository

To clear your repo, use:

git rm -r --cached .
// User profile images from: https://uifaces.co/?provider%5B%5D=9&provider%5B%5D=7&provider%5B%5D=5&provider%5B%5D=3&provider%5B%5D=1&provider%5B%5D=8&from_age=18&to_age=40
const profiles = [
'https://randomuser.me/api/portraits/men/32.jpg',
'https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&s=707b9c33066bf8808c934c8ab394dff6',
'https://randomuser.me/api/portraits/women/44.jpg',
'https://randomuser.me/api/portraits/women/68.jpg',
'https://randomuser.me/api/portraits/women/65.jpg',
'https://randomuser.me/api/portraits/men/43.jpg',
'https://tinyfac.es/data/avatars/475605E3-69C5-4D2B-8727-61B7BB8C4699-500w.jpeg',
'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?h=350&auto=compress&cs=tinysrgb',
// Names by: https://www.randomlists.com/random-names
const names = ["Emily Mcpherson", "Trinity Taylor", "Rodolfo Good", "Lilliana Atkinson", "Brisa Cummings", "Javier Alexander", "Elsa Pineda", "Valentin Blackwell", "Mallory Morton", "Ross Ho", "Rihanna Barry", "Aubree Solis", "Mercedes Henderson", "Shaun Cooper", "Kamora Mckinney", "Maleah Farrell", "Makenna Obrien", "Patricia Zuniga", "Giancarlo Mcpherson", "Alessandra Cortez", "Erin Robles", "Lilyana Chapman", "Rhys Jimenez", "Justine Lara", "Lennon Brandt", "Bruce Weaver", "Kash Rivera", "Kamron Pugh", "Jazlene Ross", "Ishaan Page", "Killian Norman", "Kiersten Hahn", "Azul Mooney", "Roselyn Ware", "Davian Bennett", "Kymani Frank", "Nayeli Robertson", "Juan Rivas", "Jaylyn Melton", "Jamison Cowan", "Malaki Quinn", "Miguel Molina", "Leonidas Bishop", "Sage Richmond", "Gary Brandt", "Ross Barton", "Efrain Patton", "Rohan Best", "Griffin Bishop", "Rosa Hines", "Makena Rowland", "Aden Mckay", "Elisa Ponce", "Marianna Jacobs", "Jayvion Flores", "Princess Schm
// https://jsfiddle.net/L1pozdj6/
// Source: https://stackoverflow.com/questions/33036487/one-liner-to-flatten-nested-object - Webber
/**
* Flatten a multidimensional object
*
* For example:
* {
* "a": 1,
* "b": {
* "c": 2,
{"lastUpload":"2020-09-01T06:15:14.723Z","extensionVersion":"v3.4.3"}
@mbecker
mbecker / comunioTransfermarkt.js
Last active September 26, 2019 08:30
Read name, points and market value for each team member at the transfer page
var tradable = document.getElementsByClassName("tradable");
var output = "";
var dt = new Date().toISOString().substr(0, 10);
for (let i=0; i<tradable.length; i++) {
var el = tradable[i];
// Name
var tradablename = el.getElementsByClassName("tradablename")[0];
var name = tradablename.getElementsByClassName("name")[0].innerText;
var output = "";
var rowsTable = document.getElementsByClassName("ReactVirtualized__Table__row styles__row___3MKZR");
for(var i = 0; i < rowsTable.length; i++) {
var el = rowsTable[i];
var rowsInTable = el.querySelectorAll("div");
output += '- name: ' + rowsInTable[0].innerText + '\n';
output += ` value: "${rowsInTable[1].innerText}"\n`
}
console.log(output);