Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Kelly mikekelly

View GitHub Profile
@chrsengel
chrsengel / getPubKey.js
Last active May 3, 2022
Attempting to get the public key
View getPubKey.js
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 Aug 29, 2015
Simplified HAL
View orders.json
{
"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 Jun 30, 2017
Allow testing of locals when rendering Controllers
View assign_locals_helper.rb
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
View slides.md

!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 Oct 18, 2012
HAL Chai plugin
View hal-plugin.js
// 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 Jun 23, 2012 — forked from lukemelia/sketch.rb
sketch for Matt Wynne
View sketch.rb
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
@pironim
pironim / capybara cheat sheet
Last active Oct 5, 2015 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
View 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')
View part1.md

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 Apr 12, 2012
More technical details about the discussion at last nights meetup
View personality.rb
# 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 Apr 10, 2012
HAL version of catalog
View hal-catalog.json
{
"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": [
{