Skip to content

Instantly share code, notes, and snippets.

View chrisnicola's full-sized avatar

Chris Nicola chrisnicola

View GitHub Profile
require 'auto_reloader'
module RailsAutoReloader
def self.activate
AutoReloader.activate reloadable_paths: ['lib']
end
class Middleware
def initialize(app)
@app = app
using System;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace Presentation.Helpers {
public static class TreeViewitemFinder {
public static TreeViewItem BringTreeViewItemIntoView(this TreeView treeView, TreeViewItemModel item) {
if (item == null) return null;
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';
@chrisnicola
chrisnicola / facepalm.js
Created May 16, 2013 02:26
Face Palm Directive for AngularJS
var facepalm = function() {
return {
replace: true,
template: "<pre>"
+ " .-'---`-.\n"
+ ",' `.\n"
+ "| \\\n"
+ "| \\\n"
+ "\\ _ \\\n"
+ ",\\ _ ,'-,/-)\\\n"
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
install_git "jamesgolick-ruby" "https://github.com/jamesgolick/ruby.git" "jamesgolick" autoconf standard verify_openssl
@chrisnicola
chrisnicola / page-turner.js
Created December 19, 2012 17:45
Pagination using the History API
$(function() {
setPageState = function(current, next) {
$('#content').data('page', current);
history.replaceState({ page: current }, null, current);
if(!next) return;
history.pushState({ page: next }, null, current);
history.go(-1);
};
if (!history) return;
@chrisnicola
chrisnicola / Guardfile
Created September 19, 2012 22:37
Guard problems
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
watch(%r{^config/initializers/.+\.rb$})
watch('Gemfile')
watch('Gemfile.lock')
watch('spec/spec_helper.rb') { :rspec }
watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber }
@chrisnicola
chrisnicola / jQuery.contentChanged.coffee
Created July 28, 2012 00:58
jQuery content changed plugin
# $ contentChanged
# By: Chris Nicola
#
# Provides an attachable 'contentChanged' event for text inputs and allows an
# event to be fired whenever changed content is detected. For convenience the
# event incldues properties for `previous`, `current` and `hasContent`.
#
$.fn.extend
@chrisnicola
chrisnicola / tddium_test_helper.rb
Created March 17, 2012 00:46
Tddium test log folder helper
# Returns a file located in /logs/ when running locally and in the Tddium log output on Tddium
# This allows custom logs and files to be included in the Tddium test results
class Helpers
def self.test_log_path filename
if (ENV['TDDIUM_SESSION_ID'])
File.expand_path("#{ENV['HOME']}/results/#{ENV['TDDIUM_SESSION_ID']}/#{ENV['TDDIUM_TEST_EXEC_ID']}/") + '/' + filename
else
File.expand_path('log/') + '/' + filename
end
@chrisnicola
chrisnicola / serialization.rb
Created October 3, 2011 03:17
Serialization improvements for CouchRest Model
module CouchRest
module Serialization
extend ActiveSupport::Concern
include ActiveModel::Serialization
include ActiveModel::Serializers::JSON
include ActiveModel::Serializers::Xml
included do
class_attribute :include_root_in_json
self.include_root_in_json = false