Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
usage ()
{
cat <<UsageHERE
boot2docker-fwd -- Helper function to quickly manage port forwards between the boot2docker-vm and the host
Usage: boot2docker-fwd [ -n RULE_NAME ] [ -h HOST_PORT ] [ -p {tcp|udp} ] [ -i HOST_IP ] GUEST_PORT
or boot2docker-fwd -d RULE_NAME
or boot2docker-fwd -l
or boot2docker-fwd -A
@digglife
digglife / ppdeploy.bat
Last active June 20, 2018 23:56
Batch Script for deploying puppet agent
@ECHO OFF
REM Get Administrator Privilege on Windows 6+
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
IF '%errorlevel%' NEQ '0' (
ECHO Requesting administrative privileges...
GOTO UACPrompt
) ELSE ( GOTO gotAdmin )
:UACPrompt
@gkspranger
gkspranger / decrypt.yml
Last active January 9, 2020 05:10
a common way to decrypt a whole file using ansible vault and openssl
---
# this is how you encrypt a file using openssl and aes-256
# openssl aes-256-cbc -salt -a -e -in <src file> -out <out file> -k <enc salt>
# expects you pass in vars:
# enc_src_file -- local location of encrypted src file that will copied to target node
# enc_src_dest -- where the decrypted file should be put
# enc_salt -- salt used to decrypt
# enc_file_user -- user ownership
@csexton
csexton / v.zsh
Created January 27, 2015 20:01
Use a fuzzy finder to open a file in $EDITOR
# v Command {{{
# Fuzzy file opener in your editor
v(){
file=$(fzf)
[[ -n "$file" ]] && $EDITOR $file
}
# }}}
@chsh
chsh / pg_pub_sub.rb
Last active January 2, 2025 16:56
PostgreSQL LISTEN/NOTIFY example for ruby
#
# A:
# pubsub = PgPubSub.new('channelname')
# pubsub.subscribe do |data|
# puts "data: #{data} is coming!"
# end
#
# B:
# pubsub = PgPubSub.new('channelname')
# pubsub.publish("hello world")
@jezhumble
jezhumble / coc.md
Last active November 9, 2019 05:19
Some notes on codes of conduct from a conference organizer's perspective

Some notes on codes of conduct from a conference organizer's perspective

  1. The customers of a Code of Conduct are the people whom it is protecting. For tech conferences, that means marginalized people.
  2. The Code of Conduct is a promise to its customers from the conference organizers that they will be in a safe space, and that they will be protected and given the benefit of the doubt in the event of something bad happening.
  3. Thus the wording of a code of conduct should be decided by its customers. The Geek Feminism wiki hosts an example code of conduct: http://geekfeminism.wikia.com/wiki/Anti-harassment_policy_resources
  4. The legal basis of a code of conduct is my right, as an event organizer, to kick anybody out of my private event for any reason, even if they have paid. This happens all the time, often with the most flimsy excuses: http://www.hannahettinger.com/guest-post-by-clare/

If you, as a non-customer of the CoC, are not

@caged
caged / score-buildings.sql
Last active August 29, 2015 14:01
Scoring buildings based on proximity to neighborhood features
drop table if exists target_homes;
with
supermarket_zones as (select st_expand(geom, 0.0045) as zone, 5 as score from osm_polygons where osm_polygons.shop='supermarket'),
rail_stop_zones as (select st_expand(geom, 0.0045) as zone, 5 as score from trimet_rail_stops),
park_zones as (select st_expand(geom, 0.0045) as zone, 2 as score from osm_polygons where osm_polygons.leisure='park'),
target_buildings as (
select * from supermarket_zones inner join buildings on st_intersects(supermarket_zones.zone, buildings.geom) where buildings.subarea='City of Portland'
union select * from rail_stop_zones inner join buildings on st_intersects(rail_stop_zones.zone, buildings.geom) where buildings.subarea='City of Portland'
)
@dhh
dhh / test_induced_design_damage.rb
Last active November 2, 2024 00:52
This is an extraction from Jim Weirich's "Decoupling from Rails" talk, which explained how to apply the hexagonal design pattern to make every layer of your application easily unit testable (without touching the database etc). It only seeks to extract a single method, the EmployeesController#create method, to illustrate the design damage that's …
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active May 7, 2025 05:43
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@danrigsby
danrigsby / packer-ami-id
Last active December 14, 2023 15:07
Get AMI ID from a packer build
packer build packer.json 2>&1 | sudo tee output.txt
tail -2 output.txt | head -2 | awk 'match($0, /ami-.*/) { print substr($0, RSTART, RLENGTH) }' > sudo ami.txt