Skip to content

Instantly share code, notes, and snippets.

View nathanpalmer's full-sized avatar

Nathan Palmer nathanpalmer

  • Crowd Ox
  • Washington, DC
View GitHub Profile
# app/controllers/quotes_controller.rb
def create
@quote = current_company.quotes.build(quote_params)
if @quote.save
respond_to do |format|
format.html { redirect_to quotes_path, notice: "Quote was successfully created." }
format.turbo_stream { flash.now[:notice] = "Quote was successfully created." }
end
require 'conderaction'
class Model
def save
end
end
class Changeset
attr_reader :model, :context
Process: Core Shell [1147]
Path: /Applications/Setapp/Core Shell.app/Contents/MacOS/Core Shell
Identifier: io.coressh.shell-setapp
Version: 2.0 (2755)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Core Shell [1147]
User ID: 501
Date/Time: 2020-03-26 10:34:36.593 -0400

Keybase proof

I hereby claim:

  • I am nathanpalmer on github.
  • I am nathanpalmer (https://keybase.io/nathanpalmer) on keybase.
  • I have a public key ASASYErCUBm6sRqt-fLFGivposbrs4n2d-d4HRg7j9fkUwo

To claim this, I am signing this object:

@nathanpalmer
nathanpalmer / x11vnc.service
Created January 6, 2019 03:29
x11vnc.service
[Unit]
Description=VNC Server for X11
Requires=display-manager.service
After=display-manager.service
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -xkb -repeat -allow 127.0.0.1 -display :0 -auth guess -rfbauth /home/nathan/.vnc/passwd -rfbport 5900 -forever -loop -o /var/log/x11vnc.log
Restart=on-failure
RestartSec=10
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
@nathanpalmer
nathanpalmer / fish_prompt.fish
Last active June 24, 2018 18:49
Mercurial & Git prompt using the Fish shell
## Requires
## hg prompt : http://stevelosh.com/projects/hg-prompt/
## fish : http://fishshell.com/
## mercurial : http://mercurial.selenic.com/
## git : http://git-scm.com/
set -g __fish_hg_prompt_color "cyan"
set -g __fish_hg_prompt_color_status "cyan"
# check only on startup if the "hg prompt" extension is installed
@nathanpalmer
nathanpalmer / git-switch-branch
Last active April 4, 2018 15:18
Auto migrate rails when switching branches
#!/usr/bin/env bash
function git_dirty {
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*"
}
if [ "$(git_dirty)" == "*" ]; then
echo "You must run this command on a clean repository (no changes)"
exit
fi
@nathanpalmer
nathanpalmer / logger.rb
Last active December 28, 2017 17:02
Index
LOGGER = if !ENV['TIMBER_API_KEY'].nil?
require 'timber'
Timber.config.integrations.rack.http_events.silence_request = lambda do |rack_env, rack_request|
# rack_request.path returns a string *without* the query string.
# The request of the lambda must be a boolean
rack_request.path == "/status" ||
rack_request.path == "/favicon.ico"
end
@nathanpalmer
nathanpalmer / nomad-drain-and-wait.py
Created December 2, 2017 17:44
nomad-drain-and-wait.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
## Taken from: https://gist.github.com/blalor/246eaf5755e784b353ab756a36a1142e
##
## in order to cleanly shut down a node with running jobs, the node needs to be
## drained, and then we need to wait for allocations to be migrated away. in
## this script, we:
## * set up a watch for node-update evals for the current node
## * wait for allocations currently running to complete