Skip to content

Instantly share code, notes, and snippets.

View dayglojesus's full-sized avatar
:shipit:

Brian Warsing dayglojesus

:shipit:
View GitHub Profile
@milesbxf
milesbxf / monzo-alertmanager-config.yaml
Last active May 15, 2024 19:37
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##
@pmbuko
pmbuko / primary_user.rb
Created August 8, 2014 16:16
Custom facter fact to report the primary user, determined by greatest total login time. The paths are for linux. Adjust as necessary.
# primary_user.rb
Facter.add("primary_user") do
setcode do
%x{if [ -f /usr/bin/ac ]; then /usr/bin/ac -p | /bin/sort -nk 2 | /bin/awk '/total/{print x};{x=$1}';fi}.chomp
end
end
@timsutton
timsutton / auto-update-mas-apps.sh
Last active March 7, 2018 06:54
Clear storeagent cache and trigger Mac App Store app updates.
#!/bin/sh
#
# Trigger an update of MAS (and softwareupdate) apps
#
# This seems to be all that's needed to schedule an immediate update of
# MAS apps. This should be run as a normal user. You can run this and
# tail the install log to get an idea of what's happening.
#
# You can also take a look at this user's ~/Library/Caches/com.apple.storagent
# directory to get a report on what apps were available, installable, etc.
@NigelThorne
NigelThorne / hash_inverse.rb
Last active October 25, 2017 05:43
ruby hash invert
require './hash_inverse'
describe Hash do
describe "when empty and asked for the inverse" do
it "returns an empty hash" do
{}.inverse.must_equal Hash.new
end
end
describe "when mapping are unique and asked for the inverse" do
@glarizza
glarizza / gist:1561644
Created January 4, 2012 19:34
Setting Password
This method gets an already-prepared password string fed as the variable 'password_hash'
@@users_plist_dir = '/var/db/dslocal/nodes/Default/users'
if File.exists?("#{@@users_plist_dir}/#{resource_name}.plist")
# If a plist already exists in /var/db/dslocal/nodes/Default/users, then
# we will need to extract the binary plist from the 'ShadowHashData'
# key, log the new password into the resultant plist's 'SALTED-SHA512'
# key, and then save the entire structure back.
users_plist = Plist::parse_xml(`plutil -convert xml1 -o /dev/stdout #{@@users_plist_dir}/#{resource_name}.plist`)
@glarizza
glarizza / gist:1445481
Created December 8, 2011 00:24
OS X Lion Password Hash Instructions

Password Hash Accessing:

  • Grab plist file from /var/db/dslocal/nodes/Default/users/username.plist

  • Convert to xml

      plutil -convert xml1 username.plist
    
  • Grab the ShadowHashData key and base64 decode it (install base64 with port install base64)

      echo "Data from ShadowHashData Key" | base64 -d > ShadowHashData
    
  • Convert the resultant binary plist file into xml

@taavi223
taavi223 / .pythonrc.py
Last active April 19, 2024 13:37
.pythonrc.py
"""
This file is executed when the Python interactive shell is started if
$PYTHONSTARTUP is in your environment and points to this file. It's just
regular Python commands, so do what you will. Your ~/.inputrc file can greatly
complement this file.
Modified from sontek's dotfiles repo on github:
https://github.com/sontek/dotfiles
"""
@floere
floere / james_very_simple_example.rb
Created May 13, 2011 08:57
Simple example dialogue for James.
require 'rubygems'
require 'james'
# This is a very simple James example for MacRuby.
#
# James is a voice controlled butler:
# http://github.com/floere/james
#
# Run using:
# 1. gem install james
@mikedamage
mikedamage / user_location.rb
Created January 9, 2010 21:18 — forked from mattetti/user_location.rb
MacRuby CoreLocation
# This is how you can get a user's location using MacRuby and CoreLocation
framework 'CoreLocation'
def locationManager(manager, didUpdateToLocation: new_location, fromLocation: old_location)
puts "location: #{new_location.description}"
exit
end
loc = CLLocationManager.alloc.init
loc.delegate = self