Skip to content

Instantly share code, notes, and snippets.

@jefftriplett
jefftriplett / python-django-postgres-ci.yml
Last active March 27, 2024 04:27
This is a good starting point for getting Python, Django, Postgres running as a service, pytest, black, and pip caching rolling with GitHub Actions.
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
services:
@LeZuse
LeZuse / stats_logger.rb
Last active June 21, 2021 13:53
Puma plugin for stats logging on Heroku
Puma::Plugin.create do
def production?
ENV.fetch('RACK_ENV', 'development') == 'production'
end
def log(msg)
if production?
Rails.logger.info msg
else
puts msg
@EricADockery
EricADockery / Fastfile
Created July 25, 2017 16:42
Parallel iOS Testing using Bluepill
lane :bluepill do
scan(scheme: “myApp”, build_for_testing: true)
sh “bash ./bluepill.sh“
end
@jicowan
jicowan / enable-mfa-delete.py
Created July 14, 2017 05:26
enable mfa-delete on a bucket
import boto3
from botocore.exceptions import ClientError
s3_client = boto3.client('s3')
s3_bucket = boto3.resource('s3')
bucket_name = raw_input('Enter the name of the bucket that you want to enable MFA-delete on: ')
mfa_token = raw_input('Enter your MFA serial number and token code, e.g. <deviceSerialNumber> <tokenCode>: ')
try:
s3_bucket.meta.client.head_bucket(Bucket=bucket_name)
@carolineartz
carolineartz / _ex.md
Last active February 27, 2018 15:50
example testing out `ActiveRecord::Aggregations`

Usage

# in your controller you can use
@domain = CreateDomains.new('car.oline.codes').call #=> returns Domain with name 'car' that is the child of `oline.codes`
@domain.web_address.to_s #=> 'car.oline.codes'

You can use your logic for subtree equality to compare the actual web_address value objects, which are immutable. You could also see all the 'parent' strings for a given web_address object

@thatbudakguy
thatbudakguy / hostapd.conf
Last active March 29, 2022 12:49
hostapd configuration for a 5ghz wireless network.
interface=(INTERFACE HERE)
driver=nl80211
ssid=(SSID HERE)
hw_mode=a
channel=36
country_code=US
ignore_broadcast_ssid=0
wpa=2
#!/usr/bin/env bash
# Exit on error
set -e
# On MacOS, make sure shuf command is available
if uname | grep -q Darwin
then
which brew &> /dev/null || echo "please install brew: https://brew.sh" && exit 1
@penguinpowernz
penguinpowernz / README.md
Last active November 13, 2024 04:40
WPA CLI commands
command args description
status [verbose] get current WPA/EAPOL/EAP status
ifname get current interface name
ping pings wpa_supplicant
relog re-open log-file (allow rolling logs)
note <text> add a note to wpa_supplicant debug log
mib get MIB variables (dot1x, dot11)
help [command] show usage help
interface [ifname] show interfaces/select interface
@ajaxray
ajaxray / select2-cascade.js
Last active October 5, 2024 18:22
Making Select2 (4.x) list boxes cascading / dependent. Options of a select2 list box will be loaded/refreshed by ajax based on selection of another select2 list box.
/**
* A Javascript module to loadeding/refreshing options of a select2 list box using ajax based on selection of another select2 list box.
*
* @url : https://gist.github.com/ajaxray/187e7c9a00666a7ffff52a8a69b8bf31
* @auther : Anis Uddin Ahmad <[email protected]>
*
* Live demo - https://codepen.io/ajaxray/full/oBPbQe/
* w: http://ajaxray.com | t: @ajaxray
*/
var Select2Cascade = ( function(window, $) {
@alassek
alassek / 01_Annotated_Source.md
Last active November 19, 2023 11:53
Extending Arel to support @> operator

I've been doing some work lately with JSON documents in PostgreSQL using jsonb columns. You can query these documents using a GIN index in PG, but the syntax can be a little cumbersome

SELECT "events".* FROM "events" WHERE "events"."body" @> '{"shift":{"user_id":2}}'

You have to construct the right side of the query as a JSON string, which is a bit annoying. So I wondered if I could adapt Arel to do the tedious stuff for me.