Skip to content

Instantly share code, notes, and snippets.

View zakgrant's full-sized avatar
🎯
Focusing

Zak Grant zakgrant

🎯
Focusing
View GitHub Profile
@cobyism
cobyism / osx-install-media.md
Last active March 11, 2023 00:42
Command to create installable OS X USB drive.

Creating a bootable macOS USB installer

  • First, plug in an 8GB (or bigger) USB drive, and use Disk Utility to erase it
  • If you use the default settings, you should wind up with a blank drive at /Volumes/Untitled.

With that volume in place, and with the macOS installer sitting in /Applications/Install\ macOS\ [VERSION].app, run the following command in your terminal to create a bootable install media (for Sierra):

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction
@kaloprominat
kaloprominat / macos: manage add list remove login items apple script
Last active April 11, 2024 23:22
macos: manage add list remove login items apple script
# applescript
# add login item
osascript -e 'tell application "System Events" to make login item at end with properties {name: "Notes",path:"/Applications/Notes.app", hidden:false}'
# delete login item
osascript -e 'tell application "System Events" to delete login item "itemname"'
# list loginitems
osascript -e 'tell application "System Events" to get the name of every login item'
@lillesand
lillesand / CsrfProtectionFilter.java
Last active December 19, 2015 07:19
Jersey sin Csrf protection
/**
*
* Også kan jeg kommentere her.
*
* Simple server-side request filter that implements CSRF protection as per the
* <a href="http://www.nsa.gov/ia/_files/support/guidelines_implementation_rest.pdf">Guidelines for Implementation of REST</a>
* by NSA (section IV.F) and
* section 4.3 of <a href="http://seclab.stanford.edu/websec/csrf/csrf.pdf">this paper</a>.
* If you add it to the request filters of your application, it will check for X-Requested-By header in each
* request except for those that don't change state (GET, OPTIONS, HEAD). If the header is not found,
@indec
indec / switch_audio.applescript
Last active December 17, 2015 21:09
An Applescript to cycle the audio input and output sources between two (or more) audio devices
on alfred_script(q)
set output_devices to {"Display Audio", "Generic USB Audio Device "}
set input_devices to {"Display Audio", "Generic USB Audio Device "}
set device_keywords to {"speakers", "headphones"}
tell application "System Preferences"
reveal anchor "output" of pane id "com.apple.preference.sound"
tell application "System Events"
tell process "System Preferences"
@sstephenson
sstephenson / super.bash
Last active January 30, 2017 01:40
`super` in Bash
#!/usr/bin/env bash
source super.bash
foo() {
echo hello
}
super_function foo
foo() {
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSWorkspace</key>
<key>SystemConfiguration</key>
<dict>
<key>State:/Network/Global/IPv4</key>
<dict>
<key>command</key>
@NickLaMuro
NickLaMuro / check_and_change_dns
Last active June 28, 2018 10:56
Dealing with Dynamic IP's with a home server and DNSimple
#!/bin/bash
EMAIL="your_email@example.com"
API_TOKEN="API_TOKEN"
DOMAIN_ID="your_domain.com"
RECORDS=(123456 234567 345678) # Replace with the Record ID
IP="`curl -s -S http://v4.ident.me`"
STORED_IP_ADDRESS_FILENAME="$HOME/.current_external_ip_address"
# Loop through each record id in the array
@brundage
brundage / database.yml
Created November 16, 2012 22:05
Use sqlite in-memory database for rspec testing
test:
adapter: sqlite3
encoding: utf8
pool: 5
timeout: 5000
database: ":memory:"
verbosity: quiet
@rodrigo-galba
rodrigo-galba / gist:4058942
Created November 12, 2012 11:52
Rest assured with cucumber step definitions
public class TransformationStepdefs {
private RequestSpecification spec = RestAssured.with();
@Given("^I have a single \"([^\"]*)\" file$")
public void I_have_a_single_file(String format) throws Throwable {
spec.given().
multiPart("requestData", objectAsJson()).
header("Version", 1);
}
@hamstarr
hamstarr / tunnel.sh
Created October 17, 2012 12:31
tunnel.sh
#!/bin/sh
# tunnel.sh
# Configure
LOCAL_HOST=127.0.0.1;
USERNAME="your_username";
# set your remote address and SSH port.
TUNNEL_PORT="2022"
REMOTE_HOST="my.homedomainorip.com -p $TUNNEL_PORT";