Skip to content

Instantly share code, notes, and snippets.

// npm i ts-morph
const SOURCE_PATH = '/src/';
const TS_CONFIG_PATH = './tsconfig.json';
const { Project, Node } = require('ts-morph');
async function main() {
const project = new Project({ tsConfigFilePath: TS_CONFIG_PATH });
@initFabian
initFabian / README.md
Last active July 22, 2021 21:26
Switch in-between mongo versions

Stack Overflow Question

Note: In September 2019 mongodb was removed from homebrew core, so these instructions have been updated to use mongodb-community instead, installed from the external tap.

If your current installation is still the pre-September mongodb package then you will need to use that name when you unlink, stop, relink and start, on the lines marked with #*# below.

Another option is to simply upgrade away from the deprecated package now.

I already have the latest version of mongo installed, thanks to.

@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)
//Router.swift, Fabian's entire file
struct Router: URLRouter {
static var basePath: String {
return "https://private-85a46-routable.apiary-mock.com/"
}
struct User: Readable, Creatable, Updatable,
hasStatuses, hasPictures, hasPosts {
var route: String = "users"
var urlParams: String!
@initFabian
initFabian / RoutersProtocol.swift
Last active June 6, 2020 15:21
Complete basic router version of RoutesProtocol.swift that contains all the code along with comments.
//
// RoutesProtocol.swift
// RoutableApp
//
// Created by Fabian Buentello on 11/29/16.
// Copyright © 2016 ChaiOne. All rights reserved.
//
import Alamofire
{title} (#{id})
{sourceBranch} => {targetBranch}
{description}
{approvedByList}
typealias nested1Dictionary = [ String : AnyObject ]
typealias nested2Dictionary = [ String : nested1Dictionary ]
typealias nested3Dictionary = [ String : nested2Dictionary ]
typealias nested4Dictionary = [ String : nested3Dictionary ]
let parameters2: nested2Dictionary = ["data": ["attributes": jsonData]]
let parameters3: nested3Dictionary = [ "data": [ "attributes" : jsonData ]]
let parameters4: nested4Dictionary = ["data": ["attributes": ["data": jsonData]]]
@initFabian
initFabian / ChainableURLString.swift
Last active March 9, 2016 22:18
Chainable URL String
/*
* Chainable Url String example
* Run in Playground
*/
private var baseURL = "www.example.com"
struct AppURL {
struct User: CustomStringConvertible {
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:NSIndexPath)->UICollectionViewCell
{
var cell = collectionView.dequeueReusableCellWithReuseIdentifier("CELL", forIndexPath: indexPath) as CollectionCell
//using titleLabel as an example
if (_cell.titleLabel != nil) {
print("cell being reused")
} else {
// ....