Skip to content

Instantly share code, notes, and snippets.

View rcherny's full-sized avatar

Rob Cherny rcherny

View GitHub Profile
@rcherny
rcherny / get_non_window_globals.js
Created August 31, 2018 17:12
Get Non-Window Scope Globals
delete keysfromscript;
delete wholeset;
try {
var keysfromscript = [];
} catch(e) {
keysfromscript = [];
}
try {
@rcherny
rcherny / parse_resource_size.js
Created August 31, 2018 17:11
Parse Resource Timing Size
// Unsure where this came from.
// If this code is yours, please let me know!
function display_size_data(){
// Check for support of the PerformanceResourceTiming.*size properties and print their values
// if supported.
if (performance === undefined) {
console.warn("Display Size Data: performance NOT supported");
return;
}
@rcherny
rcherny / parse_resource_timing.js
Created August 31, 2018 17:10
Parse Resource Timing Load Times
// Unsure where this code came from.
// Please get in touch if it is yours!
function calculate_load_times() {
// Check performance support
if (performance === undefined) {
console.log("= Calculate Load Times: performance NOT supported");
return;
}
@rcherny
rcherny / gist:15063948c95f535fbc75abf8925527b2
Created September 13, 2017 18:48 — forked from hiddentao/gist:5946053
Generate overridable getters and setters in Javascript
// see blog post: http://www.hiddentao.com/archives/2013/07/08/generate-overridable-getters-and-setters-in-javascript/
Function.prototype.generateProperty = function(name, options) {
// internal member variable name
var privateName = '__' + name;
options = options || {};
options.get = ('undefined' === typeof options.get ? true : options.get );
options.set = ('undefined' === typeof options.set ? true : options.set );
// pre-initialise the internal variable?
@rcherny
rcherny / dnsmasq OS X.md
Last active May 29, 2020 19:27 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

much, much newer and better ?

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.

Requirements

import sublime
import sublime_plugin
class CursorCommand(sublime_plugin.TextCommand):
saved_cursors_map = {}
def run(self, edit, action="add"):
view = self.view
cursors = view.sel()
view_id = view.id()
@rcherny
rcherny / FileTransfer.py
Created November 21, 2016 02:10 — forked from omz/FileTransfer.py
File Transfer script for Pythonista (iOS)
# File Transfer for Pythonista
# ============================
# This script allows you to transfer Python files from
# and to Pythonista via local Wifi.
# It starts a basic HTTP server that you can access
# as a web page from your browser.
# When you upload a file that already exists, it is
# renamed automatically.
# From Pythonista's settings, you can add this script
# to the actions menu of the editor for quick access.
@rcherny
rcherny / Evernote Demo.py
Created November 21, 2016 02:08 — forked from omz/Evernote Demo.py
Evernote Demo
# A simple Evernote API demo script that lists all notebooks in the user's
# account and creates a simple test note in the default notebook.
#
# Before running this sample, you must fill in your Evernote developer token!
#
# This sample is part of the Evernote SDK and has been modified slightly for
# Pythonista, to take advantage of the clipboard and PIL modules.
# If there is an image in the clipboard when the script is run, it is attached
# to the sample note.
@rcherny
rcherny / Evernote Installer.py
Created November 21, 2016 02:08 — forked from omz/Evernote Installer.py
Evernote Installer
# Simple installer script for using the Evernote SDK in Pythonista
#
# This script should be run from the root directory. In order to keep things
# tidy, it installs the module and all its dependencies in a directory named
# 'evernote-sdk'. In order to be able to import it, you have to add that to
# your import path, like this:
#
# import sys
# sys.path.append('evernote-sdk')
#
@rcherny
rcherny / PythonistaBackup.py
Created November 21, 2016 02:07 — forked from omz/PythonistaBackup.py
PythonistaBackup.py
# coding: utf-8
'''Creates a zip archive of your Pythonista files and serves them via HTTP in your local network.'''
import sys
if sys.version_info[0] >= 3:
from http.server import SimpleHTTPRequestHandler, HTTPServer
else:
from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer