This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| count = 0 | |
| running_avg = nil | |
| real_avg = nil | |
| values = [] | |
| 50000.times do |n| | |
| count += 1 | |
| new_value = rand(1000.to_f) | |
| values.push(new_value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| file_line_length = {} | |
| STDIN.read.split("\n").each do |f| | |
| file_line_length[f] = {length: -1, line_num: nil} | |
| fh = File.open(f) | |
| fh.each_line do |l| | |
| if file_line_length[f][:length] < l.length |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'ipaddr' | |
| require 'pcaprub' | |
| require 'strscan' | |
| # https://en.wikipedia.org/wiki/EtherType | |
| ETHER_TYPE = { | |
| 0x0800 => :ipv4, | |
| 0x0806 => :arp, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| def initialize(*args) | |
| puts args.inspect | |
| end | |
| end | |
| def Foo(*args) | |
| Foo.new(*args) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A good key that we want | |
| VALID_CONFIG_KEY=testing | |
| # We don't want external commands to be able to run | |
| DANGEROUS=$(date) | |
| # Or a weird syntax to trigger commands | |
| BAD=$(echo 'test')=value | |
| # And we should receive a warning about lines that don't match the key value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'serialport' | |
| require 'thread' | |
| serial_port = SerialPort.new('/dev/ttyUSB0', 9600, 8, 1, SerialPort::NONE) | |
| read_queue = Queue.new | |
| write_queue = Queue.new | |
| read_thread = Thread.new do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *filter | |
| :INPUT ACCEPT [0:0] | |
| :FORWARD ACCEPT [0:0] | |
| :OUTPUT ACCEPT [0:0] | |
| -A INPUT -m conntrack --ctstate INVALID -j DROP | |
| -A INPUT -i lo -j ACCEPT | |
| -A OUTPUT -o lo -j ACCEPT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| def x_values | |
| %w(a b c d) | |
| end | |
| def y_values | |
| %w(m n o p) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ExTest = Class.new(StandardError) | |
| begin | |
| raise ExTest, 'wee' | |
| rescue ExTest => e | |
| puts 'Caught 1' | |
| raise e | |
| rescue => e | |
| puts 'Caught 2' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'benchmark/ips' | |
| require 'forwardable' | |
| class Target | |
| def goal(msg) | |
| msg.reverse | |
| end | |
| end |