Skip to content

Instantly share code, notes, and snippets.

Rob Hurring robhurring

Block or report user

Report or block robhurring

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@robhurring
robhurring / datepicker.js
Last active Aug 29, 2015
angular pikaday
View datepicker.js
/* global angular, Ladda */
(function(module, $) {
'use strict';
module.directive('datepicker', function() {
return {
link: function postLink(scope, element, attrs) {
var today = new Date();
var minYear = 1900;
var maxYear = today.getFullYear();
View noidea.js
var UserSelect = React.createClass({
_changed: function(event) {
var value = this.refs.box.getDOMNode().value;
this.props.onSelect(value);
},
render: function() {
var items = this.props.items.map(function(item) {
return (
<option value={item}>{item}</option>
@robhurring
robhurring / save_tracker.rb
Created Apr 14, 2015
RSpec ActiveRecord model save and creation reporting
View save_tracker.rb
# ./spec/support/save_tracker.rb
module SaveTracker
extend ActiveSupport::Concern
included do
class_attribute :_save_tracker_
self.reset_save_tracker!
end
module ClassMethods
View Timer.jsx
class Timer extends React.Component {
constructor(props) {
super(props)
this._interval = null;
this.state = {
ticks: 0
}
}
@robhurring
robhurring / .eslintrc
Last active Aug 29, 2015 — forked from cletusw/.eslintrc
ESLint starter RC file (updated ECMA6 rules)
View .eslintrc
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"arrowFunctions": false, // enable arrow functions
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"classes": false, // enable classes
"defaultParams": false, // enable default function parameters
"destructuring": false, // enable destructuring
View update_content.js
(function($) {
// scan our ajax response for replaceable content blocks then update the HTML
var updateContent = function(content) {
var $contentKeyElements = $(content).filter('[data-content-key]');
$contentKeyElements.each(function() {
var node = $(this);
var key = node.attr('data-content-key');
$('[data-content-key=' + key + ']').replaceWith(node);
});
@robhurring
robhurring / any.js
Created Feb 18, 2009
Allow strings to number_to_currency style comma seperate in javascript
View any.js
// Allow strings to number_to_currency style comma seperate
String.prototype.commafy = function () {
return this.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) {
return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,");
});
}
// Convenience method for numbers
Number.prototype.commafy = function () {
return String(this).commafy();
@robhurring
robhurring / application.html.erb
Created Mar 16, 2009
Rails Metal theme switcher
View application.html.erb
# your applications main layout file (app/views/layouts/application.html.erb?)
# I put this after the normal stylesheet call, so our theme can override what we want instead of the entire stylesheet
<% if theme = request.env['rails.theme'] %>
<%= stylesheet_link_tag "themes/#{theme}", :media => :all %>
<% end %>
@robhurring
robhurring / any.html.erb
Created Mar 24, 2009
object debugging with syntax highlight
View any.html.erb
<!-- using -->
<%= syntax_debug @object %>
@robhurring
robhurring / config.ru
Created Mar 24, 2010
Sinatra using ActiveRecord's Query Caching ability across multiple Databases : http://proccli.com/active-record-query-caching-sinatra-multiple-databases
View config.ru
require 'sinatra_query_caching_demo'
run Demo
You can’t perform that action at this time.