Skip to content

Instantly share code, notes, and snippets.

View jdnichollsc's full-sized avatar
🏠
Working from home

J.D Nicholls jdnichollsc

🏠
Working from home
View GitHub Profile
//Copy the collection to prevent deleting data
db.nameCollection.copyTo('newNameCollection')
//See the collections in the database
db.getCollectionNames()
//See if exist duplicate data
db.orders.aggregate([
{
$group: {
var file = fileOrFileArray[i];
if (file.indexOf("data:application") >= 0) {
var fileData = Windows.Security.Cryptography.CryptographicBuffer.decodeFromBase64String(file.split(',')[1]);
var memoryStream = new Windows.Storage.Streams.InMemoryRandomAccessStream();
var dataWriter = new Windows.Storage.Streams.DataWriter(memoryStream);
dataWriter.writeBuffer(fileData);
dataWriter.storeAsync().done(function () {
@jdnichollsc
jdnichollsc / docsController.js
Last active January 26, 2016 10:39
PouchDB with SQLite plugin in Ionic Framework (Pre-populated database) => Using service pattern
controllers.controller('DocsController', ['$scope', '$ionicPlatform', 'Docs', 'Products' function ($scope, $ionicPlatform, Docs, Products) {
$scope.products = [];
$scope.allDocs = [];
$ionicPlatform.ready(function () {
//Insert a new product
Products.addProduct({
name : 'Milk',
@jdnichollsc
jdnichollsc / game.js
Last active February 17, 2016 05:23
Phaser Kinetic Scrolling Plugin - Draft (Swipe and Tap)
var game = new Phaser.Game(1024, 768, Phaser.AUTO, '', {
init: function () {
this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
this.scale.pageAlignHorizontally = true;
this.scale.pageAlignVertically = true;
//Load the plugin
this.game.kineticScrolling = this.game.plugins.add(Phaser.Plugin.KineticScrolling);
},
create: function () {
@jdnichollsc
jdnichollsc / Output
Created November 2, 2015 17:38
No valid MSBuild was detected for the selected target.
1>------ Build started: Project: Blank, Configuration: Release Windows-x64 ------
1> Your environment has been set up for using Node.js 0.12.7 (x64) and npm.
1> ------ Ensuring correct global installation of package from source package directory: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\APACHECORDOVATOOLS\packages\vs-tac
1> ------ Name from source package.json: vs-tac
1> ------ Version from source package.json: 1.0.13
1> ------ Package already installed globally at correct version.
1> ------ Cordova tools 5.3.1 already installed.
1> ------ Build Settings:
1> ------ Build Settings:
1> ------ platformConfigurationBldDir: C:\Apps\Windows\Blank\Blank\bld\Windows-x64\Release
@jdnichollsc
jdnichollsc / fileService.js
Last active May 2, 2016 18:18
Download and Open File with ngCordova in Ionic Framework
(function() {
'use strict';
angular
.module('App')
.factory('Files', Files);
Files.$inject = ['$window', '$cordovaFileTransfer', '$ionicLoading', '$cordovaFileOpener2'];
function Files($window, $cordovaFileTransfer, $ionicLoading, $cordovaFileOpener2) {
return {
@jdnichollsc
jdnichollsc / script.js
Last active May 27, 2016 20:52
Repeat HTTP request removing cookies and localStorage
var foo = function(){
//Clear cookies
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
@jdnichollsc
jdnichollsc / assign.js
Last active August 8, 2016 21:40
Accesing Nested Object Properties
var assignProperty = function (object, property, value) {
if (typeof property === "string") {
property = property.split(".");
}
if (property.length > 1) {
var e = property.shift();
assignProperty(object[e] = Object.prototype.toString.call(object[e]) === "[object Object]" ? object[e] : {}, property, value);
} else {
object[property[0]] = value;
}
@jdnichollsc
jdnichollsc / AWS Elastic Beanstalk
Last active October 11, 2016 16:31
AWS EXPERIENCE DAY
Servicio para deployar y administrar aplicaciones y servicios web en Java, .NET, PHP, Node.js, Python, Ruby y Docker.
Infraestructura lista para lanzar la aplicación.
@jdnichollsc
jdnichollsc / array.js
Last active January 17, 2017 06:07
Filter arrays with lodash, sift.js, and other alternatives
//pretty printing JSON => JSON.stringify(obj, null, 2);
var product = {
"productTypeCode": "productTypeEnergy",
"quantities": [
{
"period": {
"startDate": new Date("2017-01-13T05:00:00.000Z"),
"endDate": new Date("2017-01-31T05:00:00.000Z"),
"dayType": {
"normal": true,