Skip to content

Instantly share code, notes, and snippets.

View CodeOfficer's full-sized avatar

Russell Jones CodeOfficer

View GitHub Profile
@CodeOfficer
CodeOfficer / firestore.rules
Created September 1, 2021 16:08 — forked from pfiadDi/firestore.rules
Firestore Advanced Security Rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
function isAuthenticated() {
return request.auth != null;
}
function isDefined(field) {
return field in request.resource.data
@CodeOfficer
CodeOfficer / validators.js
Created January 17, 2013 16:02
Validators for ember-data
var get = Ember.get;
DS.Model.reopen({
validate: function() {
if (get(this, 'isDeleted')) {
return;
}
get(this, 'validators').forEach(function(validator) {
validator.fn.call(this, validator.meta.key(this.constructor), get(this, validator.attribute), validator.options);
}, this);
var get = Ember.get;
DS.Model.reopen({
validate: function() {
if (get(this, 'isDeleted')) {
return;
}
get(this, 'validators').forEach(function(validator) {
validator.fn.call(this, validator.meta.key(this.constructor), get(this, validator.attribute), validator.options);
}, this);
@CodeOfficer
CodeOfficer / gist:2205474
Created March 26, 2012 14:28 — forked from jeffkreeftmeijer/gist:1473018
PGError: ERROR: syntax error at or near "IDENTITY" (ActiveRecord::StatementInvalid)
Loading ["spec"]
*****************************************************************
DEPRECATION WARNING: you are using a deprecated constant that will
be removed from a future version of RSpec.
/Users/codeofficer/.rvm/gems/ruby-1.9.3-p125@worldbrain/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
* Rspec is deprecated.
* RSpec is the new top-level module in RSpec-2
*****************************************************************
@CodeOfficer
CodeOfficer / capybara cheat sheet
Created May 25, 2011 22:01 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
(function($){
$.each(["live", "die"], function( i, name ) {
var method = $.fn[ name ];
$.fn[ name ] = function( types, data, fn, origSelector ) {
if ( typeof types === "object" && !types.preventDefault ) {
for ( var key in types ) {
method.call( this, key, data, types[key], origSelector );
}
/**
* An implementation of the K Combinator.
* http://wiki.tcl.tk/1923
*
* Copied from Mikael Brockman's code in Ruby on Rails' ActiveSupport library.
* http://weblog.jamisbuck.org/2006/10/27/mining-activesupport-object-returning
*/
function returning(value, block, context) {
block.call(context || null, value);
return value;
This is an example of using RVM's Project .rvmrc file
to have it automatically bootstrap your environment, including bundler.
This could be further expanded to do anything you require :)
The important thing to remember is that the purpose of these files is
to allow you to very easily have your 'project context' (aka 'environment')
loaded automatically for you when you enter the project in the shell (cd).
You can generate the .rvmrc file below by running:
(function ($) {
$.event.special.textchange = {
setup: function (data, namespaces) {
$(this).bind('keyup', $.event.special.textchange.handler);
$(this).bind('cut paste input', $.event.special.textchange.delayedHandler);
},
teardown: function (namespaces) {
file 'Gemfile', <<-GEMS
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta3"
gem "bson_ext"
gem "mongoid", "2.0.0.beta4"
gem "haml", "3.0.0.rc.2"
gem "compass", "0.10.0.rc4"
gem "inherited_resources"
group :test do