Skip to content

Instantly share code, notes, and snippets.

View Ed1123's full-sized avatar
🍉
learning... forever

Ed1123

🍉
learning... forever
View GitHub Profile
@Ed1123
Ed1123 / concurrentFilter.go
Created January 23, 2024 16:22
Exploring how to run a function x times concurrently and get the results on a new slice. Both with buffer and unbuffered channels.
package main
import (
"fmt"
"sync"
)
func filterBufferedChannel(toFilter []int) []int {
filtered := make(chan int, len(toFilter))
var wg sync.WaitGroup
@Ed1123
Ed1123 / connect_salesforce.py
Created October 16, 2023 19:06
Simple funciton to connect to Salesforce (and sandbox when needed)
def connect_salesforce(username: str, password: str, security_token: str, is_test: bool) -> Salesforce:
'''Returns a Salesforce connection object. If test, it'll connect to Sf sandbox'''
domain = None
if is_test:
domain = 'test'
username += '.full'
return Salesforce(username, password, security_token, domain=domain)
@Ed1123
Ed1123 / logging_level_env.py
Last active September 2, 2022 23:00
Get Python logging level from environment variable
# From https://powerfulpython.com/blog/nifty-python-logging-trick/
import logging
import os
LOGLEVEL = os.environ.get('LOGLEVEL', 'WARNING').upper()
logging.basicConfig(level=LOGLEVEL)
@Ed1123
Ed1123 / change-email-git.sh
Last active May 2, 2022 22:39
Update email in git history (just for personal projects)
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "wrong_email@wrong_host.local" ];
then
GIT_AUTHOR_NAME="Your Name Here";
GIT_AUTHOR_EMAIL="correct_email@correct_host.com";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
@Ed1123
Ed1123 / autoEmojiSignal.js
Last active March 7, 2024 22:01
A script to auto-select the star emoji for all stickers when importing them to Signal
// Delay function
const delay = ms => new Promise(res => setTimeout(res, ms));
// Delay between clicks (seconds)
delayBetweenClicks = .1;
// Loop for all the stickers
stickers = document.getElementsByClassName('lCzvEVovrfFcZaKyf3ZOA');
for (i=0; i<stickers.length; i++){
// Clicking each emoji element for each sticker
stickers[i].getElementsByClassName('_2S1Fkez4JWbv9-1wbe5aeH')[0].click();
@Ed1123
Ed1123 / Random_number_game.py
Created November 12, 2018 00:52
My first Python game... I hope I'll learn plenty more. :'D
# This game consist in guessing a random
# number in less that determinate number
# of attemps.
import random
import time
def need_a_number(user_input):
while not user_input.isnumeric():