Skip to content

Instantly share code, notes, and snippets.

View abelflopes's full-sized avatar
🚀

Abel abelflopes

🚀
View GitHub Profile
@abelflopes
abelflopes / README.md
Last active August 24, 2023 17:27
Sourcetree Custom Actions

Sourcetree Custom Actions

This gist is a collection of custom actions for Sourcetree. The actions abstract useful git commands & combinations.

Creating a custom action on Sourcetree

  1. Open sourcetree on a repository
  2. Go to the "OS top bar" > "Actions" > "Custom Actions" > "Edit..."
  3. You should now be on Sourcetree settings with the "Custom Actions" tab selected
@abelflopes
abelflopes / array-utils.ts
Last active August 30, 2022 15:27
Utils to remove repeated items from array & to sort based on equality
const getEqualitySorter =
<T = unknown>(sortList: T[]) =>
(a: T, b: T): number => {
for (const i in sortList) {
const orderItem = sortList[i];
if (a === orderItem && b !== orderItem) return -1;
if (a !== orderItem && b === orderItem) return 1;
}
@abelflopes
abelflopes / debounce.ts
Created August 22, 2022 20:51
Typescript debounce
type TimeOutSheet = Record<string, ReturnType<typeof setTimeout | typeof clearTimeout>>;
const timeOutSheet: TimeOutSheet = {};
const getFnId = (fn: () => unknown): string => {
return [fn.name, fn.toString()].join("").split(" ").join("");
};
export const debounce = (callback: () => void, ms: number): void => {
const toId = timeOutSheet[getFnId(callback)];