This file contains 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
# mDNS client | |
# | |
# Usage: ruby script.rb "_http._tcp.local." | |
require "socket" | |
require "ipaddr" | |
require "fcntl" | |
require "resolv" | |
module DNSSD |
This file contains 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 "fisk" | |
require "fisk/helpers" | |
require "fiddle/import" | |
module Ruby | |
extend Fiddle::Importer | |
dlload | |
typealias "VALUE", "uintptr_t" |
This file contains 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
# Have you ever wanted lldb to break in a certain place, but you weren't | |
# sure where to set the breakpoint? Look no further than this script! | |
# | |
# This script creates a chunk of executable code that uses the int3 x86 | |
# instruction. This instruction is defined for use by debuggers, and you can | |
# read more about it here: https://en.wikipedia.org/wiki/INT_%28x86_instruction%29#INT3 | |
# | |
# When that instruction is executed, the debugger will halt and you can do | |
# what you need! | |
# |
This file contains 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
def ractor_bitonic_sort array | |
size = array.size | |
level = size.bit_length - 1 | |
raise 'size is not power of 2' unless size == 1 << level | |
pipe = Ractor.new { loop { Ractor.yield Ractor.recv } } | |
ractors = array.map.with_index do |v, i| | |
Ractor.new pipe, v, i, size, level do |pipe, v, index, size, level| | |
received = {} | |
conditional_recv = -> key { | |
return received.delete key if received.key? key |
This file contains 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 'socket' | |
addr = "00:11:22:33:44:55" | |
rf_chan = 23 | |
l2_psm = 15 | |
# rfcomm client | |
s = Socket.new 31, 1, 3 # (31 = AF_BLUETOOTH, 1 = SOCK_STREAM, 3 = BTPROTO_RCOMM) |
This file contains 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
drbig@swordfish:pts/16 ~/P/pry-tcprepl> cat pry-tcprepl.rb | |
require 'pry' | |
require 'pty' | |
class PryTcpRepl | |
attr_reader :thread | |
def initialize(where, host = '127.0.0.1', port = '9123') | |
@where = where | |
@host = host |