Skip to content

Instantly share code, notes, and snippets.

View markandrewj's full-sized avatar

Mark Jackson markandrewj

  • Canada
View GitHub Profile
@markandrewj
markandrewj / tmux.conf
Last active April 9, 2024 01:56
Basic Tmux Status Bar
# ----------------------
# Status Bar
# -----------------------
set-option -g status on # turn the status bar on
set -g status-utf8 on # set utf-8 for the status bar
set -g status-interval 5 # set update frequencey (default 15 seconds)
set -g status-justify centre # center window list for clarity
# set-option -g status-position top # position the status bar at top of screen
# visual notification of activity in other windows
@markandrewj
markandrewj / gist:9270d311c3a14b3c3565
Last active August 17, 2022 04:30
How To Stub authentication in Devise controller specs

https://github.com/plataformatec/devise/wiki/How-To:-Stub-authentication-in-controller-specs

These are instructions for allowing you to use resource test doubles instead of actual ActiveRecord objects for testing controllers where Devise interactions are important. This means there's even less reliance on the database for controller specs, and that means faster tests!

This approach certainly needs some evolution, but it's a start.

To stub out your user for an action that expects an authenticated user, you'll want some code like this (once you've got Devise::TestHelpers loaded):

 user = double('user')

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@markandrewj
markandrewj / pedantically_commented_playbook.yml
Created November 17, 2016 07:02 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@markandrewj
markandrewj / examples.md
Created November 13, 2016 04:28 — forked from jonschlinkert/examples.md
Three files: examples.md, yaml-cheatsheet.md and yaml-cheatsheet.yml

adapted from this blog

# YAML
name: Jon
# YAML
object:
@markandrewj
markandrewj / fb-rotate
Last active August 26, 2016 00:17
Program to rotate second display from command line or keyboard shortcut
// fb-rotate.c
#include <getopt.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <ApplicationServices/ApplicationServices.h>
#define PROGNAME "fb-rotate"
#define MAX_DISPLAYS 16
// kIOFBSetTransform comes from <IOKit/graphics/IOGraphicsTypesPrivate.h>
@markandrewj
markandrewj / app.html
Created August 17, 2016 00:39 — forked from nch3ng/Froala and Carrierwave-RoR Demo.html
Image upload with Froala and Rails 4, Carrierwave
...
...
<textarea froala="froalaOptions"></textarea>
...
...
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@markandrewj
markandrewj / gist-download
Created August 21, 2014 04:18
Download all files from a Gist without Git
curl -L https://gist.github.com/westonruter/ea038141e46e017d280b/download | tar -xvz --strip-components=1
@markandrewj
markandrewj / rules-both.iptables
Last active June 5, 2016 03:26 — forked from jirutka/rules-both.iptables
starting/basic iptables ideas (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is