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 / modulepattern-prototype.js
Created April 3, 2014 09:03
Module pattern along with prototypal inheritance...
namespace('MINE');
MINE.parent = (function() {
// private funcs and vars here
// Public API - constructor
var Parent = function (coords) {
// ...do constructor stuff here
};
@telekosmos
telekosmos / prototypical-functional-inheritance.js
Created April 3, 2014 09:06
Combination of Functional/Prototypal Inheritance
var Animal = function () {
var helloCount = 0;
var self = this;
//priviledge methods
this.AnimalHello = function() {
helloCount++;
console.log(self.Name + ' says hello (animalHello)');
};
@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);
};
}