Skip to content

Instantly share code, notes, and snippets.

View brotoo25's full-sized avatar

Broto brotoo25

  • Broto Tech.
  • Brazil
View GitHub Profile
@brotoo25
brotoo25 / instagram_video_post.json
Created June 19, 2022 20:56
Instagram Video Post Payload
[
{
"postUrl":"",
"description":"",
"commentCount":1,
"likeCount":1,
"pubDate":"2022-04-20T16:20:00.000Z",
"likedByViewer":false,
"isSidecar":false,
"type":"Video",
@brotoo25
brotoo25 / node-cron.js
Created January 21, 2022 00:51
Node Cron Sample
// package.json
"dependencies": {
"node-cron": "^3.0.0"
}
// code.js
const cron = require('node-cron')
// Run currency refresh every 30 minutes
@brotoo25
brotoo25 / notion.js
Last active July 18, 2021 17:00
Notion API - Update table with currency prices
const dotenv = require('dotenv').config()
const { Client } = require('@notionhq/client')
const notion = new Client({
auth: process.env.NOTION_TOKEN,
})
const databaseId = process.env.NOTION_DATABASE_ID
const defaultCurrency = process.env.DEFAULT_CURRENCY
@brotoo25
brotoo25 / currency.js
Created July 18, 2021 03:58
Query Currency price using 'Api de Moedas'
/**
* Get most recent price of any currency listed at 'API de Moedas'.
* https://docs.awesomeapi.com.br/api-de-moedas
*
* Params: (from) - Currency Code. Ex: USD, BRL, NZD
* (to) - Currency Code. Ex: USD, BRL, NZD
**/
async function fetchCurrencyPrice(from, to) {
try {
if (from.toUpperCase() == to.toUpperCase()) {
@brotoo25
brotoo25 / crypto.js
Created July 18, 2021 03:19
Query cryptocurrency price using CoinGecko
/**
* Get most recent price of any crypto listed at CoinGecko.
* Params: (coin) - Crypto ID from CoinGecko, all crypto IDs can be found at:
* https://api.coingecko.com/api/v3/coins/list?include_platform=false
* (defaultCurrency) - Base Currency Code to calculate price. Ex: USD, BRL, NZD
**/
async function fetchPriceOnCoinGecko(coin, defaultCurrency) {
try {
const response = await axios.get(`https://api.coingecko.com/api/v3/simple/price?ids=${coin}&vs_currencies=${defaultCurrency}`);
return response.data[`${coin}`][defaultCurrency.toLowerCase()]
@brotoo25
brotoo25 / create.sh
Last active May 6, 2021 01:28
Script to create Flutter Project + Github Repo
#!/bin/bash
#############################################################
#
# REQUIRES:
# - GitHub CLI (https://cli.github.com/)
# Script to automatically create default project structures
# along side its Github Repository, all integrated and with
# default 'first commit' pushed to remote repository.
#
@brotoo25
brotoo25 / .gitconfig
Last active March 28, 2021 22:05
My Git Aliases
[alias]
s = status
unstage = reset HEAD --
undo = reset HEAD~1 --mixed
done = !git push origin HEAD
get = !git pull origin HEAD
go = checkout
back = checkout -
del = branch -D
new = checkout -b
@brotoo25
brotoo25 / emulator.command
Last active July 29, 2021 13:35
Script to run Android Emulator on Mac when wifi not running
#!/bin/bash
~/Library/Android/sdk/emulator/emulator -avd Nexus_5X_API_28_x86 -dns-server 8.8.8.8,8.8.4.4 &
osascript -e 'tell application "Terminal" to close first window' & exit
# Instead of 'Nexus_5X_API_28_x86', use your own emulator AVD image name, which can be found running the following command:
# ~/Library/Android/sdk/emulator/emulator -list-avds
#
# Also don't forget to give it execution permissions with "chmod +x".