Skip to content

Instantly share code, notes, and snippets.

View morgant's full-sized avatar

Morgan Aldridge morgant

View GitHub Profile
@dpk
dpk / realpath.c
Created February 22, 2012 13:44
Command-line interface to realpath(3)
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
int main (int argc, char *argv[]) {
char* instr;
char outstr[PATH_MAX];
instr = argv[1];
@splorp
splorp / wanted.md
Last active October 25, 2021 20:34
Wanted: Magazines, Publications, Discs & Sundries

Wanted

This is a list of magazines, publications, discs, and other sundry articles that I am interested in obtaining, in order to complete parts of my compunabula collection.

See also: Floppies

If you happen to have any of these items kicking around, please contact me.

grant [a] splorp [dot] com

@pmarreck
pmarreck / fake_time_machine.sh
Created September 23, 2011 16:29
Fake Time Machine, a way to duplicate the functionality of Apple's Time Machine using rsync, which also might make it cross-platform, but also lets you run it to any remote server
#!/usr/bin/env sh
# fake_time_machine.sh
# Fake Time Machine
# by Peter Marreck
# Based on ideas in http://blog.interlinked.org/tutorials/rsync_time_machine.html
# 9/2011
# E_BADARGS=85
# if [ -z "$1" ]
@kangax
kangax / gist:1051534
Created June 28, 2011 16:28 — forked from maxim/progressify.rb
Progressify - a progress bar approximator for smoothness
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Progressify</title>
<script>
var Plot = (function() {
function Point(duration, progress) {
this.duration = duration;
@samuelcole
samuelcole / ultimate_url_re.js
Created April 14, 2011 19:44
Ultimate Url Regex!
/*
Based off of Gruber's awesome url regex: http://daringfireball.net/2010/07/improved_regex_for_matching_urls
In addition:
- Should match 'example.com', 'google.net', 'google.org'. (only com, net, and org are whitelisted).
- Should not match 'sam@samuelcole.name'.
*/
var URL_RE = /(?:(?=[\s`!()\[\]{};:'".,<>?«»“”‘’])|\b)((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/|[a-z0-9.\-]+[.](?:com|org|net))(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))*(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]|\b))/gi
@ekoeppen
ekoeppen / gist:854390
Created March 4, 2011 09:28
Newton Voyager Platform Driver Interface
#include <NewtonGestalt.h>
#include <NewtonScript.h>
#include <BufferList.h>
#include <BufferSegment.h>
class TGPIOInterface
{
public:
NewtonErr ReadGPIOData (UByte, ULong *);
};
@gruber
gruber / Reply.scpt
Last active October 22, 2020 19:48
Prompt with options to "Reply" or "Reply All" when replying to a message with multiple recipients in Apple Mail for Mac OS X. Also does away with top-posting.
tell application "Mail"
set _sel to get selection
if (count of _sel) > 1 then
-- multiple message selection, usually a conversation thread
choose from list {"Reply", "Reply All"} with prompt "Unknown recipient count." default items {"Reply"}
try
set _menu_command to item 1 of the result
on error
return
@splorp
splorp / gist:776730
Created January 12, 2011 19:36
Preferences to disable local storage in Safari
# To disable Safari’s annoying modal local database
# storage dialog, use this Terminal command:
defaults write com.apple.Safari WebKitDatabasesEnabledPreferenceKey -bool false
# To disable local storage altogether, use this command:
defaults write com.apple.Safari WebKitLocalStorageEnabledPreferenceKey -bool false
@kirkegaard
kirkegaard / dumpoverssh.sh
Created December 20, 2010 11:33
pipe a mysql dump through gzip and send it over ssh
mysqldump -u MYSQL_USERNAME -p YOUR_DATABASE | gzip -c | ssh USERNAME@YOUR_TO_HOST 'cat > ~/dump.sql.gz'
<?php
/**
* Looks for unquoted keys in a json string and fixes them ie: {a:"b"} => {"a":"b"}
* @param string $string A json string that is suspect
* @return string A valid json string
*/
function fix_json($string){
// (no qupte) (word) (no quote) (semicolon)
$regex = '/(?<!")([a-zA-Z0-9_]+)(?!")(?=:)/i';