Skip to content

Instantly share code, notes, and snippets.

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

Ryan McGrath ryanmcgrath

💭
==bG9s
View GitHub Profile
# 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 = {
@ryanmcgrath
ryanmcgrath / default.json
Created June 29, 2018 07:34
Experiments in GUIs in Rust.
{
"window": {
"backgroundColor": {"r": 35, "g": 108, "b": 218},
"defaultWidth": 800,
"defaultHeight": 600
},
"root": {
"backgroundColor": {"r": 35, "g": 108, "b": 218}
},
@ryanmcgrath
ryanmcgrath / stfu.js
Created January 5, 2011 21:02
Parameter-based debugging.
var stfu = function(msg) {
if(!/\#DEBUG/.test(window.location.href)) return false;
/* Opera has a totally different friggin' API, but
it's actually fairly useful for IE debugging as their
VMs have some layer of compatibility.
*/
if(window.opera) window.opera.postError(msg);
/* Now we try for the sweet sweet lovin'... */

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 April 9, 2016 10:55
Getting around uwsgidecorators import failure issues when using uwsgi spooler functionality.
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)
@ryanmcgrath
ryanmcgrath / gist:5628362
Last active December 17, 2015 14:59
Example for Rane.
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
UIViewController *rootViewController = [[MyUIViewControllerSubclass alloc] init];
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];