Skip to content

Instantly share code, notes, and snippets.

View restartgoroutine.go
package main
import "fmt"
// number of desired workers
const nWorkers = 10
func main() {
// make a buffered channel with the space for my 10 workers
workerChan := make(chan *worker, nWorkers)
View getUCPEnv.js
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);
@mbecker
mbecker / comunioTransfermarkt.js
Last active Sep 26, 2019
Read name, points and market value for each team member at the transfer page
View comunioTransfermarkt.js
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;
View cloudSettings
{"lastUpload":"2020-09-01T06:15:14.723Z","extensionVersion":"v3.4.3"}
View FlattenObject.js
// 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,
View RandomUserProfileNames.js
// 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
View userprofiles.js
// 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',
View git-untrack-files.md

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 .
@mbecker
mbecker / golang_cheathseet.md
Created Mar 8, 2019
Golang cheatsheet #golang #cheatsheet
View golang_cheathseet.md

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?
@mbecker
mbecker / Postresql_Table_Size.sql
Created Nov 1, 2018
Get the tables size of postgreql
View Postresql_Table_Size.sql
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,