Skip to content

Instantly share code, notes, and snippets.

View chrisnicola's full-sized avatar

Chris Nicola chrisnicola

View GitHub Profile
@chrisnicola
chrisnicola / angularjs.md
Created March 20, 2014 20:25
AngularJS Tutorial Syllabus

Course Outline

  • 1 Overview of AngularJS (1hr)
    • 1.1 AngularJS architecture overview
    • 1.2 The Angular Batarang
    • 1.3 Using Karma
    • 1.4 Get Setup
    • 1.5 Angular Seed Tour
    • 1.6 Build: Hello World
  • Bind tweet to input
# Provides angular filters for lodash or underscore functions
module = angular.module('_filters', [])
_(_).functions().each (name) ->
n = name
module.filter '_' + n, -> _[n]
@chrisnicola
chrisnicola / xirr.rb
Last active August 29, 2015 14:02 — forked from sapient/xirr.rb
Performs XIRR calculations using Ruby's Newton#nlsolve
require 'date'
require 'bigdecimal/newton'
require 'bigdecimal/math'
class XIRR
include Newton
def initialize(trans)
@trans = trans
@zero = 0.to_d
| <script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;
s.src='https://widget.intercom.io/widget/#{ENV['INTERCOM_APP_ID']}';
var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
require 'active_support/key_generator'
module ActionDispatch
module Session
class JWTStore < AbstractStore
GENERATOR_KEY = "action_dispatch.key_generator".freeze
JWT_SECRET_SALT = "jwt secret salt".freeze
def initialize
super
import {Component, Inject, AfterViewInit} from 'angular2/core';
import {upgradeAdapter} from 'upgrade_adapter';
const template = require('./template.html');
// Step 1: Upgrade any Angular 1.x components we depend on
const Dialog = upgradeAdapter.upgradeNg1Component('Dialog');
// Step 2: Import any Angular 2.x components we depend on
import {Calendar} from '../calendar';
require 'auto_reloader'
module RailsAutoReloader
def self.activate
AutoReloader.activate reloadable_paths: ['lib']
end
class Middleware
def initialize(app)
@app = app
@chrisnicola
chrisnicola / sorted_test_order.rb
Last active August 3, 2016 11:49
Examples of trying to set test order to be sorted. Note that I'm looking at the order that test files are being run as well. Perhaps that isn't controlled here.
# So far I have tried the following code in test_helper.rb
# Based on documentation here: http://api.rubyonrails.org/v4.2/classes/ActiveSupport/TestCase.html
class ActiveSupport::TestCase
def test_order
:sorted
end
end
@chrisnicola
chrisnicola / test_helper.rb
Last active August 3, 2016 20:15
Instance Eval'd blocks for ActionDispatch::Integration::Runner#open_session
class ActionDispatch::IntegrationTest
# Override Rails open_session so we can use an instance involved block
# instead of passing the session instance and using it. This allows the block
# to work exactly the same as the regular test.
def open_session(&block)
return super if block.nil? || block.arity > 0
super do |session|
session.instance_eval(&block)
end
end
@chrisnicola
chrisnicola / useful_object.rb
Last active September 3, 2016 00:17
A Useful Object Support Module
# Provides a default implementation of the singleton methods of buildable and
# callable classes based on the Useful Object's concept.
#
module UsefulObject
def self.included(base)
base.extend(Builder)
end
module Builder
def build(*args, **kargs, &block)