Skip to content

Instantly share code, notes, and snippets.

View willnaoosmith's full-sized avatar
🐧
Torvalds take the wheel 🙏🏻

William Brochensque Júnior willnaoosmith

🐧
Torvalds take the wheel 🙏🏻
View GitHub Profile
@willnaoosmith
willnaoosmith / gist:961ccab8299543b230ab9bc03279eee9
Created August 15, 2024 17:58
watch an element for class changes
var e = document.getElementById('test')
var observer = new MutationObserver(function (event) {
console.log(event)
})
observer.observe(e, {
attributeFilter: ['class'],
characterData: false,
attributes: true,
@willnaoosmith
willnaoosmith / gist:45c501118260700e35a275fbc5775cc9
Created August 15, 2024 13:09
get all starred repositories from user
while curl -s "https://api.github.com/users/willnaoosmith/starred?per_page=100&page=${page:-1}" \
|jq -r -e '.[].html_url' && [[ ${PIPESTATUS[1]} != 4 ]]; do
let page++
done
@willnaoosmith
willnaoosmith / gist:a6c42999e872226ccd336371454501ec
Created July 25, 2024 18:31
Diferença de meses entre 2 datas / month diff between 2 dates / sql server
CEILING(DATEDIFF(d, DATEADD(DAY, 1 - DAY(ITM7.DprStart), ITM7.DprStart), EOMONTH(ITM7.DprEnd)) / (365.25 / 12))
@willnaoosmith
willnaoosmith / gist:90a91b2ee5e8be9b6869ca372180e299
Last active June 12, 2024 16:22
start lottie from specific frame and stop at specific frame using events
const stopAtFrame = (animation, stopFrame, frame) => {
if (frame.currentTime >= stopFrame){
animation.pause()
}
}
<Lottie
ref={errorlottie}
height={"33%"}
width={"33%"}
@willnaoosmith
willnaoosmith / gist:2a00a84a0640b7c5f3e47395f9784818
Created June 6, 2024 17:50
break text if overflows in a div
white-space: pre-wrap;
overflow-wrap: break-word ;
word-wrap: break-word;
word-break: break-word;
@willnaoosmith
willnaoosmith / gist:03959c13cfbfb79456ce14b50939dc06
Last active June 4, 2024 13:19
animate reactjs item on in and out
<div
style={
currentQuestion == 0 ?
{animation: "outAnimation 270ms ease-out", animationFillMode: "forwards", visibility: "hidden"} :
{animation: "inAnimation 250ms ease-in"}
}
>
</div>
@willnaoosmith
willnaoosmith / gist:4dae4fa526e8f3ca3745e71cc1987568
Created May 21, 2024 10:33
get a PID of a command and use it on another command
$( sleep 10 )& pid=$!; sleep 0.1s; kill -9 $pid
@willnaoosmith
willnaoosmith / gist:0870879b99058298da4e780707d61888
Created May 8, 2024 13:11
repeat bash command every x seconds
while true; do bash -c "command here"; done
OR
watch -n 1 bash -c "command here"
@willnaoosmith
willnaoosmith / workdays.py
Last active March 22, 2024 13:04
Using python to calculate the next workday based on your country and state, ignoring weekends and holydays
from datetime import datetime, timedelta, date
import holidays
def nextBusinessDay(date, country, *state):
currentYearHolidays = holidays.country_holidays(country, subdiv=state[0] if state else "")[f"{date.year}-01-01":f"{date.year}-12-31"]
nextDay = date + timedelta(days=1)
while nextDay.weekday() in holidays.WEEKEND or nextDay in currentYearHolidays:
nextDay += timedelta(days=1)
@willnaoosmith
willnaoosmith / gist:9778445ee355f642852e95fb290627c9
Last active January 24, 2024 11:04
Powershell script to turn off all computers on a OU that is not on a ignore List
Import-Module active*
$ignoreList = @(
"PC-XXXX",
"PC-YYYY"
)
$rtn = $null
Get-ADComputer -Filter * -SearchBase "OU=COMPUTERS,OU=XXX,DC=DOMAINHERE,DC=local" |
ForEach-Object {