Skip to content

Instantly share code, notes, and snippets.

@txus
txus / delegate_matcher.rb
Created February 2, 2011 09:19
RSpec matcher for delegations
# RSpec matcher to spec delegations.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:month).to(:created_at) }
# it { should delegate(:year).to(:created_at) }
# end
I am attesting that this GitHub handle txus is linked to the Tezos account tz1TSCo7tDXgCEySkrVyyNov7GBLSQPpL2ev for tzprofiles
sig:edsigtrsQ4vojJfHQtejr4MFp4xWJnJHe8q7rkfGyM988PZMTQ5Aw74hAUw6RsTZeMkrheSMc83Tyw9rjQG8Z5WqbM8KTedpBKt
@txus
txus / sinatra.rb
Created June 5, 2013 09:50
Disabled and checked checkboxes aren't sent in post requests.
# app.rb
#
# Usage:
#
# $ gem install sinatra
# $ ruby app.rb
#
require 'sinatra'
get '/' do
@txus
txus / Readme.md
Created September 12, 2012 08:56
Minitest Runner

MiniTest Runner

A basic runner for MiniTest as a shell script! Requires bash >= 4.0.

One-liner install

mkdir -p ~/bin && curl https://raw.github.com/gist/3705372/2f591ce427e21dab7685f7c743272827c8e8cf4f/minitest > ~/bin/minitest && chmod +x ~/bin/minitest

Put the ~/bin directory in your PATH.

@txus
txus / Playground.hs
Last active July 16, 2020 14:10
Plutus Playground Smart Contract (should adapt from https://gist.github.com/j-mueller/db9bb00b6b45fe7e475e75473c1e778b)
-- This is a starter contract, based on the Game contract,
-- containing the bare minimum required scaffolding.
--
-- What you should change to something more suitable for
-- your use case:
-- * The DataScript type
-- * The Redeemer type
--
-- And add function implementations (and rename them to
# adapted from http://github.com/rspec/rspec-rails/blob/master/specs.watchr
# Run me with:
#
# $ watchr specs.watchr
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def all_spec_files
@txus
txus / capybara_uoc.rb
Created June 26, 2011 15:05
UOC scraping with standalone Capybara
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'akephalos'
Capybara.run_server = false
Capybara.current_driver = :akephalos
Capybara.app_host = 'http://cv.uoc.edu'
module MyCapybaraTest

Keybase proof

I hereby claim:

  • I am txus on github.
  • I am txus (https://keybase.io/txus) on keybase.
  • I have a public key ASAbZcf0hjvViWF-qloQU5qxKk4thtbvBjzXBtKRWAeU9wo

To claim this, I am signing this object:

@txus
txus / README.md
Last active July 30, 2018 20:54
Memory as a dependently-typed effect (scroll down for examples!)

Memory as an effect

What if we treated memory as a side-effect?

Idris lets us track lots of things in the type system, in order to get errors at compile-time rather than at runtime. One of the tools that lets us do this in Idris is called Effects, and they're used to keep track of state, to manage file handlers, and lots more.

In barely 40 lines of Idris (which could be less if I had any idea what I'm

@txus
txus / Readme.md
Created March 11, 2012 17:19
RubyScript - A transcompiler transforming a subset of Ruby to JavaScript

RubyScript

A ~400LOC transcompiler transforming a subset of Ruby to JavaScript.

Installing and usage

curl https://raw.github.com/gist/2017173/efebd33d6ff430347ddb953c587318c8934cfd1e/rubyscript.rb > rubyscript
chmod +x rubyscript
./rubyscript my_file.rb > my_file.js