Skip to content

Instantly share code, notes, and snippets.

View RhinoLance's full-sized avatar

Lance Conry RhinoLance

View GitHub Profile
@RhinoLance
RhinoLance / app.component.ts
Created February 14, 2018 22:27
Ionic not displaying page until window resize
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {Observable} from 'rxjs/Rx';
import { Subject } from "rxjs/Rx";
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
@RhinoLance
RhinoLance / Angular_code.js
Last active August 29, 2015 14:20
Angular and Jasmine testing withservice using $q
angular.module('MyModule', [])
// DB wrapper
.factory('rsDb', function($q, DB_DEFINITION) {
var self = this;
self.db = null;
self.init = function() {
self.db = window.openDatabase(DB_DEFINITION.name, '1.0', 'database', -1);
var promises = [];
@RhinoLance
RhinoLance / RhinoLib.Leaflet.js
Created June 26, 2014 15:28
Leaflet offline tile caching
/*global L, LocalFileSystem, RhinoLib, async, FileTransfer, Connection */
var cacheMode = {
PRE_CACHE: 0x1,
CACHE_IN_BOUNDS: 0x2,
CACHE_OUTSIDE_BOUNDS: 0x4
};
L.TileLayer.CachedTiles = L.TileLayer.extend({
@RhinoLance
RhinoLance / replaceProperties
Last active August 29, 2015 14:02
Replace object properties from other object
var setObjectOptions = function(element, args){
var targetObj = allObjects[element];
for (var prop in args) {
// important check that this is objects own property
// not from prototype prop inherited
if(args.hasOwnProperty(prop)){
targetObj[prop] = args[prop];
}
}
import sys
import os
import time
import io
import scipy.misc
import pprint
from PIL import Image
from skimage import data
from skimage.io import imread
@RhinoLance
RhinoLance / fileCatcher.js
Created April 24, 2014 07:16
node.js file upload trouble
var http = require('http');
var fs = require('fs');
http.createServer(function(request,response){
response.writeHead(200);
var destinationFile = fs.createWriteStream(fileName);
request.pipe(destinationFile);
var fileSize = request.headers['content-length'];
//This doesn't work. The test can't find the service
angular.module('RhinoLib').service('sqLite', function( $q ) {
this.initPromise = null;
this.oDb = null;
}
//This works perfectly. I just renoved the $q parameter for the service
angular.module('RhinoLib').service('sqLite', function() {
@RhinoLance
RhinoLance / gist:9497816
Created March 12, 2014 00:07
Local caching
_loadTile: function (tile, tilePoint) {
//try{
var that = this;
tile._layer = this;
tile.onload = this._tileOnLoad;
tile.onerror = this._tileOnError;
tilePoint.z = this._getZoomForUrl();
@RhinoLance
RhinoLance / gist:9333441
Created March 3, 2014 20:03
Save and move images taken with Cordova camera plugin.
ModFormCommon.PhotoSuccess = function (imageURI) {
var fsSuccess = function (fileEntry) {
//alert("got image file entry: " + fileEntry.fullPath);
var gotFileSystem = function (fileSystem) {
fileSystem.root.getDirectory(
ModPhoto.FileStore,
{ create: true },
@RhinoLance
RhinoLance / gist:9059555
Last active August 29, 2015 13:56
Cordova notification wrappers
if (typeof navigator.notification === 'undefined') {
navigator.notification = {
confirm: function (message, confirmCallback, title, buttonLabels) {
setTimeout(function (){
if (window.confirm(message)) {
confirmCallback(1);
}
else {
confirmCallback(2);