Skip to content

Instantly share code, notes, and snippets.

View timcase's full-sized avatar

Tim Case timcase

View GitHub Profile
#!/usr/bin/env bash
# Drop everything from the scissors line down (git commit -v diff),
# then strip comment lines
msg=$(sed '/^# -\+ >8 -\+$/,$d' "$1" | grep -v '^#')
subject=$(printf '%s' "$msg" | head -1)
# Skip autosquash targets and merge commits — not subject to normal formatting
if [[ "$subject" =~ ^(fixup|squash|amend)\!\ ]] || [[ "$subject" == Merge\ * ]]; then
exit 0
require "digest"
require "rack"
# This class encapsulates a unit of work done for a particular tenant, connected to that tenant's database.
# ActiveRecord makes it _very_ hard to do in a simple manner and clever stuff is required, but it is knowable.
#
# What this class provides is a "misuse" of the database "roles" of ActiveRecord to have a role per tenant.
# If all the tenants are predefined, it can be done roughly so:
#
# ActiveRecord::Base.legacy_connection_handling = false if ActiveRecord::Base.respond_to?(:legacy_connection_handling)
@timcase
timcase / kamal-production-server-setup.sh
Last active June 1, 2026 11:37 — forked from rameerez/kamal-production-server-setup.sh
Set up a Ubuntu server to deploy Kamal 2.x Docker containers to, hardened security and production ready
#!/bin/bash
# Production Docker Host Hardening Script v2
# For Ubuntu Server 26.04 LTS (Resolute)
# Suitable for both Kamal deployment and builder hosts
#
# Usage:
# curl -fsSL https://gist.githubusercontent.com/timcase/be550d75c5071ab7651a76f601a120a1/raw/kamal-production-server-setup.sh | sudo bash
set -euo pipefail
@timcase
timcase / prometheus_node.json
Created April 29, 2022 16:44
role for prometheus node
{
"name": "prometheus_node",
"json_class": "Chef::Role",
"default_attributes": {
"twodrops_prometheus": {
"components": {
"node_exporter": {
"install?": true,
"cli_opts": {
"collector.systemd": "",
INSIDE OF .taskrc:
report.monwait.columns=id,start.active,project,tags,wait,wait.remaining,due,until,description
report.monwait.description=tasks sorted by due date ascending
report.monwait.filter=wait:mon
report.tuewait.columns=id,start.active,project,tags,wait,wait.remaining,due,until,description
report.tuewait.description=tasks sorted by due date ascending
report.tuewait.filter=wait:tue
def print_bill
outstanding = 0.0
#print banner
puts "*************************"
puts "******Customer Owes******"
puts "*************************"
# calculate outstanding
@timcase
timcase / DialogMixin.js
Created April 30, 2017 10:05
onSubmit modded to accept state from redux-form
var React = require('react');
var ReactDOM = require('react-dom');
// var $ = require('jquery');
module.exports = {
propTypes: {
onSubmit: React.PropTypes.func.isRequired
},
@timcase
timcase / TextField.js
Created April 30, 2017 10:03
TextField modded to support redux-form Field props
var React = require('react');
module.exports = React.createClass({
displayName: 'TextField',
propTypes: {
label: React.PropTypes.string.isRequired,
value: React.PropTypes.string.isRequired,
},
@timcase
timcase / Create.js
Created April 30, 2017 09:57
Redux form with lore bootstrap create form
var React = require('react');
var DialogMixin = require('../mixins/DialogMixin');
var StringField = require('../fields/StringField');
var TextField = require('../fields/TextField');
var BooleanField = require('../fields/BooleanField');
var NumberField = require('../fields/NumberField');
var _ = require('lodash');
var reduxForm = require('redux-form').reduxForm;
var Field = require('redux-form').Field;
@timcase
timcase / todo.js
Last active April 17, 2017 14:07
Todo mutation
handleCompletedClick = () => {
const originalTodo = Object.assign({}, this.props.todo);
let todo = this.props.todo;
todo.completed = true
this.props.update(todo, originalTodo);
}
export const updateTodo = (todo, originalTodo) => {
const url = 'http://localhost:3001/todos/' + todo.id;