Skip to content

Instantly share code, notes, and snippets.

@lightcap
lightcap / madness_test.coffee
Last active August 29, 2015 13:56
JavaScript, Sinon.js and Chai.js Regexp literal equality Madness
chai = require 'chai'
sinon = require 'sinon'
chai.use require 'sinon-chai'
# Yup, I'm mixing style. Deal with it.
expect = chai.expect
assert = chai.assert
describe 'regexp equality', ->
### Keybase proof
I hereby claim:
* I am lightcap on github.
* I am lightcap (https://keybase.io/lightcap) on keybase.
* I have a public key whose fingerprint is 8C96 7DC7 DD99 828A 2C9D CC34 9CD1 E300 98AB 7456
To claim this, I am signing this object:
@lightcap
lightcap / deploy.rb
Created February 21, 2009 01:50 — forked from defunkt/deploy.rb
# deploy to staging from your current topic branch, with ease
set :branch, "origin/#{`git branch`.scan(/^\* (\S+)/)}"
chinook: mattkern$ git reset --hard HEAD
HEAD is now at 65d77f3 ...and back to regularly scheduled programming.
# Examples of Nesting Associated Attributes
# This is a look at the various ways to set associated attributes through
# nested parameters. For example, let's say Project has_many :tasks and
# we want to update the tasks the same time we edit a project. There are
# several ways this interface could be handled, and here are a few.
#
# For these examples, we're trying to create two new tasks and update an
# existing task (with id 3) through a project.
# Approach 1
## markup
<div>
<ul>
<li>
<div class="image">
<img src="/system/events/icons/1/small_IMG_1651.jpg" />
</div>
<div>
<span class="ttl">THIS IS A TITLE</span>
This is the text...
<%= javascript_tag "var auth_token = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
results in:
//<![CDATA[
var auth_token = "ZOqYXojCWdc5FZlFY11sHtDW4dnC9eh2/G2M7PcDEDY=";
//]]>
</script>
When called like:
<datacom xmlns="http://www.pvpowered.com">
<inverter>
<inverter_model>286</inverter_model>
<inverter_serial>02860910090016</inverter_serial>
<text_serial>PV2600BBAF0910090016</text_serial>
<firmware_version>3.18</firmware_version>
<micro_rev>5</micro_rev>
<pvm_status>00</pvm_status>
<modbus_addr>81</modbus_addr>
<power_board_serial>0</power_board_serial>
class MonitorPoll < ActiveRecord::Base
set_table_name :inverter_monitor_polls
belongs_to :inverter
has_one :inverter, :foreign_key => :last_poll_id
end
class Inverter < ActiveRecord::Base
## monitor_poll_test.rb
require 'test_helper'
class MonitorPollTest < ActiveSupport::TestCase
should_belong_to :inverter
should_belong_to :inverter_property
context "An instance of MonitorPoll" do
setup do