Skip to content

Instantly share code, notes, and snippets.

View tettoffensive's full-sized avatar

Stuart Tett tettoffensive

View GitHub Profile
@gregfenton
gregfenton / fetch-user-records-from-google-sheets.js
Last active December 7, 2022 23:00
Downloads data from a Google Sheets worksheet and stores in a local JSON file -- command-line JavaScript/node
/**
* A script that:
* 1. loads Google Sheets API keys and spreadsheet IDs (see GOOGLE_API_KEY)
* 2. connects to the identifed Google Sheet
* 3. grabs the data from a named Worksheet (see SHEET_TO_GET)
* 4. iterates over each row (see processUserRows())
* 5. puts them into a JSON structure
* 6. and writes that out to a file (see FILE_NAME)
*
* To run this script, I have this in my package.json:
@gregfenton
gregfenton / load_json_to_firstore.js
Last active December 4, 2023 16:24
Loads JSON data into a Firestore database (cloud or local emulator) -- command-line JavaScript/node
/**
* load_json_to_firstore.js
*
* This code is a "node script" used to load data into your Firestore database, either in "the cloud" or the emulator.
*
* The script is a "client app", so it logs in with Firebase Auth using email/password from the variable USER1.
*
* The USER1 user (the.admin.guy@test.com) must exist in your Firebase project and have write access
* to the collection(s) you are populating. You can create that account via Firebase Console >> Authentication.
*
@thehappydinoa
thehappydinoa / $React.png
Last active March 17, 2024 16:14
Awesome React Native
$React.png
@sturmenta
sturmenta / firestore2json.js
Last active October 28, 2022 19:03
firestore to json & json to firestore
const admin = require('firebase-admin');
const fs = require('fs');
const serviceAccount = require('../../../../../../Private/myschool-data_transfer-key.json');
admin.initializeApp({ credential: admin.credential.cert(serviceAccount) });
const schema = require('./schema').schema;
const firestore2json = (db, schema, current) => {
@rcugut
rcugut / [GUIDE] macos yarn nvm install.md
Last active July 10, 2023 11:49
GUIDE for mac OS X yarn nvm node install

GUIDE to install yarn, nvm (node) on macOS

last update: Dec 4, 2020

Assumptions:

  • macOS >= 10.14 (Mojave); tested with 10.15 (Catalina)
  • homebrew properly installed
@Lwdthe1
Lwdthe1 / usaCities.js
Last active April 13, 2024 14:18
JSON of 5,950+ USA Cities and Their States - Presented by https://www.ManyStories.com
[
{'city': 'Abbeville', 'state': 'Louisiana'},
{'city': 'Aberdeen', 'state': 'Maryland'},
{'city': 'Aberdeen', 'state': 'Mississippi'},
{'city': 'Aberdeen', 'state': 'South Dakota'},
{'city': 'Aberdeen', 'state': 'Washington'},
{'city': 'Abilene', 'state': 'Texas'},
{'city': 'Abilene', 'state': 'Kansas'},
@brunobraga95
brunobraga95 / copyFirestoreDB.js
Last active August 12, 2021 14:35
Copy firestore database
const firebase = require('firebase-admin');
var serviceAccountSource = require("./source.json"); // source DB key
var serviceAccountDestination = require("./destination.json"); // destiny DB key
const sourceAdmin = firebase.initializeApp({
credential: firebase.credential.cert(serviceAccountSource)
});
const destinyAdmin = firebase.initializeApp({
@designatednerd
designatednerd / CountableIntEnum.swift
Last active August 3, 2018 06:14
Swift 3 Helpers for getting all the cases of a given enum [Swift 3]
import Foundation
/**
A swift protocol to make any Int enum able to count its cases.
Super-useful for making enums to help you deal with sections in tableviews without having to maintain a case for the count of the enum.
Originally developed by Logan Wright for Swift 2.0 here:
https://gist.github.com/LoganWright/c8a26b1faf538e40f747
@xhjkl
xhjkl / Draw+LoadImage.swift
Last active April 24, 2020 03:09
OpenGL wrapper for Swift
//
// Convenience extensions to read images into textures.
//
import UIKit
import OpenGLES
extension DrawContext {
/// Make texture with an image in it.
public func makeTexture(id: TextureId? = nil, width: Int? = nil, height: Int? = nil, fromFileContents filename: String) -> TextureId {
@initFabian
initFabian / AlamofireRouterExample_Extended.swift
Last active June 6, 2020 15:27
An Alamofire router example used in a post, https://chaione.com/blog/rethinking-routers-swift-protocol-oriented-programming-part-1, to show how a router with multiple paths would look like.
// Router.swift
import Alamofire
enum Router: URLRequestConvertible {
static let baseURLString = "https://private-85a46-routable.apiary-mock.com/"
case readUsers
case createUser(parameters: Parameters)