Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Daniels adam12

View GitHub Profile
View database_cleaner.rb
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
@adam12
adam12 / 1 - I plan to turn these off
Created Nov 15, 2019 — forked from dlangille/1 - I plan to turn these off
Periodic things to turn off in FreeBSD jails
View 1 - I plan to turn these off
# after reviewing /etc/defaults/periodic.conf I have decided
# to disable these items in jails
daily_status_disks_enable="NO"
daily_status_network_enable="NO"
daily_status_uptime_enable="NO"
# not needed on jails
daily_ntpd_leapfile_enable="NO"
View cron_helper.sh
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]... COMMAND
Execute the given command in a way that works safely with cron. This should
typically be used inside of a cron job definition like so:
* * * * * $(which "$0") [OPTION]... COMMAND
Arguments:
@adam12
adam12 / accounts.txt
Created May 8, 2019 — forked from simonmichael/accounts.txt
a sample *ledger chart of accounts (first 3 levels): combined personal & business, eg for a freelancer
View accounts.txt
assets
business
accounts receivable
bank
personal
accounts receivable
bank
cash
gifts
online
@adam12
adam12 / lazy.rb
Created Apr 23, 2019 — forked from localhostdotdev/lazy.rb
Lazy: fetch deep values only when you need to
View lazy.rb
# Example: Lazy.new(lambda { |id| API::HackerNews.item(id) }, 0)
class Lazy
attr_reader :value
def initialize(function:, value:)
@function = function
@value = value
@cached = nil
@is_cached = false
@adam12
adam12 / async.rb
Created Apr 1, 2019 — forked from paul/async.rb
Implementations of useful step adapters for dry-transaction
View async.rb
# frozen_string_literal: true
module Tesseract
module Transaction
module Steps
# Executes the step in a background job. Argument is either an ActiveJob
# or another Transaction (or anything that implements `#perform_later`.
#
# If the provided transaction implements a `validate` step, then that
# validator will be called on the input before the job is enqueued. This
@adam12
adam12 / jail.conf
Created Oct 18, 2018 — forked from paulc/jail.conf
FreeBSD ZFS Jail
View jail.conf
interface = "lo1";
host.hostname = "$name";
ip4.addr = "172.16.0.$n";
path = "/jail/run/$name";
exec.prestart = "/sbin/zfs clone zroot/jail/template/10.2-RELEASE/root@10.2-RELEASE-p8 zroot/jail/run/$name &&
/usr/sbin/sysrc -f /jail/run/$name/etc/rc.conf hostname=$name &&
/usr/sbin/sysrc -f /jail/run/$name/etc/rc.conf sshd_enable=YES &&
/usr/sbin/sysrc -f /jail/run/$name/etc/rc.conf sshd_flags=\"-o ListenAddress=172.16.0.$n\" &&
/usr/sbin/pw -R /jail/run/$name useradd -n u01 -m -w random &&
/usr/sbin/pw -R /jail/run/$name lock root &&
View build.py
#!/usr/bin/env python
import errno
import os
import subprocess
import sys
import shutil
import glob
import tarfile
import os.path
View exec_scanner.go
package main
import (
"bufio"
"fmt"
"io"
"log"
"os/exec"
)
View cgi.go
package main
import (
"fmt"
"net/http"
"net/http/cgi"
"os"
)
type Handler func(http.ResponseWriter, *http.Request)
You can’t perform that action at this time.