Skip to content

Instantly share code, notes, and snippets.

View 128keaton's full-sized avatar

Keaton Burleson 128keaton

View GitHub Profile
#!/bin/bash
## INCORRECT
$(top -bn1 | grep load | awk '{printf"%.2f%%\t\t\n", $(NF-2)}')
@128keaton
128keaton / output.shell
Last active September 17, 2019 22:15
Prints HDD/Memory Usage (bash)
--------------------------------------------------|Usage|--------------------------------------------------
Memory Usage: [###############-------------------------] 38% (372M/962M, 194M available)
Disk Usage: [##########------------------------------] 26% (5G/19G, 13G available)
-----------------------------------------------------------------------------------------------------------
class CentralMenuButton: UIButton {
var label: UILabel?
var labelText: String!
var labelColor: UIColor!
var labelFont: UIFont!
var labelAlignment: NSTextAlignment!
override init(frame: CGRect) {
@128keaton
128keaton / flashScreen.swift
Created August 29, 2019 01:46 — forked from bgreenlee/flashScreen.swift
Flashing the screen in Swift. Sticking this here because it took me a while to work out the right variable types and casting.
func flashScreen() {
let inDuration: CGDisplayFadeInterval = 0.0
let outDuration: CGDisplayFadeInterval = 1.0
let color = NSColor.white
var fadeToken: CGDisplayFadeReservationToken = 0
let colorToUse = color.usingColorSpaceName(NSColorSpaceName.calibratedRGB)!
let err = CGAcquireDisplayFadeReservation(inDuration + outDuration, &fadeToken)
if err != CGError.success {
2019/04/12 14:08:06:389 macOS Utilities-v2.65-b2
2019/04/12 14:08:06:389
2019/04/12 14:08:06:389
---------------------------LOGGER INITIALIZED---------------------------
2019/04/12 14:08:06:389
2019/04/12 14:08:06:389 Library folder does not exist at '/Users/admin/Library/Application Support/ER2/'
2019/04/12 14:08:06:389 Creating folder at path '/Users/admin/Library/Application Support/ER2/'
2019/04/12 14:08:06:390 Library folder exists at '/Users/admin/Library/Application Support/ER2/'
2019/04/12 14:08:06:390 Property list does not exist at '/Users/admin/Library/Application Support/ER2/com.er2.applications.plist'
2019/04/12 14:08:06:390 Copying property list from bundle
@128keaton
128keaton / navigation.js
Last active September 21, 2018 20:29
Client-side javascript that fetches menus from a Wordpress instance for another website.
// -------------------------------------------------------------
// Add page items
// (uses Wordpress plugins JSONMenu)
// -------------------------------------------------------------
$.ajax({
url: 'http://wp.dev.reviveit.io/?rest_route=/menus/v1/list',
dataType: 'application/json',
cache: 'true',
complete: function (data) {
console.log('Ajax request success');
@128keaton
128keaton / archiver.rb
Last active September 6, 2018 00:42
Creates a Wayback machine entry for URL
require 'net/https'
require 'uri'
class WebArchiver
def self.archive(url)
url = URI.parse("https://web.archive.org/save/#{url}")
req = Net::HTTP::Get.new(url.to_s)
res = Net::HTTP.start(url.host, url.port, :use_ssl => true) {|http|
http.request(req)
@128keaton
128keaton / DestinationView.swift
Last active June 6, 2018 14:02
Dragging view in Swift 3
import Foundation
import Cocoa
class DestinationView: NSView {
var isHighlighed: Bool! = false
override func awakeFromNib() {
self.register(forDraggedTypes: [NSFilenamesPboardType])
}
func isHighlighted() -> Bool! {
require 'json'
require 'net/http'
require 'uri'
require 'logger'
logger = Logger.new(STDOUT)
#get machine serial number
serial = `sudo dmidecode -t 1 | grep Serial | sed 's/.*: //g'`.strip!
base_url = 'http://10.0.2.7:3001'
require 'json'
require 'net/http'
require 'uri'
require 'logger'
logger = Logger.new(STDOUT)
base_url = 'http://10.0.2.7:3001'
serial = `sudo dmidecode -t 1 | grep Serial | sed 's/.*: //g'`.strip!