Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
coding

Breno Cota brenogcota

🎧
coding
View GitHub Profile
@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
@brenogcota
brenogcota / branch-name-terminal.sh
Last active March 18, 2022 14:43
add git branch name like oh-my-zsh
View branch-name-terminal.sh
## https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] $(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
@brenogcota
brenogcota / interfaces.ts
Created January 10, 2022 16:38
interfaces
View interfaces.ts
/* Autocomplete */
interface ISearchAutocomplete{
queries: Array<IQueries>
products: Array<IProducts>
}
interface IProducts{
id: string
name: string
price: number