Skip to content

Instantly share code, notes, and snippets.

View reynaldot's full-sized avatar

Reynaldo Tortoledo reynaldot

View GitHub Profile
@reynaldot
reynaldot / await-async-example.js
Last active January 25, 2019 23:45
Await/Async example. A function marked as "async" is no longer a regular function but an AsyncFunction that wraps whatever it returns in a Promise.
function slowGreeting(timeout) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Hello WorldzZzZzzz');
}, timeout);
})
}
// Assigns the promise value to a variable and returns the variable:
async function getSlowGreeting() {
@reynaldot
reynaldot / sample.vine.js
Created February 6, 2014 20:00
Sample vine object
{
liked: 0,
foursquareVenueId: null,
userId: 988872511955898400,
private: 0,
likes: {
count: 0,
records: [
],
@reynaldot
reynaldot / keen-test.js
Created November 30, 2013 03:42
Adds a single event to a collection and queries the analytics API for a simple event count.
var should = require('should')
, assert = require('assert')
, request = require('request')
, qs = require('querystring');
describe('keen api', function () {
var projectId = 'my_project_id'
, masterKey = 'my_master_key'
, writeKey = 'my_write_key'
, readKey = 'my_read_key'
@reynaldot
reynaldot / classical-pattern-1.js
Last active December 20, 2015 19:48
Followup notes on javascript inheritance after reading some of Stoyan Stefanov's Javascript Patterns book.
var assert = require('assert');
/**
* Default pattern
*
* Inherits properties added to this and prototype
*/
// parent constructor:
function Parent(name) {
@reynaldot
reynaldot / ar_namedscoped_models_patch.rb
Created February 11, 2011 01:36
ActiveRecord 2.3.8 - Associations + namescoped models patch.
# ActiveRecord 2.3.8 - Associations + namescoped models patch.
#
# Problem:
# module App::Model
# class Base < ActiveRecord::Base
# # some base class logic...
# end
#
# class User < App::Model::Base
# set_table_name :users