Skip to content

Instantly share code, notes, and snippets.

View chrisnicola's full-sized avatar

Chris Nicola chrisnicola

View GitHub Profile
export function parseName(path) {
const name = path.toLowerCase()
// Remove starting ./
.replace(/^\.\//, '')
// Parameters
.replace(/\/_(\w+)(\/|\.vue$)/, '/:$1/')
// Remove file extension and 'index'
.replace(/(index)?\.vue$/, '')
// Remove trailing '/'
.replace(/\/$/, '');
chrisnicola / type_compatibility.ts
Created October 27, 2016 21:56
Type inference limitations for Typescript
class TypeOne {
public one
private two
private three
class TypeTwo {
public one
chrisnicola / angular.d.ts
Created September 14, 2016 19:51
Fixed Angular type definition
// Type definitions for Angular JS 1.5
// Project:
// Definitions by: Diego Vilar <>
// Definitions:
/// <reference types="jquery" />
declare var angular: angular.IAngularStatic;
// Support for painless dependency injection
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)
module Builder
def build(*args, **kargs, &block)
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|
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:
class ActiveSupport::TestCase
def test_order
require 'auto_reloader'
module RailsAutoReloader
def self.activate
AutoReloader.activate reloadable_paths: ['lib']
class Middleware
def initialize(app)
@app = app
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 '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
| <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;
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>