Skip to content

Instantly share code, notes, and snippets.

require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'openapi3_parser', '= 0.9.2'
end
require 'pathname'
require 'yaml'
@backus
backus / shitlist.rb
Last active December 15, 2020 17:14
module Shitlist
def shitlist(method_name, whitelist)
original_method = instance_method(method_name)
undef_method(method_name)
define_method(method_name) do |*args, &block|
call = caller_locations.first
passes_whitelist = whitelist.any? do |label, file_pattern|
call.label == label && call.absolute_path.end_with?(file_pattern)
end
@backus
backus / README.md
Created December 18, 2018 22:57
CSV generated on December 18th from scrape performed on the 17th

The headers should mainly be self-explanatory, but just in case:

Column Description
post_title Displayable title of the source post
post_author Author of the source post
post_url Canonical URL of source post, extracted from on post page
post_reference_count Number of times the source post has been referenced by other posts
ref_title Displayable title of the target post
ref_author Author of the target post
This file has been truncated, but you can view the full file.
[
{
"scam_address": "0x7bb386c33486fe345168d0af94bef03897e16022",
"inputs": [
{
"blockNumber": "5000129",
"timeStamp": "1517321579",
"hash": "0xd131607c4bc0d77dee4bf12ad418fe79f0b3bc9a7ec515e3f12e239874f9bba6",
"nonce": "28",
"blockHash": "0x765941db2efcf0f1d2476193f7da42588b1fbf6f8435e9bd10c5dbbf20364207",
@backus
backus / signTypedData.js
Created April 19, 2018 02:05
Example #2 for "How to make a user friendly Ethereum dApp"
const user = web3.eth.accounts[0];
const sigInput = [
{ type: "string", name: "Action", value: "Create Account" },
{ type: "address", name: "Address", value: user }
];
web3.currentProvider.sendAsync(
{ method: "eth_signTypedData", params: [sigInput, user], from: user },
handleSignature
@backus
backus / EthedIn.sol
Created April 19, 2018 02:01
Example #1 for "How to make a user friendly Ethereum dApp"
contract EthedIn {
// Digest describing the data the user signs.
// Needs to match what is passed to Metamask.
bytes32 public constant delegationHash =
keccak256("string Action", "address Address");
// Create account for a user using the signature they provided
//
// * Only approved transaction delegators are allowed to call this
// * _sender should be the address included in the signature as well
@backus
backus / signTypedData.js.md
Created April 8, 2018 20:48
How signTypedData works

I couldn't find a good explanation of each step of signTypedData EIP with examples of inputs and outputs at each step. I wanted this so I could keep track.

Say this is our private key

const privKey = new Buffer(
  "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
  "hex"
);
@backus
backus / snapshot.js
Created June 4, 2017 00:00
Simple image diffing with phantomjs and imagemagick
var system = require('system');
var page = require('webpage').create();
page.viewportSize = {
width: 1024,
height: 768
};
page.open(system.args[1], function() {
page.render(system.args[2]);
@backus
backus / masgn-conditional.rb
Created July 21, 2016 23:06
What is falsey in multiple assignment?
'truthy' if (a, b = []) # => "truthy"
'truthy' if (a, b = nil) # => nil
'truthy' if (a, b = [nil]) # => "truthy"
'truthy' if (a, b = [nil, nil]) # => "truthy"
'truthy' if (a, b = [false]) # => "truthy"
'truthy' if (a, b = [false, false]) # => "truthy"
'truthy' if (a, b = [true, false]) # => "truthy"
'truthy' if (a, b = [false, true]) # => "truthy"
'truthy' if (a, b = *[]) # => "truthy"
'truthy' if (a, b = *nil) # => "truthy"
gem 'json', '= 2.0.1'
require 'json'
JSON::VERSION # => "2.0.1"
json_string = '{}'
utf8_string = json_string.dup.force_encoding('UTF-8')
utf8_string_frozen = utf8_string.dup.freeze