Skip to content

Instantly share code, notes, and snippets.

View anchetaWern's full-sized avatar
🏠
Working from home

Wern Ancheta anchetaWern

🏠
Working from home
View GitHub Profile
@anchetaWern
anchetaWern / forward.md
Created August 9, 2022 09:59 — forked from jamestalmage/forward.md
Using Firebase to Authenticate to Google Drive

Note: There is a lot of information here, but if I have provided a link, it is probably something you should click on and read. OAuth is a complex enough subject on it's own, and hacking these two services together only adds to it.

Even so, I have found Firebase's API to be simpler than almost any other OAuth solution I have explored. When all is said and done, the important bits of code related to authentication is actually less than 10 lines. If you have ever tried to implement your own OAuth flow before, you know how amazing that is.

In the end, it may be worth using Firebase for authentication, even if that's the ONLY thing you use it for.

@anchetaWern
anchetaWern / aspect.js
Created July 24, 2019 03:47
get image aspect ratio
function getRandomInt(min, max) {
let sign = Math.random() < 0.5 ? -1 : 1;
min = Math.ceil(min);
max = Math.floor(max);
return (Math.floor(Math.random() * (max - min + 1)) + min) * sign;
}
function getNewHeight(oldWidth, oldHeight, newWidth) {
const aspectRatio = (oldWidth / oldHeight);
const newHeight = (newWidth / aspectRatio);
@anchetaWern
anchetaWern / basic_data_intent_sample.json
Created July 13, 2019 08:10
Pokedex Bot: sample Dialogflow response
{
"responseId":"xxxxx-xxx-xx-xxx-xxxxx-xxxxxxx",
"queryResult":{
"queryText":"Image of pikachu",
"parameters":{
"specs":"photo",
"pokemon":"Pikachu"
},
"allRequiredParamsPresent":true,
"fulfillmentText":"pikachu",
@anchetaWern
anchetaWern / get_type_effectiveness_intent_sample_request.json
Created July 13, 2019 08:07
Pokedex Bot: sample fulfillment server request body from Dialogflow
{
"responseId":"xxxx-xxx-xxx-xx-xxxxxx-xxxxx",
"queryResult":{
"queryText":"What is super effective against ice type?",
"parameters":{
"pokemon_types":"ice",
"type_effectiveness":"double_damage_from"
},
"allRequiredParamsPresent":true,
"fulfillmentMessages":[
@anchetaWern
anchetaWern / training phrases for get_type_effectiveness intent
Created July 12, 2019 05:40
Pokedex Bot: training phrases for get_type_effectiveness intent
what is strong against electric type?
what is weak against ground type?
what is rock type super effective against?
what is super effective against dragon type?
what is ground type no effect against?
what has no effect against ground type?
what has half damage against fire type?
what fire type has half damage to?
what bird type has double damage to?
what has double damage against fighting type?
@anchetaWern
anchetaWern / training phrases for evolution intent
Created July 12, 2019 05:27
Pokedex Bot: training phrases for evolution intent
what came before mew?
what's next after vulpix
what comes after machoke
tentacool evolves to
machamp evolves from
what does bayleef evolve from?
evolutions of charmander
third form of bulbasaur
second form of kabuto
first form of golem?
@anchetaWern
anchetaWern / training phrases of basic_data intent
Created July 12, 2019 05:14
Pokedex Bot: training phrases of basic_data intent
image of pokemon
pokemon image
photo of meowth
what are the abilities of hitmonlee
tell me about pokemon
what's the description of pokemon
what are the moves of pokemon
@anchetaWern
anchetaWern / pokemon.csv
Created July 12, 2019 03:37
Pokedex Bot: Pokemon entity
Abomasnow Abomasnow
Abra Abra
Absol Absol
Accelgor Accelgor
Aerodactyl Aerodactyl
Aggron Aggron
Aipom Aipom
Alakazam Alakazam
Alomomola Alomomola
Altaria Altaria
@anchetaWern
anchetaWern / pokemon_types.csv
Created July 12, 2019 03:37
Pokedex Bot: pokemon_types entity
bug bug
dark dark
dragon dragon
electric electric
fairy fairy
fighting fighting
fire fire
flying flying
ghost ghost
grass grass
@anchetaWern
anchetaWern / evolutions.csv
Created July 12, 2019 03:36
Pokedex Bot: evolutions entity
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 4 columns, instead of 5 in line 1.
"evolution_chain","evolution chain","evolution_chain","evolutions of"
"first_evolution","1st evolution","first evolution","first_evolution","second form"
"last_evolution","2nd evolution","final evolution","last evolution","last_evolution","second evolution","third form"
"next_form","came after","comes after","comes next","evolves to","next evolution","next form","next_form"
"previous_form","came before","comes before","evolves from","previous form","previous_form"