Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
==bG9s

Ryan McGrath ryanmcgrath

💭
==bG9s
View GitHub Profile
@ryanmcgrath
ryanmcgrath / install_smashenabler.sh
Created Jul 20, 2020
A script to automate installing SmashEnabler.kext, while also being a bit easier to debug what exactly happens on some systems.
View install_smashenabler.sh
#!/bin/sh
# shellcheck shell=dash
# This is just a little script that can be downloaded from the internet to
# install SmashEnabler.
#
# It runs on Unix shells like {a,ba,da,k,z}sh. It uses the common `local`
# extension. Note: Most shells limit `local` to 1 var per line, contra bash.
#
# Borrow heavily and liberally from rustup's install script. ;P
View msg.txt
BEGIN MESSAGE.
VenBkaimvRMIPOo PTQMKFv9nlQPkrt Z8ZgVPVnJbnTBPT SmDTDHPHbr5Ayyv
ZxZsrGjpEkuCMy1 wiCFHpIaBxqTCKq 6Xr2MZHgg7Ci9mz qZCbwrVMkyYzc1R
4ejwW0WiGNZpvDu 1AcRFc8fl07FfcA 7I5l6Bd1ewiyYME KuMkAULCR5BtoWo
JPyyCzEDj40wXJy MsyBsT5lxmCqASL mD4gr0aLMzWSiL.
END MESSAGE.
View update_twitter_avatar.py
# pip install twython to get this library
from twython import Twython
# Create a new App at https://dev.twitter.com/, check off "sign in via Twitter", and get your tokens there
twitter = Twython('Consumer API Key', 'Consumer API Secret', 'Access Token', 'Access Token Secret')
# Read and upload the image, see image guidelines in post above~
image = open('path/to/image.png', 'rb')
twitter.update_profile_image(image=image)
View nscollectionviewitem-touchesended.swift
override func touchesEnded(with event: NSEvent) {
if(self.isTracking) {
self.endTracking(leftAnchor?.constant ?? 0)
}
}
override func touchesCancelled(with event: NSEvent) {
if(self.isTracking) {
self.endTracking(leftAnchor?.constant ?? 0)
}
View nscollectionviewitem-touchesmoved.swift
override func touchesMoved(with event: NSEvent) {
if(!isTracking) { return }
let currentTouches = event.touches(matching: .touching, in: view)
if(currentTouches.count != 2) { return }
currentTouchOne = nil
currentTouchTwo = nil
currentTouches.forEach { (touch: NSTouch) in
View nscollectionviewitem-touchesbegan.swift
override func touchesBegan(with event: NSEvent) {
if(isTracking) { return }
let initialTouches = event.touches(matching: .touching, in: view)
if(initialTouches.count != 2) { return }
isTracking = true
initialPoint = view.convert(event.locationInWindow, from: nil)
let touches = Array(initialTouches)
View nscollectionviewitem-setup.swift
class HolidayCalendarCollectionViewItem: NSCollectionViewItem {
var leftAnchor: NSLayoutConstraint?
var initialTouchOne: NSTouch?
var initialTouchTwo: NSTouch?
var currentTouchOne: NSTouch?
var currentTouchTwo: NSTouch?
var initialPoint: CGPoint?
var isTracking = false
public lazy var contentView: NSView = {
@ryanmcgrath
ryanmcgrath / default.json
Created Jun 29, 2018
Experiments in GUIs in Rust.
View default.json
{
"window": {
"backgroundColor": {"r": 35, "g": 108, "b": 218},
"defaultWidth": 800,
"defaultHeight": 600
},
"root": {
"backgroundColor": {"r": 35, "g": 108, "b": 218}
},
View keybase.md

Keybase proof

I hereby claim:

  • I am ryanmcgrath on github.
  • I am ryanmcgrath (https://keybase.io/ryanmcgrath) on keybase.
  • I have a public key ASBoiGzjRfuni2cjo3ZESQ0S9NqFGkb9ork8wK-_fciOJgo

To claim this, I am signing this object:

@ryanmcgrath
ryanmcgrath / uwsgidecorators.py
Created Apr 9, 2016
Getting around uwsgidecorators import failure issues when using uwsgi spooler functionality.
View uwsgidecorators.py
try:
# This module is only available when running under uwsgi
# in production. We try to import it, but if it fails we're
# running in development and should just pass a decorator that'll
# run it back immediately.
from uwsgidecorators import spool
except:
def spool(fn):
def _spool(**kwargs):
return fn(kwargs)
You can’t perform that action at this time.