Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
coding

Breno Cota brenogcota

🎧
coding
View GitHub Profile
@brenogcota
brenogcota / tuts.md
Created April 24, 2023 16:35
Discard file changes from git PR
View tuts.md

Switch to the branch from which you created the pull request:

$ git checkout pull-request-branch

Overwrite the modified file(s) with the file in another branch, let's consider it's master:

git checkout origin/master -- src/package-lock.json
View pr_notify_googlechat.sh
function pr_notify() {
url=$(echo $(gh pr view | sed '10!d' | sed 's/.*://'))
title=$(echo $(gh pr view | sed '1!d' | sed 's/.*://'))
state=$(echo $(gh pr view | sed '2!d' | sed 's/.*://'))
author=$(echo $(gh pr view | sed '3!d' | sed 's/.*://'))
data=$(echo '{
"cards": [
{
"header": {
"title": "🤖 Code Review",
@brenogcota
brenogcota / zsh.rc
Created March 27, 2023 19:44
Create PR with Jira task id
View zsh.rc
function pr(){
repo="${PWD##*/}"
branch_name=$(git symbolic-ref -q HEAD)
task=$(echo $branch_name | awk -F/ '{print $NF}')
message=$(echo $(git log -n 1 --pretty=format:%B))
gh pr create --title "$message" --body "## $message [$task](https://<your-org>.atlassian.net/browse/$task)"
}
@brenogcota
brenogcota / bubble-sort.md
Created September 19, 2022 00:03
Bubble Sort example in Javascript and Go
View bubble-sort.md

Bubble Sort

Bubble Sort example in Javascript and Go

Javascript

function BubbleSort(array) {
	var swapCount = 1
	while (swapCount > 0) {
 swapCount = 0
@brenogcota
brenogcota / binary-search.md
Last active September 18, 2022 22:04
Example binary search in Javascript and Go
View binary-search.md

Binary Search

Example Binary search in Javascript and Go

Javascript

function BinarySearch(array, number) {
	var minIndex = 0
	var maxIndex = array.length - 1
	while (minIndex <= maxIndex) {
 var midIndex = Math.floor((maxIndex + minIndex) / 2)
@brenogcota
brenogcota / current-song.sh
Created July 29, 2022 18:41
Get Current Song Spotify
View current-song.sh
osascript -e 'tell application "Spotify" to artist of current track & " - " & name of current track'
@brenogcota
brenogcota / color-picker.js
Created May 30, 2022 16:45
Chrome default color picker snippet
View color-picker.js
function copy(value) {
setTimeout(async()=>console.log(
await window.navigator.clipboard.writeText(value)), 3000);
console.log("Color: " + value);
}
window.colorPicker = () => new EyeDropper().open().then((color)=> copy(color.sRGBHex))
window.colorPicker();
// create color picker snippet
@brenogcota
brenogcota / cssHandles.md
Last active May 30, 2022 17:18
make dynamic css classes
View cssHandles.md
function cssHandles(...arguments) {
   return arguments.reduce((acc, cur) => {
     if (typeof cur === 'string') return acc + ` ${cur}`;
     if (typeof cur === 'object') {
        return Object.keys(cur).map((key) => {
            if(cur[key]) return acc + ` ${key}`
            return acc
        }).filter(Boolean).join('').trim()
 
@brenogcota
brenogcota / terminal-utils.sh
Last active May 27, 2022 01:43
Show package json infos by terminal
View terminal-utils.sh
# terminal utils
alias pkg="cat package.json"
alias head-pkg="head package.json"
alias tail-pkg="tail package.json"
alias pkg-scripts="pkg | jq .scripts"
alias hgrep="history | grep "
@brenogcota
brenogcota / vtex-link.sh
Last active March 25, 2022 12:20
run vtex link in sub directories
View vtex-link.sh