Skip to content

Instantly share code, notes, and snippets.

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

Ryan McGrath ryanmcgrath

💭
==bG9s
View GitHub Profile
@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}
},

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 / example.js
Last active January 23, 2021 09:42
A basic React Video tag. I wanted to use video.js inside something I was building, so this is more or less a 5-minute tag for handling it. ES6 syntax but you can extrapolate what you need. Handles dynamically loading video.js/css as necessary since I really loathe serving any swf/etc myself. Could be easily extended or made better, works for me …
import React from 'react';
import Video from './Video';
class MyGenericApp extends React.Component {
render() {
return <div>
<Video src="my_video_url" poster="my_poster_url" />
</div>;
}
}
@ryanmcgrath
ryanmcgrath / SVG.js
Last active August 29, 2015 14:24
An incredibly basic module that handles injecting SVG sprites into the document, and then displaying it in a simple <SVG> component tag. Allows for easy PNG fallback for older/unsupported browsers.
import React from 'react';
import icons from './icons';
// This will inject our packaged SVG into the document, if it belongs there
const supportsSVGNatively = (
!!document.createElementNS &&
!!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect
);
if(supportsSVGNatively) {
@ryanmcgrath
ryanmcgrath / vex-without-jquery.js
Last active November 4, 2015 10:26
A version of Vex (https://github.com/HubSpot/vex/) that doesn't require jQuery. The project seems somewhat unmaintained at this point but I've neither the time nor the energy to fork it myself, but did wind up ripping jQuery out of this and figured it's at least worth sharing as a gist. Most of the core API is intact (though I had no use for the…
;(function() {
/**
* This is in no way a proper shim, but it'll work fine here.
*/
var filter = function(data, fn) {
var results = [], val, l = data.length, i = 0;
for(; i < l; i++) {
val = data[i];
if(fn.call(val, i)) results.push(val);
}
@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];
@ryanmcgrath
ryanmcgrath / calculator.js
Created November 22, 2012 22:26
Teaching some JS
<script type="text/javascript">
/**
* Variables we'll need. The mode (adding, subtracting, etc),
* the two numbers, and a pointer to the number we're setting up
* at any point in time.
*/
var mode = '';
var number1;
var number2;
var currentNumber = number1;
@ryanmcgrath
ryanmcgrath / scrape_cl.py
Created November 11, 2012 23:56
Scrapes area names from CL. They seem to be on the ball with that stuff.
from django.core.management import setup_environ
from django.contrib.localflavor.us.us_states import STATE_CHOICES
from pyquery import PyQuery as pq
import settings, time
setup_environ(settings)
from myproject.writers.models import Location
@ryanmcgrath
ryanmcgrath / quora_api_skimmer_lulz.py
Created April 9, 2012 04:53
Because Quora doesn't have a damn API.
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import urllib2 # Quora no like requests requests. ;_;
from pyquery import PyQuery as pq
from pprint import pprint
class Puora(object):
def __init__(self, username):
self.answers_url = 'http://www.quora.com/%s/answers' % username