Skip to content

Instantly share code, notes, and snippets.

View PragTob's full-sized avatar

Tobias Pfeiffer PragTob

View GitHub Profile
@ryanml
ryanml / stranger-things.bas
Last active May 13, 2018 02:48
Bob's Password Brute-Forcer from Stranger Things Season 2
10 DIM FourDigitPassword INTEGER
20 FOR i = 0 TO 9
30 FOR j = 0 TO 9
40 FOR k = 0 TO 9
50 FOR l = 0 TO 9
60 FourDigitPassword = getFourDigits (i,j,k,l)
70 IF checkPasswordMatch(FourDigitPassword) = TRUE THEN
80 GOTO 140
90 END
100 NEXT l
# This file modifies benchmark-ips to better accommodate the optimisation
# characteristics of sophisticated implementations of Ruby that have a very
# large difference between cold and warmed up performance, and that apply
# optimisations such as value profiling or other speculation on runtime values.
# Recommended to be used with a large (60s) warmup and (30s) measure time. This
# has been modified to be the default. Note that on top of that, it now runs
# warmup five times, so generating the report will be a lot slower than
# before.
# Code is modified from benchmark-ips
@wjr1985
wjr1985 / gist:567445781a06e126a286
Created June 23, 2015 17:15
Braintree Ruby library - multiple merchant gateways
require "rubygems"
require "braintree"
transaction_attributes = {
:amount => "1000.00",
:credit_card => {
:number => "5105105105105100",
:expiration_date => "05/12"
}
}
require 'benchmark/ips'
class FakeDimension
def initialize
@margin_start = 10
@margin_start_relative = false
end
def relative?(result)
result.is_a?(Float) && result <= 1
@practicingruby
practicingruby / x.rb
Last active December 30, 2015 01:08
Tests for a game object in "Hunt The Wumpus". Please help improve its clarity.
require_relative "../helper"
describe "A room" do
let(:room) { Wumpus::Room.new(12) }
it "has a number" do
room.number.must_equal(12)
end
it "may contain hazards" do

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
@zmaril
zmaril / softwarehelpskill.md
Last active August 3, 2021 04:52
I want to write software that helps kill people.

I want to write software that helps kill people.

Please, before you call the police and get my github account put on lockdown, allow me a moment to explain. What I really want to do is work on projects that advance the human condition and improve people's lives. I've been in a mad dash to learn how to program for the past four or five years exactly because I realized how much good I could do for the world with a computer.

@wrightling
wrightling / design_for_devs.md
Last active December 14, 2015 15:59
CSS, HTML, and Design for a back-end developer. Suggestions from the Ruby Rogues' Parlay list.
@bugant
bugant / dining_philosophers.rb
Last active December 30, 2015 08:16
Dining Philosophers solution using Celluloid
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'celluloid'
class Table
include Celluloid
CHOPSTICK_FREE = 0
CHOPSTICK_USED = 1
@bf4
bf4 / ruby_learning.md
Last active July 17, 2021 08:06
Some Ruby Learning Resources