Skip to content

Instantly share code, notes, and snippets.

package main
import "fmt"
var true = false
func main() {
fmt.Println(true)
}
def myfunc(prog = "")
mystr = "hi there"
eval(prog)
mystr.scream
end
puts 'first'
begin
myfunc
rescue => e
@packrat386
packrat386 / example.txt
Created October 21, 2018 20:04
Example of tldr -l implementation
[fg-386] tldr-cpp-client > ./tldr -l
Pages for osx
airport
apachectl
archey
as
base64
brew-cask
brew-mas
brew
From 46cff894e9de7284395b4df996914221f96fc1ac Mon Sep 17 00:00:00 2001
From: Aidan Coyle <packrat386@gmail.com>
Date: Tue, 20 Nov 2018 21:40:36 -0600
Subject: [PATCH] Bats first attempt
---
src/pv/display.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pv/display.c b/src/pv/display.c
@packrat386
packrat386 / customer_notifier_v1.rb
Created December 5, 2018 00:48
What is green may not always be grue
class CustomerNotifier
def initialize(mail_server, templates)
@mail_server = mail_server
@templates = templates
end
def confirm_order(customer, data)
@mail_server.send_mail(customer.email_address, @templates[:confirm_order].render(data))
end
@packrat386
packrat386 / ips.rb
Created December 14, 2018 02:54
Some people manage to do everything the hard way
require 'benchmark/ips'
SIZE = 10
Benchmark.ips do |x|
x.report('insane') do
[0].cycle.take(SIZE)
end
x.report('sane') do
@packrat386
packrat386 / 0001-Override-the-RB_TEST-macro-to-check-falsiness.patch
Created February 10, 2019 16:01
Git patch to override RB_TEST to attempt to check class instead of specific values. Didn't work very well.
From ee8b5f5c1f4072affd1c3d68209e39889831c56e Mon Sep 17 00:00:00 2001
From: Aidan Coyle <packrat386@gmail.com>
Date: Sun, 10 Feb 2019 15:54:21 +0000
Subject: [PATCH] Override the RB_TEST macro to check falsiness
Rather than only accepting the exact values Qnil and Qfalse, instead
check the class of the VALUE passed to see if it is FalseClass.
---
eval.c | 16 ++++++++++++++++
include/ruby/ruby.h | 12 ++++++------
@packrat386
packrat386 / builder.go
Created April 26, 2019 19:12
Regex parser because I was bored on a plane
package re
import "fmt"
type builderEdge struct {
from int64
to int64
on rune
}
@packrat386
packrat386 / index.go
Created July 3, 2019 03:00
Dumb impl of `bytes.Index`
package index
func Index(s, sep []byte) int {
pos := 0
for {
if pos+len(sep) > len(s) {
return -1
}
@packrat386
packrat386 / clients.go
Created October 10, 2019 20:13
How to dependency inject for a function in go
package main
import "fmt"
func handle(f func(input string) string) { fmt.Println(f("foo")) }
func main() {
handle(func(input string) string {
return handler(input, &ic{42}, &sc{"bar"})
})