Skip to content

Instantly share code, notes, and snippets.

View mikekelly's full-sized avatar

Mike Kelly mikekelly

View GitHub Profile
@protortyp
protortyp / getPubKey.js
Last active October 25, 2023 18:33
Attempting to get the public key
const ethers = require("ethers")
const pk =
"0x0471c746523d16e93d4738f882d9b0beebf66c68caa0f895db15686b57b878cfc7b3e09813ba94f1bbfaa91a06566d3d18bbf69d10bcc947325bbcd6fea97ed692"
const ad = "0xcD3edF915387E2555A829567cE0dBbC919834B82"
getPubKey = async () => {
const infuraProvider = new ethers.providers.JsonRpcProvider(
"https://ropsten.infura.io/v3/<projectID>"
)
@ssfrr
ssfrr / orders.json
Last active August 29, 2015 14:05
Simplified HAL
{
"self": {"href":"/orders"},
"rel-templates":[
{
"name":"ea",
"href":"http://example.com/docs/rels/{rel}",
"templated":true
}
],
"next":{"href": "/orders?page=2"},
@mattheworiordan
mattheworiordan / assign_locals_helper.rb
Last active June 30, 2017 16:55
Allow testing of locals when rendering Controllers
def assigns_local(key)
controller.instance_variable_get('@patched_locals')[key]
end
def patch_controller_render_to_support_locals(controller)
def controller.render(options = nil, extra_options = {}, &block)
[options, extra_options].select { |o| o.kind_of?(Hash) }.each do |option_hash|
if option_hash.include?(:locals)
@patched_locals = option_hash[:locals]
end
@jamiehodge
jamiehodge / slides.md
Created December 3, 2012 09:40
Hypermedia APIs

!SLIDE

Hypermedia APIs

"Follow your nose"

— Roy T. Fielding

!SLIDE

"build scalable, flexible implementations that do not simply run on the Web, but that actually exist in the Web"

@jxson
jxson / hal-plugin.js
Created October 18, 2012 23:23
HAL Chai plugin
// http://chaijs.com/guide/plugins/
module.exports = function(chai, utils){
var Assertion = chai.Assertion
, assert = chai.assert
Assertion.addProperty('resource', function(){
var doc = this._obj
, message = utils.flag(this, 'message')
new Assertion(doc, message).to.be.an('object')
@mattwynne
mattwynne / sketch.rb
Created June 23, 2012 22:22 — forked from lukemelia/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
@pironim
pironim / capybara cheat sheet
Last active October 5, 2015 16:18 — 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')

Inheritance is a key concept in most object-oriented languages, but applying it skillfully can be challenging in practice. Back in 1989, M. Sakkinen wrote a paper called Disciplined inheritance that addresses these problems and offers some useful criteria for working around them. Despite being more than two decades old, this paper is extremely relevant to the modern Ruby programmer.

Sakkinen's central point seems to be that most traditional uses of inheritance lead to poor encapsulation, bloated object contracts, and accidental namespace collisions. He provides two patterns for disciplined inheritance and suggests that by normalizing the way that we model things, we can apply these two patterns to a very wide range of scenarios. He goes on to show that code that conforms to these design rules can easily be modeled as ordinary object composition, exposing a solid alternative to tradi

@wycats
wycats / personality.rb
Created April 12, 2012 18:07
More technical details about the discussion at last nights meetup
# Just wanted to clarify my points at the meetup last night.
#
# There were two different issues intertwined:
# (1) Whether to use extend or "include as extend"
# (2) When using "include as extend", what is the simplest way to achieve the goal?
#
# My personal opinion is that the answer to (1) is "extend", not "include as extend", but that
# is just my personal opinion. My answer to (2) is a more empirical question.
# Using the "extend" approach. Again, I personally prefer the simplicity of this approach, but
@domenic
domenic / hal-catalog.json
Created April 10, 2012 18:25
HAL version of catalog
{
"title": "Catalog for Domenic, page 1",
"description": "Contains lots of books, which is cool",
"_links": {
"self": { "href": "/docs?page=1" },
"next": { "href": "/docs?page=2" }
},
"_embedded": {
"http://rel.nkstdy.co/document": [
{