Skip to content

Instantly share code, notes, and snippets.

@vncsna
vncsna / bash_strict_mode.md
Created June 6, 2021 01:59 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@rbalman
rbalman / cfn-delete.sh
Last active November 23, 2022 05:37
Delete all the CloudFormation stacks with given search-pattern recursively until every stack is deleted. Make sure to provide DELETE_PATTERN, AWS_PROFILE, AWS_REGION mandatory variables. Dependencies: JQ
#!/bin/bash
if [ -z "${DELETE_PATTERN}" ]
then
echo "please set DELETE_PATTERN environment variable with pattern to delete"
exit
fi
if [ -z "${AWS_PROFILE}" ]
then
@JoaoCarabetta
JoaoCarabetta / README.md
Last active February 3, 2022 16:05
Add Time Based Glue Partitions with Lambda AWS

Creates time based Glue partitions given time range.

Keep in mind that you don't need data to add partitions. So, you can create partitions for a whole year and add the data to S3 later.

@jamtur01
jamtur01 / ladder.md
Last active July 4, 2024 19:31
Kickstarter Engineering Ladder
@ejoubaud
ejoubaud / simulate_keypress.js
Last active April 9, 2024 18:38
Simulate keypress that works in Google nav in Chrome
// Based on http://stackoverflow.com/a/10520017/1307721 and http://stackoverflow.com/a/16022728/1307721
Podium = {};
Podium.keydown = function(k) {
var oEvent = document.createEvent('KeyboardEvent');
// Chromium Hack
Object.defineProperty(oEvent, 'keyCode', {
get : function() {
@joekur
joekur / security_notes.md
Created May 22, 2014 17:00
Security notes for Rails

STAY SAFE!

SQL Injection

Never interpolate user input directly in a SQL statement.

Don't:

User.where("name = #{params[:search][:name]}")
@emad-elsaid
emad-elsaid / gmail2tumblr.rb
Created March 6, 2014 12:19
gmail to tumblr posting script
#!/usr/bin/env ruby
require 'mail' # gem install mail --no-document
# Credit to :
# http://stackoverflow.com/questions/12884711/how-to-send-email-via-smtp-with-rubys-mail-gem
def ask question
print "#{question} ? : "
$stdin.gets.chomp!
end
module FactoryGirlAdditions
# create instance without running callbacks and validations
def insert(*args)
record = FactoryGirl.build(*args)
def record.run_callbacks(*args, &block)
if block_given?
block.arity.zero? ? yield : yield(self)
end
end
record.save!
# inspired by http://blog.leshill.org/blog/2011/10/23/fast-specs.html
# to get specs running without rails (faster) do
# SKIP_RAILS=yes time bundle exec rspec
# or
# SKIP_RAILS=yes time bundle exec guard
# spec_helper