Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
magnetikonline / README.md
Last active January 3, 2024 14:30
GitHub token validation regular expressions.
@ntrogers
ntrogers / apple_caching_commands.sh
Last active July 29, 2023 18:31
[Apple Cacheing commands]
https://support.apple.com/guide/mac-help/configure-advanced-content-caching-settings-mchl91e7141a/mac
# On client, test caching server availability
/usr/bin/assetcachelocatorutil
# View log
log show --predicate 'subsystem == "com.apple.AssetCache"'
log stream --predicate 'subsystem == "com.apple.AssetCache"'
# Display content cache settings
@benders
benders / delayed_job_classifier.sql
Last active December 27, 2015 12:59
Figure out WTF is in our delayed_job queue
SELECT
count(*) as count, priority, object, method from (
SELECT
@load_start := LOCATE('object: LOAD;', handler),
@method_start := LOCATE('method: ', handler) + 9,
@method_end := LOCATE('args:', handler) - 1,
IF(@load_start,
@object_start := @load_start + 13,
@object_start := LOCATE('object: !ruby/object:', handler) + 21
),
@benders
benders / cisco-asa-config.txt
Last active November 23, 2021 05:01
Getting Amazon VPC up and running with Cisco ASAs can be a pain. This is the config that we used to make it work.
! --------------------------------------------------------------------------------
! This example configuration shows what WE did to get Amazon VPC working with our
! ASAs. We use version 8.3(1). This config has not been reviewed or otherwise
! blessed in any way by anyone at Amazon. YMMV.
!
! It differs from Amazon's supplied config by using two different sets of
! crypto maps and ACLs, so it brings both tunnels up simultaneously.
!
! For the purposes of the example, the physical datacenter network is 172.16.1.0/24
! and the VPC is 10.0.0.0/16.
@benders
benders / reflate.rb
Created February 7, 2013 01:52
Display the contents of a DEFLATE compressed file (like an HTTP POST body)
#!/usr/bin/env ruby
require 'zlib'
print Zlib::Inflate.new.inflate($<.read)
@gnarg
gnarg / drb_socket_pair.rb
Created October 25, 2012 21:21
drb socket pair protocol interface
class TimeServer
def get_current_time
Time.now
end
end
################
URI = 'druby://localhost:8787'
@relistan
relistan / ssh-config
Created March 22, 2012 16:36
proxy ssh through a jump host without breaking all other ssh connections
Host *
ForwardAgent yes
ProxyCommand ~/bin/ssh-proxy.sh %h %p username@jump-host
ServerAliveInterval 10
ServerAliveCountMax 600
@foliosus
foliosus / .irbrc
Created May 24, 2011 22:28
Interesting .irbrc hacks, including getting logging to your console, making easy calls to the app from the console, easy loading of accounts
ANSI = {}
ANSI[:RESET] = "\e[0m"
ANSI[:BOLD] = "\e[1m"
ANSI[:UNDERLINE] = "\e[4m"
ANSI[:LGRAY] = "\e[0;37m"
ANSI[:GRAY] = "\e[1;30m"
ANSI[:RED] = "\e[31m"
ANSI[:GREEN] = "\e[32m"
ANSI[:YELLOW] = "\e[33m"
ANSI[:BLUE] = "\e[34m"
@benders
benders / script-with-bundler.rb
Created July 2, 2010 20:51
How to use Bundler for a script run via symlink
#!/usr/bin/env ruby
# Bundler needs to find the Gemfile in the current directory, so we
# need to dereference symlinks, then chdir to where this script lives
this_file = __FILE__
while( File.symlink?(this_file) )
this_file = File.readlink(this_file)
end
Dir.chdir(File.dirname(this_file))
@benders
benders / birthday.rb
Created May 19, 2009 17:25
Estimate the collision rate of k keys in space n
# Approximates the chance of at least one collision in a random
# distribution of k items across n possible IDs. Adapted from
# Karsten's approximate calculator at http://tinyurl.com/5zt6ol
def collision_probability( k, n )
1 - Math.exp((-k ** 2) / ( 2.0 * n).to_f)
end
# The odds of two people having the same birthday are slightly
# greater than 50% if you have 23 or more people.
puts collision_probability( 23, 365 ) # => 0.515509538061517