Skip to content

Instantly share code, notes, and snippets.

@tatey
tatey / shell.nix
Created February 23, 2023 23:21
Minimal shell.nix for Ruby on Rails
let
nixpkgs =
import (builtins.fetchTarball {
url = https://github.com/NixOS/nixpkgs/archive/f5dad40450d272a1ea2413f4a67ac08760649e89.tar.gz; # Pinned to unstable. Update by picking a SHA from https://status.nixos.org
}) { };
in
nixpkgs.mkShell {
buildInputs = [
nixpkgs.ruby_3_1
nixpkgs.nodejs-18_x
@tatey
tatey / 1_sources.nix
Created February 23, 2023 23:17
0_shell.nix
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: spec:
if spec.builtin or true then
@tatey
tatey / 0_shell.nix
Last active November 1, 2022 07:33
A quick script to enable "all access" on a bunch of projects
let
nixpkgs =
import (builtins.fetchTarball {
url = https://github.com/NixOS/nixpkgs/archive/e6e6bad81b7e11f37d893ef39712ce8918ae2338.tar.gz;
}) { };
in
nixpkgs.mkShell {
buildInputs = [
nixpkgs.chromedriver
nixpkgs.ruby_3_1
#!/usr/bin/env bash
# Datadog bills by the number of unique hosts that were used in the month and
# every time we launch a one off dyno it results in a new
# host (e.g. run.4030404). This script is executed when the dyno launches and
# determines whether the agent should be running to reduce the number of
# unique hosts that we are billed for.
# Disable the Datadog Agent for one-off runs (e.g. console, release).
if [ "$DYNOTYPE" == "run" ] || [ "$DYNOTYPE" == "release" ]; then
@tatey
tatey / 00_cli
Created May 17, 2019 11:28
Federal Election 2019 Bingo Card Generator in Ruby
$ ruby 01_bingo.rb > ~/Downloads/board_1.html
@tatey
tatey / 0_MyView.swift
Created March 30, 2019 11:56
Why can't I use this "setter" via the Appearance proxy?
class MyView: UIView {
func set(borderTintColor: UIColor?, forControlState controlState: UIControl.State) {
// literally empty
}
// I've also tried prefixing with @objc
}
@tatey
tatey / 0_MyView.swift
Created March 30, 2019 11:56
Why can't I use this "setter" via the Appearance proxy?
class MyView: UIView {
func set(borderTintColor: UIColor?, forControlState controlState: UIControl.State) {
// literally empty
}
// I've also tried prefixing with @objc
}
import UIKit
class LayoutMarginsHackView: UIView {
var actualLayoutMargins: UIEdgeInsets = .zero
override var layoutMargins: UIEdgeInsets {
set {
if #available(iOS 11, *) {
super.layoutMargins = newValue
} else {
@tatey
tatey / 0_attribute_encrypted.rb
Last active August 21, 2018 22:28
AttributeEncrypted is a simple way to encrypt values in the database using the same mechanism as Rails credentials, including the master key.
# AttributeEncrypted is a simple way to encrypt values in the database
# using the same mechanism as Rails credentials, including the master key.
#
# Example:
# class User
# include AttributeEncrypted
#
# attr_accessor :encrypted_secret
# attr_encrypted :secret
# end
@tatey
tatey / equality.rb
Created August 2, 2018 11:37
What could possibly go wrong?
module Equality
def ==(other)
return false unless other.is_a?(self.class)
instance_variables.all? do |ivar|
instance_variable_get(ivar) == other.instance_variable_get(ivar)
end
end
end