Skip to content

Instantly share code, notes, and snippets.

Mark Rada ferrous26

Block or report user

Report or block ferrous26

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:e993352a4319f7fbbbf6
### Keybase proof
I hereby claim:
* I am ferrous26 on github.
* I am ferrous26 (https://keybase.io/ferrous26) on keybase.
* I have a public key whose fingerprint is 1D34 82B6 1EB5 286D 8D61 E84C 1EE8 F634 208C EB3B
To claim this, I am signing this object:
@ferrous26
ferrous26 / test.java
Last active Aug 29, 2015
Java silliness
View test.java
public class test {
public test() {
int[] a = new int[''];
a[1] = a[0];
}
}
@ferrous26
ferrous26 / float.rb
Last active Jan 3, 2016
A regular expression for validating floating point numbers
View float.rb
DIGITS = '(\d+)'
EXPONENT = "([eE][+-]?#{DIGITS})"
SUFFIX = '(f|F|d|D)'
PATTERN = Regexp.union [
"#{DIGITS}\\.#{DIGITS}?#{EXPONENT}?#{SUFFIX}?",
"\\.#{DIGITS}#{EXPONENT}?#{SUFFIX}?",
"#{DIGITS}#{EXPONENT}#{SUFFIX}?",
"#{DIGITS}#{EXPONENT}?#{SUFFIX}"
].map { |str| Regexp.new "\\A#{str}\\Z" }
@ferrous26
ferrous26 / ferrous26.pem
Created Dec 20, 2013
My Rubygems certificate
View ferrous26.pem
-----BEGIN CERTIFICATE-----
MIIDeDCCAmCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDAptYXJr
cmFkYTI2MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
b20wHhcNMTMxMjIwMDkwMjQ4WhcNMTQxMjIwMDkwMjQ4WjBBMRMwEQYDVQQDDApt
YXJrcmFkYTI2MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCumG1cuUOFpjYl
ktWNO8nA1FROqLnpC6GkT1CIBOG3VgXjh5vl3uAbvg6FaSU2jA0W91i6QhSaP1Ik
ReX3o6wBUnK15pN/wBULZY772WEg0Nb5wyrzSlS3dv8Jg6aGuw1bridSO0HSARvG
oQC++a1Ks64uy++OPwglaGBOcalNxwF1TUcYzi0K3a679+/8+kwaJt0pVtbT81RW
2oHli/SGB4oFu3uYnMoKk0yczfiSBdG7oSWBAcSEPsFRsUGn3vUdwCIlVXtKmmfW
@ferrous26
ferrous26 / bf.rb
Last active Dec 11, 2015
Brainfuck interpreter in Ruby
View bf.rb
#!/usr/bin/env ruby
mem = Array.new(30_000)
iptr = dptr = 0
prog = File.read ARGV.first
jmp = lambda { |op, a, b|
(iptr = iptr.send(op, 1); jmp.call(op, a, b) if prog[iptr] == a) until prog[iptr] == b
}
nop = lambda {}
cmds = {
'>' => lambda { dptr += 1 },
View gist:4536483
finder = AX::Application.finder
dock = AX::Application.dock
click dock.application_dock_item(title:"Finder")
sleep 2
type "\\SHIFT+\\COMMAND+\\G"
type "~"
click finder.window.button(id: "_NS:48")
click finder.window.radio_button(description: "icon view")
right_click finder.window.image(title: "Applications") do
findermenu = finder.standard_window.menu
@ferrous26
ferrous26 / time.c.diff
Last active Dec 10, 2015
MacRuby/MacRuby GH-174
View time.c.diff
diff --git a/time.c b/time.c
index 332aad9..730d0e5 100644
--- a/time.c
+++ b/time.c
@@ -10,6 +10,7 @@
#include "macruby_internal.h"
#include "ruby/node.h"
+#include "id.h"
#include "vm.h"
@ferrous26
ferrous26 / bug.rb
Created Dec 27, 2012
Varargs in MacRuby and MRI
View bug.rb
def foo *args
arg = args.last
if arg.zero?
args
else
foo(args << arg - 1)
end
end
p foo 3
@ferrous26
ferrous26 / pipeline.rb
Created Nov 22, 2012
Trying to generalize the pipeline data flow
View pipeline.rb
require 'thread'
##
# A basic, serial data flow
#
# If you have a long process for a data set, consider performing steps
# of the process concurrently. Even simply reading a file and writing it
# back out elsewhere (i.e. a socket) can have increased throughput by
# using a pipeline.
#
@ferrous26
ferrous26 / screen_recorder.rb
Created Oct 28, 2012
A simple screen recorder
View screen_recorder.rb
framework 'AVFoundation'
MOUNTAIN_LION_APPKIT_VERSION = 1187
if NSAppKitVersionNumber >= MOUNTAIN_LION_APPKIT_VERSION
framework '/System/Library/Frameworks/CoreGraphics.framework'
end
##
# Screen recordings, easy as pie.
You can’t perform that action at this time.