Skip to content

Instantly share code, notes, and snippets.

@m-radzikowski
m-radzikowski / script-template.sh
Last active May 4, 2024 04:13
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@byronmansfield
byronmansfield / install-openssl-from-src-mac
Last active December 15, 2023 05:51
Install OpenSSL from source Mac OS X
# Install OpenSSL from source on Mac OS X
# prepare workspace
mkdir -p ~/code/build-from-src/ && cd $_
# download source code
curl -LO https://www.openssl.org/source/openssl-1.1.1d.tar.gz
# expand tar
tar -xzvf openssl-1.1.1d.tar.gz
@hjhart
hjhart / blog.md
Last active August 6, 2021 07:35

Effective Caching for Yarn, Bundler, and Rails Asset Pipeline in CircleCI

Phil Karlton said: "There are two hard problems in computer science: cache invalidation, naming things, and off-by-1 errors."

Well, maybe he didn't say exact that, but it's a decent joke anyway.

In this article I'll talk about the first of those problems, caching. And in doing so effectively, how we reduced our CircleCI build times by 33%. For those of you raising your eyebrows and saying "33% off of what?!", I'll direct your eyeballs to the graph below for some absolute numbers.

[ TODO: Show a bar graph of each job going down by a percentage ]

@hmcfletch
hmcfletch / config.yml
Created September 21, 2018 19:40
An example Circle CI workflow for a Ruby on Rails app
version: 2
jobs:
checkout_and_deps:
docker:
- image: circleci/ruby:2.5.1-node-browsers
steps:
- checkout
- run:
@odigity
odigity / knex.js
Last active February 2, 2021 14:34
Wrapping a unit test in a transaction for easy cleanup with Knex.js
#!/usr/bin/node
const Promise = require('bluebird')
const config = require('./config.json')
const knex = require('./lib/knex')(config.database).connection()
const mock = () => ({ user_id: Math.floor(Math.random() * 999) + 1, payload_type: 'foo', attributes: JSON.stringify({}) })
const before = (t) => {
# This unfortunate hack is necessary because ActiveRecord doesn't provide any
# way (clean or otherwise) to circumvent the default_scope when preloading.
#
# Here's a closed-but-unresolved issue that goes into it a bit more:
#
# https://github.com/rails/rails/issues/11036
#
# Example usage:
#
# In this scenario, Product and User may have paranoid deletes, and a
@baweaver
baweaver / ruby_books.md
Last active April 24, 2024 19:24
A list of books for learning and expanding on your Ruby knowledge.

Ruby Book List

Learning Ruby

You're taking your first steps into Ruby

A good introduction to programming in general. Easy on newer programmers.

# Cleans up branches like:
# if Shopify.rails_next?
# # Rails 5 login
# else
# # Rails 4 login
# end
module RuboCop
module Cop
module ShopifyRails
class RailsNextUnless < Cop
@koppen
koppen / pre-commit
Created January 25, 2016 08:50
Run rubocop on pre-commit
# .git/hook/pre-commit
#!/bin/sh
#
# Check for ruby style errors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
NC='\033[0m'
@willpatera
willpatera / Google-Sheet-Form-Post.md
Last active May 3, 2024 12:57
Post to google spreadsheet from html form

Overview

This collection of files serves as a simple static demonstration of how to post to a google spreadsheet from an external html <form> following the example by Martin Hawksey

Depreciation Warning: This code is not maintained, and should be seen as reference implementation only. If you're looking to add features or update, fork the code and update as needed.

Run example

You should be able to just open index.html in your browser and test locally.