Skip to content

Instantly share code, notes, and snippets.

View chriscorwin's full-sized avatar

Chris Corwin chriscorwin

View GitHub Profile
#!/bin/bash
touch '/Users/ccorwin/Google Drive/Documents/pasteboard.html'
pbpaste > '/Users/ccorwin/Google Drive/Documents/pasteboard.html'
highlight -O rtf -t 2 -K 11 -k 'Source Code Pro' --syntax 'html' '/Users/ccorwin/Google Drive/Documents/pasteboard.html' | pbcopy
javascript: (function() {
var headElement = document.getElementsByTagName('head')[0];
var bodyElement = document.getElementsByTagName('body')[0];
var bootstrapStylesheetLink = document.createElement('link');
bootstrapStylesheetLink.rel = 'stylesheet';
bootstrapStylesheetLink.href = "file:/Users/ccorwin/floobits/share/chriscorwin/RPD/css/bootstrap.css";
headElement.appendChild(bootstrapStylesheetLink, headElement);
#!/usr/bin/sh
#Adapted by Ben Schmidt from Barry Hubbard's code at
#http://www.barryhubbard.com/articles/37-general/74-converting-a-pdf-to-text-in-linux
#to convert into a folder of text files, each one representing a page.
#This takes pdfs from the pdfs folder, writes tif files to the images folder, and writes text to the texts folder.
#each pdf gets a _folder_ in each of the other two.
mkdir -p texts
mkdir -p images
function CleanWordHTML(str) {
/*
Function to strip Microsoft Word HTML formatting
As developers, we've all been there you give someone an HTML-enabled editor yet they STILL paste in content from Word, thereby ruining all your dedicated efforts at styling and making text look consistent and pretty (damn you and your Comic Sans, Bill!).
So, bearing this in mind, we put together a wee script which removes all the standard formatting of the mso:xml/html and other formatting which Microsoft Word stuffs in to retain the formatted document. Don't get me wrong, Word is very good at what it was designed for writing word documents not creating web pages!
The function explained: basically in the function below, we pass the main body of the text or passage into the js function (note that we are running this on the server to get the database elements parsed prior to passing it to the client) then, in a linear fashion systematically to do a series of "replaces". The nature of the replacing of some lines has experienc
/**
* Turns someCrazyName into Some Crazy Name
* Decent job of acroynyms:
* ABCAcryonym => ABC Acryoynm
* xmlHTTPRequest => Xml HTTP Request
*/
String.prototype.unCamelCase = function(){
return this
// insert a space between lower & upper
.replace(/([a-z])([A-Z])/g, '$1 $2')
//use the myApp object if it already exists, else start a new object
window.myApp = window.myApp || {};
/** @namespace */
myApp.globalTimer = myApp.globalTimer || {};
/** @constant */
myApp.globalTimer.THRESHOLD = 10000;
/** @todo what is this? */
myApp.globalTimer.lastTick_;
/** @todo what is this? */
[
define_atbegin: {
local('requesttype') = (request_isajax ? 'AJAX' | 'Not Ajax');
var('the_file_exists'=true);
log_critical('URL_Handler (' + #requesttype + ' : ' + response_filepath + ') AtBegin starting...');
if(string(response_filepath) == '/');
/**
* Executes a function by name.
*/
var executeFunctionByName = function executeFunctionByName(functionName, context /*, args */ ) {
var args = Array.prototype.slice.call(arguments, 2);
var namespaces = functionName.split(".");
var func = namespaces.pop();
for (var i = 0; i < namespaces.length; i++) {
context = context[namespaces[i]];
}
#noshebang;source-this
##
# This is a simple script to figure out what sort of system the user is running. These
# exported environmental variables can then be used for system-agnostic scripts. This
# script MUST be sourced in order to have access to the variables afterwards.
##
# get uname info
export _ENV_UNAME=$(uname -s)