Skip to content

Instantly share code, notes, and snippets.

View dam1's full-sized avatar

Damien Galan dam1

View GitHub Profile
@dam1
dam1 / GmailResumableUpload.js
Last active May 27, 2019 08:00
Create an email with multiple attachment with resumable upload with Google Gmail Api
var fs = require('fs');
var request = require('request');
var EventEmitter = require('events').EventEmitter;
var mime = require('mime');
var util = require('util');
function gmailResumableUpload() {
this.byteCount = 0; //init variables
this.tokens = {};
this.filepath = '';
@dam1
dam1 / resumableUpload.js
Created January 8, 2018 13:44
Resumable Upload Google Drive Api - Node Js
var fs = require('fs');
var request = require('request');
var EventEmitter = require('events').EventEmitter;
var mime = require('mime');
var util = require('util');
function resumableUpload() {
this.byteCount = 0; //init variables
this.tokens = {};
this.filepath = '';
@dam1
dam1 / How to
Created September 25, 2017 16:51
Angular Ui Grid save state Service with localforage
$scope.gridOptions.onRegisterApi = function (gridApi) {
SaveStateGridService.init(gridApi);
};
<div
ui-grid="gridOptions"
ui-grid-save-state></div>
@dam1
dam1 / upload.js
Last active October 30, 2016 00:32
ionic-app-lib/lib/upload.js - ionic cloud upload folder build custom folder
var fs = require('fs');
var cheerio = require('cheerio');
var path = require('path');
var url = require('url');
var FormData = require('form-data');
var IonicProject = require('./project');
var Utils = require('./utils');
var Q = require('q');
var settings = require('./settings');
var ioLib = require('./io-config');
mongod --port 27017 --dbpath /data/db --replSet rs0 --smallfiles --oplogSize 128
mongod --port 27018 --dbpath /data/db2 --replSet rs0 --smallfiles --oplogSize 128
rs.initiate({_id:"rs0", members: [{"_id":1, "host":"127.0.0.1:27017"}]})
'use strict';
var request = require('request');
var async = require('async');
var htmlparser = require("htmlparser2");
var util = require('util');
var fs = require('fs');
var path = require('path');
/**
* Because we use FREE Yandex Translate api,
@dam1
dam1 / nodejs installation amazon linux ec2
Created May 24, 2016 11:25
nodejs installation amazon linux
sudo yum install gcc-c++ openssl-devel make
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
nvm install 4.4.4
@dam1
dam1 / login.js
Created January 20, 2016 16:45
Example Login controller test with Angular, Ionic, $translate, Karma, Jasmine
angular.module('starter.controllers')
.controller('LoginCtrl', function ($scope, $state, DataCacheService, $rootScope, User, $ionicPopup, $translate, $ionicLoading, InitializeService) {
$rootScope.AAuser={password: '', email: ''};
$scope.login=function () {
if ($rootScope.AAuser.password != null && $rootScope.AAuser.password.length >= 4) {
$ionicLoading.show();
var loginData=$rootScope.AAuser;
@dam1
dam1 / gist:a784c0a7dd0178fd5e6c
Last active January 20, 2016 16:40
Very simple mock function for the $translate service ( Angular js ) for Unit test with Jasmine / Karma
$translate Mock :
$translate=function (translation) {
return {
then: function (callback) {
var translated={};
translation.map(function (transl) {
translated[transl]=transl;
});
return callback(translated);
@dam1
dam1 / gist:5a90b75874d1ddbf95f6
Created November 3, 2014 02:35
ngAutocomplete details binding
'use strict';
/**
* A directive for adding google places autocomplete to a text box
* google places autocomplete info: https://developers.google.com/maps/documentation/javascript/places
*
* Usage:
*
* <input type="text" ng-autocomplete ng-model="autocomplete" options="options" details="details/>
*