Skip to content

Instantly share code, notes, and snippets.

View th3hunt's full-sized avatar
🎯
Focusing

Stratos Pavlakis th3hunt

🎯
Focusing
  • Blueground
  • Athens
View GitHub Profile
@th3hunt
th3hunt / introrx.md
Last active August 29, 2015 14:08 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

/* This shows how to use Object.create */
/** BASE MODEL **********************************/
function BaseModel(collection) {
this.collection = collection;
}
BaseModel.prototype.getCollection = function() {
return this.collection;
@th3hunt
th3hunt / import_honeybadger_notices.js
Last active August 29, 2015 14:05
Import certain honeybadger faults into a mongo DB
var args = process.argv.slice(2),
PROJECT_ID = args[0],
FAULT_ID = args[1],
// MONGO
MONGODB_URI = 'mongodb://localhost:27017/honeybadger',
mongodb = require('mongodb'),
mongoclient,
collection,
@th3hunt
th3hunt / umd.js
Created July 21, 2014 10:20
Universal Module Loader - copied from Jim Cowart's blog post
(function (root, factory) {
if(typeof define === "function" && define.amd) {
// Now we're wrapping the factory and assigning the return
// value to the root (window) and returning it as well to
// the AMD loader.
define(["postal"], function(postal){
return (root.myModule = factory(postal));
});
} else if(typeof module === "object" && module.exports) {
// I've not encountered a need for this yet, since I haven't
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@th3hunt
th3hunt / backbone.fwd.js
Created June 5, 2014 10:38
backbone.fwd + :target option
// backbone.fwd
// ------------
// Forward events from a source, through a target object
//
// v0.1.0
// Copyright (C)2014 Muted Solutions, LLC.
// Distributed under MIT license
//
// https://github.com/derickbailey/backbone.fwd
@th3hunt
th3hunt / s3upload-samples.js
Last active August 29, 2015 13:56
Sample usages of my extension to blueimp.fileupload, s3upload
// simple usage
// 2 retries on S3
$('input#file').s3upload({
registerUrl: 'foo/bar',
registerMethod: 'PUT',
submitStrategy: {
retries: 2
}
})
@th3hunt
th3hunt / bootstrapErrorRenderer.js
Created February 7, 2014 11:28
snippet of a bootstrap 2.3 style error renderer for use with backbone views
var errorRenderer = {
valid: function (view, attr, selector) {
var control, group;
control = view.$('[' + selector + '=' + attr + ']');
group = control.parents(".control-group");
group.removeClass("error");
if (control.data("error-style") === "tooltip") {
if (control.data("tooltip")) {
return control.tooltip("hide");
@th3hunt
th3hunt / api_controller_boilerplate.rb
Created January 24, 2014 12:56
Rails API Controller Boilerplate
require 'json_responder'
class Api::V1::ApiController < ActionController::Base
respond_to :json
before_filter :authenticate_user
self.responder = JsonResponder
rescue_from ActiveRecord::RecordNotFound, with: :not_found
rescue_from ActiveModel::MassAssignmentSecurity::Error, with: :bad_request
rescue_from AccessForbidden, with: :access_forbidden
rescue_from InvalidTransition, with: :invalid_transition
@th3hunt
th3hunt / .jslintrc
Last active January 7, 2018 02:40 — forked from irae/.jslintrc
JSLint configuration
{
/*** Globals ***/
// To ignore any custom global variables, enable the `predef` option and list
// your variables within it.
"predef": [
"window",
"document",
"jQuery",
"Backbone",
"Marionette",