Skip to content

Instantly share code, notes, and snippets.

View telekosmos's full-sized avatar
💭
👻

Guillermo C. Martínez telekosmos

💭
👻
View GitHub Profile
@telekosmos
telekosmos / fileservices.js
Last active August 29, 2015 14:01
angular service factory to use the Filesystem API. ONLY WORKS IN CHROME!!!
/* Check the file content
//var filename = FileHandler.getFileName();
// FileHandler.checkRateFile();
// current use:
FileHandler.checkRateFile(function(counter) {
$scope.counter = counter;
console.log('$scope.counter: '+$scope.counter);
});
@telekosmos
telekosmos / gist:b865d821ce6c365a9129
Created July 19, 2014 10:35
"new" sequelize support for promises example
// not using Q for promises (Promises support was added in mid-2013 to
// Sequelize, https://github.com/sequelize/sequelize/issues/288
var Sequelize = require('sequelize');
var sequelize = new Sequelize('database_name', 'username', 'password', {
dialect: 'sqlite',
storage: ':memory:'
});
var User = sequelize.define('User', {
username: Sequelize.STRING,
@telekosmos
telekosmos / dbprototype
Created February 13, 2015 11:45
Promise-database prototype
Promise = require 'bluebird'
_ = require 'lodash'
jsonObj =
db:
host: "localhost",
name: "appform",
user: "gcomesana",
@telekosmos
telekosmos / downloader.v1
Created February 17, 2015 10:04
Node.js downlaoder
var https = require('https');
var fs = require('fs');
var options = {
hostname : 'wordpress.org',
port : 443,
path : '/latest.zip',
method : 'GET'
};
var file = fs.createWriteStream("wp_latest.zip");
// Both export declaration seems to have the same semantics as for babeljs.io
// export class Welcome {
class Welcome {
constructor(){
this.heading = 'Welcome to the Aurelia Navigation App!';
this.firstName = 'John';
this.lastName = 'Doe';
}
get fullName(){
@telekosmos
telekosmos / gist:b3152b3186e725ffac55
Created March 13, 2015 11:36
CS-ES6 export syntax
class Welcome
`console.log("Starting up")`
constructor: () ->
@heading = 'Welcome'
@name = 'John'
@firstname = 'Doe'
fullname: () ->
"#{@name} #{@firstname}
@telekosmos
telekosmos / gist:0c38f76060c75c7f7253
Last active August 29, 2015 14:21
plugin-typescript issues

The point is it fails to load definition files when they are referred from the single tsd.d.ts. Ex: typings/tsd.d.ts (jquery/jquery.d.ts just under typings)

index.ts ... ...

@telekosmos
telekosmos / stub-function.js
Created August 5, 2015 15:49
Stubbing a function that does not belong to an object
var jwt = function(x) {
console.log('transform stuff');
}
function thingToBeTestedFactory(jwt) {
return function(x) {
return jwt(x);
};
}
@telekosmos
telekosmos / uniq.js
Last active November 15, 2022 17:13
Remove duplicates from js array (ES5/ES6)
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});
@telekosmos
telekosmos / file-content-stream.js
Created October 6, 2015 09:33
node file content stream filter
if (file.isStream()) {
var
encoding = 'utf8',
contents = [];
function write (chunk, enc, done) {
contents.push(chunk);
done();
}