Skip to content

Instantly share code, notes, and snippets.

@drewbug
drewbug / pi-bt-adapter
Created April 18, 2021 00:47
use pi as machine's bluetooth adapter
step 1, run on the client (192.168.1.11):
=========================================================================
sudo socat pty,link=vserial TCP-LISTEN:4161,reuseaddr,fork,max-children=1
=========================================================================
step 2, run on the pi:
==============================================================================
sudo socat file:/dev/serial1,raw,b115200,iexten=0,echo=0 TCP:192.168.1.11:4161
==============================================================================

Keybase proof

I hereby claim:

  • I am drewbug on github.
  • I am drewbug (https://keybase.io/drewbug) on keybase.
  • I have a public key ASCumRamgFuwuiPjauTFP_LauWuKVhL6EbO4qQiA89oTdAo

To claim this, I am signing this object:

#!/usr/bin/env ruby
ARGV.each do |rpm|
dest_dir = File.basename rpm, '.rpm'
Dir.mkdir dest_dir
Dir.chdir dest_dir do
`rpm2cpio.pl #{rpm} | cpio -i -d`
end
end
If you delete /var/db/TokenCache/tokens/
You'll get "[token] exception during insertion processing"
So don't do that, just delete its contents
#!/usr/bin/env ruby
require 'openssl'
require 'tempfile'
OpenSSL::PKey::EC.send :alias_method, :private?, :private_key?
key = OpenSSL::PKey::EC.new('secp256k1')
key.generate_key
wget https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.1.11.tar.bz2
tar xf gnupg-2.1.11.tar.bz2
pushd gnupg-2.1.11

git clone git://git.gnupg.org/libgcrypt.git
pushd libgcrypt

./autogen.sh
./configure --prefix=$PWD --disable-doc

make

#!/usr/bin/env ruby
# create temporary auth key first via gui, then export your whole keyring and modify it
require 'digest'
unpatched = File.read 'temp_auth.key'
unpatched_bytes = unpatched.bytes
@drewbug
drewbug / prime256v1.rb
Created January 31, 2015 02:22
ruby prime256v1.rb < secp256k1_private_key.pem > prime256v1_private_key.pem
# ruby prime256v1.rb < secp256k1_private_key.pem > prime256v1_private_key.pem
require 'openssl'
ec = OpenSSL::PKey::EC.new('prime256v1')
ec.private_key = OpenSSL::PKey::EC.new(ARGF.read).private_key
ec.public_key = ec.group.generator.mul(ec.private_key)
print ec.to_pem
@drewbug
drewbug / syslog-ifdreader.sh
Created January 27, 2015 20:24
pcsc ifd-handler logging in yosemite
sudo syslog -w -k Sender com.apple.ifdreader
@drewbug
drewbug / physics-dl.rb
Created November 20, 2014 08:45
youtube-dl hang workaround
require 'timeout'
loop do
pid = fork
if pid.nil?
exec("youtube-dl https://www.youtube.com/playlist?list=PL47F408D36D4CF129")
else
begin
Timeout::timeout(15 * 60) {