Skip to content

Instantly share code, notes, and snippets.

View ryanmcgrath's full-sized avatar
💭
==bG9s

Ryan McGrath ryanmcgrath

💭
==bG9s
View GitHub Profile
use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
// Just placeholders.
type CronetPtr = i32;
type CronetError = Box<dyn std::error::Error>;
type CronetResponse = String;
use std::future::Future;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
// Just placeholders.
type CronetPtr = i32;
type Error = Box<dyn std::error::Error>;
type CronetResult = std::result::Result<(), Error>;
use std::collections::HashMap;
use std::sync::Mutex;
use lazy_static::lazy_static;
type GlobalMap = Mutex<HashMap<&'static str, &'static str>>;
lazy_static! {
static ref GLOBAL_DATA2: GlobalMap = Mutex::new(HashMap::new());
}
@ryanmcgrath
ryanmcgrath / install_smashenabler.sh
Created July 20, 2020 19:39
A script to automate installing SmashEnabler.kext, while also being a bit easier to debug what exactly happens on some systems.
#!/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
BEGIN MESSAGE.
VenBkaimvRMIPOo PTQMKFv9nlQPkrt Z8ZgVPVnJbnTBPT SmDTDHPHbr5Ayyv
ZxZsrGjpEkuCMy1 wiCFHpIaBxqTCKq 6Xr2MZHgg7Ci9mz qZCbwrVMkyYzc1R
4ejwW0WiGNZpvDu 1AcRFc8fl07FfcA 7I5l6Bd1ewiyYME KuMkAULCR5BtoWo
JPyyCzEDj40wXJy MsyBsT5lxmCqASL mD4gr0aLMzWSiL.
END MESSAGE.
# 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)
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)
}
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
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)
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 = {