Skip to content

Instantly share code, notes, and snippets.

View wovalle's full-sized avatar

Willy Ovalle wovalle

View GitHub Profile
May Challenge: https://gist.github.com/wovalle/a86a76bc20d8c886342040f54875f291
@wovalle
wovalle / CH4113N93-1337.js
Last active May 24, 2020 20:10
LeetCode May 2020
// LeetCode May 2020
@wovalle
wovalle / ig.js
Created March 27, 2019 14:57
Only works in an instagram post page. Takes the text you have in the comment input and post each line as a comment every 2s
const frm = document.querySelector('article form')
const commentBox = frm.querySelector('textarea')
const postButton = frm.querySelector('button')
const comments = commentBox.value.split('\n').filter(c => c.length)
const postComment = comment => {
console.log('Commenting: ', comment)
let lastValue = commentBox.value
// Bands formed from 1990 onwards
await bandRepository
.whereGreaterOrEqualThan('formationYear', 1990)
.find();
// Bands whose name is Porcupine Tree
await bandRepository
.whereEqualTo('name', 'Porcupine Tree')
.find();
import { BaseFirestoreRepository, CustomRepository } from 'fireorm';
import Band from './models/Band';
@CustomRepository(Band)
class BandRepository extends BaseFirestoreRepository<Band> {
async getProgressiveRockBands(): Promise<Band[]> {
return this.whereArrayCointain('genres', 'progressive-rock').find();
}
}
import { getRepository } from 'fireorm';
import Band from './models/Band';
const bandRepository = getRepository(Band);
const band = await bandRepository.findById('red-hot-chili-peppers');
const albumsAfter2000 = await band.albums.whereGreaterOrEqualThan('year', 2000).find();
import { Collection, SubCollection, ISubCollection } from 'fireorm';
class Album {
id: string;
name: string;
year: number;
}
@Collection()
export class Band {
import Band from './models/Band'
import { getRepository } from 'fireorm'
const bandRepository = getRepository(Band, firestore);
// Create a band
const band = new Band();
band.name = "A Perfect Circle";
band.formationYear = 1999;
band.genres = ['alternative-rock', 'hard-rock']
import * as admin from 'firebase-admin';
const serviceAccount = require('../firestore.creds.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`,
});
const firestore = admin.firestore();
import { Collection } from 'fireorm';
@Collection()
class Band {
id: string;
name: string;
formationYear: number;
genres: Array<string>;
}