Skip to content

Instantly share code, notes, and snippets.

View austinmao's full-sized avatar

Austin Mao austinmao

View GitHub Profile
var nodegit = require('nodegit'); Promise.promisifyAll(nodegit)
var fse = require("fs-extra"); Promise.promisifyAll(fse)
var path = "../tmp/nodegit-clone-demo";
exports.git = (function() {
var parentFn = 'git:'
var log = require('debug')(parentFn);
log('')
var createNewRepo = function() {
@austinmao
austinmao / bootstrap.js
Last active March 29, 2020 00:57
Adding Mongoose to Sails in a manner that binds promisified Mongoose functions to `Model.mongoose` preserves blueprints (auto-generated action routes), and most importantly does not remove the Waterline ORM. Note: this is done with sails-babel (ES2015) hook.
/**
* Bootstrap
* (sails.config.bootstrap)
*
* An asynchronous bootstrap function that runs before your Sails app gets lifted.
* This gives you an opportunity to set up your data model, run jobs, or perform some special logic.
*
* For more information on bootstrapping your app, check out:
* http://sailsjs.org/#/documentation/reference/sails.config/sails.config.bootstrap.html
*/
@austinmao
austinmao / example.js
Last active August 29, 2015 14:25
Finds the value at key of a nested object using lodash
// here is the nested object to do the find on
{
"level1": {
"level2": {
"level3": {
"level4": {
"level5": "value"
}
}
}
@austinmao
austinmao / UserModel.test.js
Created August 12, 2015 22:34
Functions for tearing down db records inserted into the db when unit testing with mocha
import Promise from 'bluebird'
Promise.promisifyAll(User.mongoose)
const _describe = new Describe('user')
_describe.cleanly('User Model', () => {
describe('create', done => {
User.mongoose.createAsync()
.then(() => User.mongoose.findAsync())
.then(results => {
@austinmao
austinmao / 1.reducers_gallery.js
Last active November 26, 2015 03:03
Higher Order Component and Higher Order Reducer example that creates a reusable, redux-connected photo gallery that will store a `selected` state in a unique, nested name + key object in the redux store. Follow this order: reducers/gallery.js -> components/reduxGallery.js -> components/PhotoItems.js -> components/Gallery.js
@austinmao
austinmao / 1.gallery.js
Last active January 13, 2016 05:04
Higher Order Component and Higher Order Reducer example that creates a reusable, redux-connected photo gallery that will store a `selected` state in a unique, nested name + key object in the redux store. This differs from https://gist.github.com/austinmao/b2da974571d11e3f24f3 by allowing the key to be passed in via props from one component to an…
@austinmao
austinmao / error.txt
Created December 3, 2015 01:45
css-to-radium conversion error
Module parse failed: /Users/austinmao/Sites/aditive-frontend/src/components/Global/LeftMenu/navbar.style.js Line 2: Unexpected token :
[0] You may need an appropriate loader to handle this file type.
[0] | {
[0] | '.nav-bar-container:before, .nav-bar-container:after': {
[0] | content: '" "',
[0] | display: 'table'
@austinmao
austinmao / App.js
Created February 18, 2016 02:54
Attempt at adding Progress bar for loading
/**
* App.js
* parent component of app
*/
/* global $ */ // spec jquery global
/* boilerplate */
import React, {Component, PropTypes} from 'react';
import {connect} from 'react-redux';
import {routeActions} from 'react-router-redux';
@austinmao
austinmao / apis.js
Last active February 24, 2016 04:23
connects to server api specified in helpers/apis, loads, normalizes (flattens) the data, and then stores in redux
/**
* @name apis.js
* @fileOverview api endpoints and schemas
* @exports {endpoint, schema, entity} for each api
*/
import _ from 'lodash'; // eslint-disable-line id-length
import schema, {entities} from 'helpers/normalize';
const singularEndpoints = {
@austinmao
austinmao / SDKSwap.cs
Created December 15, 2016 08:26 — forked from flarb/SDKSwap.cs
Swap between Unity3D Google Cardboard and Gear VR / OVR Mobile SDKs. It swaps out the Android manifest files when you switch platforms--pretty much all you need (aside from wrapping the APIs) to switch platforms.
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
public class SDKSwap : EditorWindow {
static string _cardboardPath;
static string _OVRPath;