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 / 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
@nathanpalmer
nathanpalmer / imagemagick.rb
Last active December 6, 2016 04:35
Install ImageMagick 6.9.1-10
class Imagemagick < Formula
desc "Tools and libraries to manipulate images in many formats"
homepage "http://www.imagemagick.org"
url "http://www.imagemagick.org/download/releases/ImageMagick-6.9.1-10.tar.xz"
mirror "http://ftp.nluug.nl/ImageMagick/ImageMagick-6.9.1-10.tar.xz"
sha256 "22565464059376513869b6626982e0726a33788ccc7e19a08e55ff1683d4ff92"
head "https://subversion.imagemagick.org/subversion/ImageMagick/trunk",
:using => :svn
@nathanpalmer
nathanpalmer / base_action.rb
Last active August 29, 2015 14:16
Action separation for a controller
# Setup in a scenario way with perform the basic action that we have from base_actions controller
#
# Emulate or possibly just use the callbacks from within rails
# https://github.com/rails/rails/blob/master/actionpack/lib/abstract_controller/callbacks.rb
#
# This gives us the before_/after_/around_ filters along with a `run_callbacks` method
class BaseUpdateAction
def perform(method)
saved = each_from_parameters(params[collection_name]) do |model_hash|
# Need a way to get access to the model we're getting, but I haven't dug into the run_callbacks method