Skip to content

Instantly share code, notes, and snippets.

Avatar
🦖

Monica Giambitto nirnaeth

🦖
View GitHub Profile
@nirnaeth
nirnaeth / exit_code_matches.rb
Created May 26, 2020 — forked from mmasashi/exit_code_matches.rb
Exit code matcher for rspec 3
View exit_code_matches.rb
RSpec::Matchers.define :terminate do |code|
actual = nil
def supports_block_expectations?
true
end
match do |block|
begin
block.call
View keybase.md

Keybase proof

I hereby claim:

  • I am nirnaeth on github.
  • I am nirnaeth (https://keybase.io/nirnaeth) on keybase.
  • I have a public key ASDnevVuapaLpl9CsLehDSjwRfrVq974JtOhcW5o66fA2go

To claim this, I am signing this object:

@nirnaeth
nirnaeth / automated_class_instance_collaboration.rb
Created May 12, 2017 — forked from rklemme/automated_class_instance_collaboration.rb
Example for adding functionality to instances of a class which needs help from class methods of the same class. Use two modules - one for instance methods and one for class methods.
View automated_class_instance_collaboration.rb
#!/usr/bin/ruby -w
module Foo
module Foo4Class
def reset_instance_count
@instance_count = 0
end
def new(*a, &b)
super.tap { @instance_count += 1 }
@nirnaeth
nirnaeth / _upgrade-pg9.4-to-pg9.5.md
Created Dec 6, 2016 — forked from chbrown/_upgrade-pg9.4-to-pg9.5.md
Upgrade PostgreSQL 9.4 to 9.5 on Mac OS X with Homebrew
View _upgrade-pg9.4-to-pg9.5.md

First, check your current config (example output in homebrew.mxcl.postgresql.plist.xml lower down in this gist):

cat ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Most importantly, note the -D /usr/local/var/postgres argument.

Second, shut down your current PostgreSQL.

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
View types.markdown

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

@nirnaeth
nirnaeth / gist:df5780be14225a28e2935bcf3223dace
Created Jul 25, 2016 — forked from joho/gist:3735740
PostgreSQL 9.2 upgrade steps
View gist:df5780be14225a28e2935bcf3223dace
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@nirnaeth
nirnaeth / gist:c65d664b4ed8771ebbde0935c7844599
Created Jun 17, 2016 — forked from luopio/gist:f5a58f1dacf94d6094ad
Generating a Paymill token to test without the Javascript Bridge
View gist:c65d664b4ed8771ebbde0935c7844599
module PaymillSupport
def get_payment_token
# Simulate the JavaScript bridge we would use in production
params = {
'transaction.mode' => 'CONNECTOR_TEST',
'channel.id' => Rails.configuration.paymill_public_key,
'jsonPFunction' => 'function',
'account.number' => '4111111111111111',
'account.expiry.month' => 1.year.from_now.month,
View gist:a04ec5a989ad4c4e06c6bf0bbdc3321b
Run tests:
mix test
Run single test file:
mix test path/to/file
Run single test:
@nirnaeth
nirnaeth / gist:04c0888f7430d5be6b85d608a980f1d1
Created May 21, 2016 — forked from mattyoho/gist:1036397
Ryan Davis' book recommendations
View gist:04c0888f7430d5be6b85d608a980f1d1
My annual reread book is The School of Niklaus Wirth: The Art of Simplicity
Others I love:
Compiler Construction, Wirth
Effective TCP/IP Programming: 44 Tips to Improve Your Network Programs
C Programming Language
The Annotated C++ Reference Manual (first and last good book on C++, besides meyers)
Structure and Interpretation of Computer Programs
The Little Schemer, The Seasoned Schemer, (and probably Reasoned Schemer, but I haven't gotten through that yet).
@nirnaeth
nirnaeth / do end snippet for sublime
Created Sep 1, 2015
do end snippet for sublime
View do end snippet for sublime
// Source http://stackoverflow.com/questions/16956254/sublimetext2-auto-complete-wrong-for-ruby-do-block
<snippet>
<content><![CDATA[
do
$1
end
]]></content>
<tabTrigger>do</tabTrigger>
<scope>source.ruby</scope>
<description>do..end</description>