Skip to content

Instantly share code, notes, and snippets.

View fmartins-andre's full-sized avatar

André Martins fmartins-andre

View GitHub Profile
@fmartins-andre
fmartins-andre / git-remove-local-branches.sh
Last active December 20, 2024 13:19
Remove local branches that were merged
#!/bin/bash
echo 'Removing origins...'
git remote prune origin
BRANCHES=`git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}'`
if [[ `echo -e "$BRANCHES" | wc -w` -gt 0 ]]; then
echo 'Removing branches:'
echo $BRANCHES
@fmartins-andre
fmartins-andre / how-to-differ-objects-in-js.md
Created July 26, 2023 14:59
How to differ objects in JavaScript

To check what the real type of and variable, run this command:

  Object.prototype.toString.call(myVar)

It'll return something like [object Object]. The second word is the real type of the variable.

Some examples:

# Salvar num arquivo ~/encode.sh, conceder direito de execução e
# executar desta forma (adaptar nomes de diretórios e arquivos para seu caso):
# $ ~/encode.sh ~/Video/bigFile.mp4 ~/Video/smallFile.mp4
ffmpeg -i "$1" -vcodec h264 -acodec aac "$2"
@pietersp
pietersp / hybrid_gpu_archcraft_laptop_setup.md
Last active March 6, 2025 20:51
Archcraft linux setup on Intel/Nvidia hybrid laptop

Setting up my Hybrid graphics Laptop with Archcraft Linux

Setting up hybrid graphics linux is generally painful with the current state of Nvidia support. If you can avoid getting an Nvidia GPU based laptop if you plan to use Linux. I use a distro called Archcraft and had some issues specific to my setup (distro/hardware)

The hardware I am installing this on is a TongFang GM6TG7W (aka Wootbook Extreme IV). It has an Intel iGPU and an Nvidia 3070 Max-Q dGPU.

@fmartins-andre
fmartins-andre / useDebouncedFn.ts
Created October 24, 2022 16:25
Debounce a React.js function
import { DebouncedFunc } from "lodash"
import debounce from "lodash.debounce"
import { useMemo } from "react"
export default function useDebouncedFn<T extends (...args: any[]) => void>(fn: T, wait?: number) {
return useMemo(() =>(
debounce((...args:any[]) => {fn(...args)}, wait ?? 300) as DebouncedFunc<T>
), [fn, wait])
}
@Jeandcc
Jeandcc / getInstagramUsersThatDontFollowBack.js
Last active March 28, 2025 19:12
Open Instagram on your browser; Login to instagram; Open your browser's console (CTRL + SHIFT + J); Paste the code below; Update the username in the first line; RUN IT (Hit enter)
const username = "USER_NAME_HERE";
/**
* Initialized like this so we can still run it from browsers, but also use typescript on a code editor for intellisense.
*/
let followers = [{ username: "", full_name: "" }];
let followings = [{ username: "", full_name: "" }];
let dontFollowMeBack = [{ username: "", full_name: "" }];
let iDontFollowBack = [{ username: "", full_name: "" }];
@fmartins-andre
fmartins-andre / import-openvpn-networkmanager.md
Created December 13, 2021 11:53
Import an openvpn file to Gnome NetworkManager

Import OpenVPN file to NetworkManager

tags: linux, gnome, networkManager, pkcs12, p12

reference: askubuntu

This article intends to be reference when importing a openvpn file to NetworkManager on linux

  • Save the files in a folder;
  • Import the .ovpn file with the following command:
@fmartins-andre
fmartins-andre / run_elevated.ps1
Created March 15, 2021 17:54
A Powershell script to run executables in elevated mode
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true, Position = 0)][string]$exeFileName,
[Parameter(Mandatory = $true, Position = 1)][string]$credentialName
)
$wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
function CheckIfFileExists {
@cassidoo
cassidoo / useMedia.jsx
Last active October 27, 2022 16:13
An example of checking on a media query with React Hooks
function useMedia(query) {
const [matches, setMatches] = useState(window.matchMedia(query).matches)
useEffect(() => {
const media = window.matchMedia(query)
if (media.matches !== matches) {
setMatches(media.matches)
}
const listener = () => {
setMatches(media.matches)
@jesstelford
jesstelford / event-loop.md
Last active December 5, 2024 02:05
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code