Skip to content

Instantly share code, notes, and snippets.

View willis7's full-sized avatar
🏠
Working from home

Sion Williams willis7

🏠
Working from home
View GitHub Profile
@willis7
willis7 / systemd-cheat-sheet.md
Last active November 17, 2022 10:11
Systemd Cheat Sheet

The most notable distribution using systemd is Fedora. Though it is used by many others. Additionally, with Debian having chosen to go with systemd over upstart, it will become the defacto upstart system for most distributions (ubuntu has already announced they will be dropping upstart for systemd).

Common Systemd Commands

  • systemctl -- list all known services
  • systemd-analyze blame -- time spent by each task during the boot process
  • systemd-analyze critical-chain -- list of the critical chain of tasks during the boot process
  • systemctl list-dependencies -- the list of the dependencies
    • systemctl list-dependencies sshd.service -- list sshd dependencies
    • systemctl list-dependencies graphical.target | grep target -- dependencies for a particular target
  • systemctl daemon-reload -- reload the configuration
@willis7
willis7 / vagrant-cheat-sheet.md
Last active March 22, 2017 10:55 — forked from wpscholar/vagrant-cheat-sheet.md
Vagrant Cheat Sheet

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Common Vagrant Commands

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
  • vagrant status -- outputs status of the vagrant machine
  • vagrant halt -- stops the vagrant machine
  • vagrant reload -- restarts vagrant machine, loads new Vagrantfile configuration
  • vagrant provision -- forces reprovisioning of the vagrant machine
@willis7
willis7 / JsonSyntaxError.go
Last active January 3, 2017 20:26
An example, the json package specifies a SyntaxError type that the json.Decode function returns when it encounters a syntax error parsing a JSON blob.
if err := dec.Decode(&val); err != nil {
if serr, ok := err.(*json.SyntaxError); ok {
line, col := findLine(f, serr.Offset)
return fmt.Errorf("%s:%d:%d: %v", f.Name(), line, col, err)
}
return err
}
@willis7
willis7 / docker-alias.txt
Created December 30, 2016 11:55
Alias a docker run command for clean use of binaries
$ docker pull quay.io/goswagger/swagger
$ alias swagger="docker run --rm -it -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger"
$ swagger version
@willis7
willis7 / test-helpers.go
Last active May 2, 2016 11:22
Test Helpers for Go
// testTempFile
// create a temp file using only a single line
// cleanly manages err handling
func testTempFile(t *testing.T) string {
tf, err := ioutil.TempFile("", "test")
if err != nil {
t.Fatalf("err: %s", err)
}
tf.Close()
@willis7
willis7 / gist:9e8c7e99a11143293d25
Created March 21, 2016 16:09
Installing Java 8 on Ubuntu
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
@willis7
willis7 / build.gradle
Created March 1, 2016 10:00
Copy files from a configuration to a specific area
repositories {
jcenter()
}
// Define a configuration with a name which logically represents the files you want to retrieve.
// As these are dependencies required to build, I have called the configuration `build`
configurations {
build
}
@willis7
willis7 / playbookscaffold.sh
Last active February 10, 2016 14:11
Creates everything that is required for a Playbook, including an inventory and a place to store variables for different environments
#!/usr/bin/env bash
# Display usage instructions
# $ playbookscaffold.sh -p . -t "first_playbook"
usage() { echo "Usage: $0 [-p <Playbook Path>] [-t <Playbook Title>]" 1>&2; exit 1; }
# Gather the users options
while getopts ":p:t:" OPTION; do
case "${OPTION}" in
p)
PROJECT_PATH=${OPTARG}
@willis7
willis7 / AccountControllerTest.groovy
Created November 12, 2015 17:37 — forked from jeffsheets/AccountControllerTest.groovy
Spock test with Mocks of Spring MVC Rest Controller using standaloneSetup and mockMvc
import groovy.json.JsonSlurper
import org.springframework.test.web.servlet.MockMvc
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.http.HttpStatus.*
import spock.lang.Specification
/**
* A Spock Spring MVC Rest unit test that doesn't require a full spring context
*/
@willis7
willis7 / README.md
Created October 1, 2015 14:05 — forked from zenorocha/README.md
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage