Skip to content

Instantly share code, notes, and snippets.

View jimthedev's full-sized avatar

Jim Cummins jimthedev

View GitHub Profile
@jimthedev
jimthedev / 010_resource_files.js
Last active April 2, 2018 06:55
Shell script to automatically copy icons and splash screens in Cordova 3.5 / Ionic Framework
#!/usr/bin/env node
// this file lives at hooks/after_prepare/010_resource_files.js
// It copies my icon and splash screens to the correct location
// so that they will be loaded by Cordova 3.5
//
// This hook copies various resource files
// from our version control system directories
// into the appropriate platform specific location
@jimthedev
jimthedev / schema.json
Created September 8, 2014 15:38
schema.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"shift": {
"$ref": "members-rest-api/schema/#/definitions/shift"
},
"blah": {
"test": "boolean"
}
}
@jimthedev
jimthedev / init-angular2-ts-jspm
Created July 7, 2015 15:17
Angular2, TypeScript, JSPM starter script
# DESCRIPTION
# Performs the commands needed to download and set up a new angular2 project using typescript and jspm
#
# Assumes you have these:
# - git
# - node / io.js
# - npm
# - npm install -g jspm@beta **NOTE**: you must have the beta release of jspm installed
#
# USAGE
@jimthedev
jimthedev / falcor-angular2-object-to-array.js
Created August 17, 2015 22:03
Falcor object flatten to array for Angular 2
/**
* I am new to falcor and it is under development
* but I find that I keep needing to flatten
* integer keyed objects into arrays so that I can
* use them with Angular 2's NgFor directive.
*
* Perhaps I just need to write an angular pipe
* but I'm curious if there's a way to have falcor
* output arrays instead of keyed objects.
*
@jimthedev
jimthedev / falcor-express-server-with-logging.js
Created August 20, 2015 22:05
Falcor with express featuring split route files and route access logging
// ...
// ... SNIP: You should include and wire up express as needed before this
// ...
// Falcor deps
var falcor = require('falcor');
var falcorExpress = require('falcor-express');
var bodyParser = require('body-parser');
// ROUTES
@jimthedev
jimthedev / LifecycleCallbackTracker.ts
Last active September 23, 2015 21:06
Lifecycle callback tracking / logging for Angular 2 (with console color by component)
/**
* Have your component extend this class temporarily when you
* need lifecycle callback tracking / debugging. See second
* file for how to use this class in your component.
*/
class LifecycleCallbackTracker {
staticCallCounts: Object = {};
textColor: string;
constructor(textColor?: string) {
@jimthedev
jimthedev / typescript.json
Created September 23, 2015 05:16
A few Visual Studio Code 0.8 Snippets for TypeScript and Angular 2
{
"New NG2 Component (Item)": {
"prefix": "ng2c",
"body": [
"import {Component, View, CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/angular2';",
"// import {ExampleListComponent} from '../example/example-list.component';",
"",
"@Component({",
" selector: '${1:dashed-name}',",
" properties: ['id']",
@jimthedev
jimthedev / ionic-toggle-platform-bookmarklet.js
Last active December 7, 2015 18:54
Ionic2 page reload bookmarklet to toggle between ionic platforms
javascript:void((function(){var loc = location.href; var base = loc.split('?')[0]; loc.indexOf("?") == -1 || loc.indexOf("?ionicplatform=ios") > -1 ? (location.href = base+"?ionicplatform=android") : (location.href = base+"?ionicplatform=ios");})());
@jimthedev
jimthedev / reduceOrientation.js
Created February 17, 2016 22:36
Reduce orientation events coming from react-native-orientation npm module
function _reduceOrientation(lastOrientation, orientation) {
if(orientation==='UNKNOWN' && lastOrientation==='UNKNOWN') {
return 'UNKNOWN';
}
switch(orientation) {
case 'LANDSCAPE':
case 'PORTRAIT':
return orientation;
@jimthedev
jimthedev / index.js
Last active July 6, 2016 03:57
requirebin sketch
var mobx = require('mobx');
var _ = require('lodash');
/*
MOBX in VANILLA ES5
Notes are based on Matt Ruby's Open Source North Talk:
Practical React with MobX
https://www.youtube.com/watch?v=XGwuM_u7UeQ