Skip to content

Instantly share code, notes, and snippets.

View midnight-wonderer's full-sized avatar

Sarun Rattanasiri midnight-wonderer

View GitHub Profile
@sauloperez
sauloperez / signal_catching.rb
Last active November 11, 2020 11:25
How to catch SIGINT and SIGTERM signals in Ruby
# Signal catching
def shut_down
puts "\nShutting down gracefully..."
sleep 1
end
puts "I have PID #{Process.pid}"
# Trap ^C
Signal.trap("INT") {
@Integralist
Integralist / Ruby Lambdas.md
Last active August 8, 2023 05:10
Ruby lambdas

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!
@fabiosantoscode
fabiosantoscode / gist:bcfe7165ca6dd97ba0bf
Last active December 9, 2023 19:46
Reverse tunnel. Connect to a public host somewhere and have it redirect all connections to your machine behind a NAT or firewall
# This enables a publicly available server to forward connections to your computer behind a NAT.
# So if you access http://xx.xx.xx.xx:8080/ on your browser, traffic is redirected to your machine behind a NAT.
# on your local host, type:
ssh -R xx.xx.xx.xx:8888:localhost:80 root@xx.xx.xx.xx
# now wait for your shell, and type:
socat TCP-LISTEN:8080,FORK TCP:127.0.0.1:8888
# This command outputs nothing, just keep it running. While you don't ^C, your tunnel is up and running!
@serradura
serradura / firebase_admin.rb
Last active February 10, 2022 18:45
FirebaseAdmin::Auth.verify_id_token | Ruby solution for https://firebase.google.com/docs/auth/admin/verify-id-tokens
# Usage:
# ========
# FirebaseAdmin::Auth.verify_id_token(your_id_token)
#
# The method call follows the same API of the Node.js, JAVA and Python SDKs.
# See https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_the_firebase_admin_sdk
# Dependencies:
# ---------------
# gem 'activesupport'
@daaximus
daaximus / usb.extended.ids
Created April 1, 2023 03:27
Extended USB Device List
This file has been truncated, but you can view the full file.
0000:0000=Device
0000:0002=USB Implementer Forum Mass Storage
0000:3825=USB Mouse
0000:7777=USB Flash Drive
0001:0001=Gaming Optical Mouse5
0001:142b=Arbiter Systems, Inc.
0001:7778=Fry's Electronics Counterfeit flash drive [Kingston]
0002:0002=Ingram passport00
0002:7007=Ingram HPRT XT300
0009:21e7=Sagemcom