Skip to content

Instantly share code, notes, and snippets.

@Haegin
Haegin / gist:3825891
Created October 3, 2012 08:56
Cleaner mongo DB integration
class Plugin:
....
PLUGIN_DEPENDS = [...]
# not sure what this decorator does yet so I'll just leave it here
#@Plugin.integrate_with('mongodb')
def _get_db(self, mongodb):
if 'mongodb' in PLUGIN_DEPENDS
self.db = mongodb.get_db(self.plugin_name())
I'm trying to test a code path that is hit when a function I'm calling raises an OAuth2::Error exception.
https://github.com/intridea/oauth2/blob/master/lib/oauth2/error.rb
OAuth2::Error takes in a response as a parameter but I really don't care about this and just want to mock this all out.
Currently I have the following:
setup do
@thing = flexmock(Thing.new(c))
@thing.should_receive('client').and_raise(OAuth2::Error)
end
should "handle an oAuth error correctly" do
No pig should go sky diving during monsoon
For this isn't really the norm.
But should a fat swine try to soar like a loon,
So what? Any pork in a storm.
No pig should go sky diving during monsoon,
It's risky enough when the weather is fine.
But to have a pig soar when the monsoon doth roar
Cast even more perils before swine.
@Haegin
Haegin / gist:6172514
Created August 7, 2013 09:19
Bookmarklet to uncheck all Trello cards.
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f%3De.jQuery)%7C%7Cg>f.fn.jquery%7C%7Ch(f))%7Bc%3Da.createElement("script")%3Bc.type%3D"text/javascript"%3Bc.src%3D"http://ajax.googleapis.com/ajax/libs/jquery/"%2Bg%2B"/jquery.min.js"%3Bc.onload%3Dc.onreadystatechange%3Dfunction()%7Bif(!b%26%26(!(d%3Dthis.readyState)%7C%7Cd%3D%3D"loaded"%7C%7Cd%3D%3D"complete"))%7Bh((f%3De.jQuery).noConflict(1),b%3D1)%3Bf(c).remove()%7D%7D%3Ba.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,"1.3.2",function(%24,L)%7B%24(%27.check-item.task.complete .checkbox.enabled%27).click()%7D)%3B
@Haegin
Haegin / git-me-back-to
Last active January 4, 2016 05:39
Automates reverting back to a given SHA with Git and restoring the lost features after the revert.
#!/bin/bash
function revert_to {
SHA=$1
echo "Reverting to ${SHA}"
git diff -R --binary $SHA | git apply
echo "Reverted"
echo "Diff against ${SHA}"
git diff $SHA
}

Keybase proof

I hereby claim:

  • I am Haegin on github.
  • I am haegin (https://keybase.io/haegin) on keybase.
  • I have a public key whose fingerprint is 61BE 3FD4 7DAE BED3 F394 0D6E A911 D5A2 1DC4 3EDC

To claim this, I am signing this object:

@Haegin
Haegin / 2014 mtrboxes changes v1.0.md
Last active August 29, 2015 14:01
MTR box changes for SelfAssessment 2013/14.

Based on 'HMRC-MTR-2014-v1-0-20130927' RIM artefacts. Version 1.0 - Changes since 2012-13

SA101

  • ASE1 - Xpath change

  • ASE2 - Box removed not used for 2013/14.

  • ASE15 - New box on 2013/14 Return UKpatentRoyaltyPaymentsMade.

  • AOR9 - Now BonusSecurityRedemptionDistributionRelief. Was AOR10 in 2012/13 - box EmployersWidowsOrphansEtcBenefitScheme removed for 2013/14.

-oooo:-
omhsoosho`
Ndo:``:oh-
dms+--+ym:
-ymhohdh+`
`N/`.s.
+: +
-- :

Array to Hash

This vim function turns Ruby arrays of symbols into new-style Ruby hashes where the symbol is the key and the value is the symbol converted to a MixedCase string.

Change Hash Style

This vim function switches Ruby hashes from the old hash-rocket style to the newer JSONesque style and back. It'll try and guess what the current style is and switch to the other one.

Dependencies

Communication at FreeAgent

Medium Timeliness Response Expected?
Face to Face / Skype Right here, right now It'd be rude not to
IM In the very near future. Hopefully less than an hour. Probably
Email Daily Depending on context but it's reasonable to expect a response
Discourse Hopefully this week No