Skip to content

Instantly share code, notes, and snippets.

View pre's full-sized avatar
🚀
Cloud & Kubernetes

Petrus Repo pre

🚀
Cloud & Kubernetes
View GitHub Profile
@pre
pre / s3etag.sh
Created March 27, 2024 10:11 — forked from emersonf/s3etag.sh
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then
@pre
pre / rails-reload-example.rb
Created November 12, 2021 13:04 — forked from teohm/rails-reload-example.rb
unload/reload
# Goal: put a non-Rails-aware Ruby library using normal `require`s in
# lib/mything. Have it transparently reloaded between requests like Rails app
# code is.
#
# The code here goes inside of your configure block in
# config/environments/development.rb. There are two parts, commented inline.
# Disable reload_classes_only_on_change. This makes Rails invoke the reloader
# even if no source files are changed. This is necessary because the autoloader
# and reloader don't know about our library, so they won't know to trigger a
@pre
pre / README.md
Created April 3, 2021 09:46 — forked from gtzilla/README.md
The Scripts/Config files to Create a Wireless Access Point with traffic tunneled through a socks5 proxy. Running Debian Stretch Proxmox VE 5. Uses hostapd running proxmox

Wireless Access Point

The is a collection of files that I used to create a Wireless access point that tunnels traffic through a socks5 proxy using tun2socks, hostapd, dnsmasq. This was done on a debian system, specifically Proxmox VE. The underlying hardware is an Intel Nuc. The wireless card currently only handles wireless G traffic. Testing "a" wireless resulted in the wireless interface not coming up. This could be merely user error. More information on setting hg_mode in hostapd.conf

This took approximately two days to setup corretly. The tutorials that address how-to create an access point, as well as how-to use tun2socks varied considerably. I was finally able to cobble together a working prototype that is able to tunnel traffic from my wireless access point through any SSH connection that can enable socks5 proxy.

@pre
pre / pg_enum.rb
Created February 2, 2017 14:59 — forked from clarkdave/pg_enum.rb
basic support for PostgreSQL Enums in ActiveRecord - to be placed in an initializer
##
# This provides `create_enum` and `drop_enum` methods for migrations, which creates
# a Postgres ENUM type with the provided values.
#
# It'll also dump these into the schema.rb to be loaded into another DB (e.g. rake db:test:load)
#
# In order to reference the new enums as actual types, ActiveRecord needs to know about them, so
# make sure they are all represented in the `types` array below
#
# Then you can reference them in your migrations, e.g.
@pre
pre / pg_interval_support_4_1.rb
Created February 2, 2017 14:59 — forked from Envek/pg_interval_support_4_1.rb
Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails 4.1 and 4.2
# Enables PostgreSQL interval datatype support (as ActiveSupport::Duration) in Ruby on Rails 4.1.
# Based on https://gist.github.com/clarkdave/6529610
require 'active_support/duration'
# add a native DB type of :interval
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:interval] = { name: 'interval' }
# add the interval type to the simplified_type list. because this method is a case statement
# we can't inject anything into it, so we create an alias around it so calls to it will call
@pre
pre / what-forces-layout.md
Created September 23, 2015 11:01 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()

This is an example of using Linux Kernel's Transparent Proxy to route all TCP traffic to docker containers without having to resort to PROXY protocol which is not supported by some applications (e.g. sshd). To get the demo to work you only need vagrant installed:

git clone [this-gist] tproxy-demo
cd tproxy-demo
vagrant up