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 / JapaneseRegex.js
Created May 20, 2011 02:32 — forked from sym3tri/JapaneseRegex.js
Regex to test for presence of Japanese characters
// REFERENCE UNICODE TABLES:
// http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml
// http://www.tamasoft.co.jp/en/general-info/unicode.html
//
// TEST EDITOR:
// http://www.gethifi.com/tools/regex
//
// UNICODE RANGE : DESCRIPTION
//
// 3000-303F : punctuation
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 / load_proper.js
Created January 5, 2011 22:16
How to properly branch loading of JS
/* Since script loading is dynamic, we take
a callback function with our loadScript call
that executes once the script is done downloading/parsing
on the page.
*/
var loadScript = function(src, callbackfn) {
var newScript = document.createElement("script");
newScript.type = "text/javascript";
newScript.setAttribute("async", "true");
newScript.setAttribute("src", src);
@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 / 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 / twitter_streaming.js
Created February 18, 2011 08:02
Access the Twitter Streaming API with ease (Node.js).
var util = require('util'),
http = require('http'),
events = require('events');
var Twitter = function(opts) {
this.username = opts.username;
this.password = opts.password;
this.track = opts.track;
this.data = '';
};
@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.