Skip to content

Instantly share code, notes, and snippets.

View joewiz's full-sized avatar

Joe Wicentowski joewiz

  • Arlington, Virginia
View GitHub Profile
@drdrang
drdrang / smarten.js
Created November 18, 2010 14:51
A very simple quote and dash smartener in JS. Used to make my tweets look nicer.
// Change straight quotes to curly and double hyphens to em-dashes.
function smarten(a) {
a = a.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018"); // opening singles
a = a.replace(/'/g, "\u2019"); // closing singles & apostrophes
a = a.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c"); // opening doubles
a = a.replace(/"/g, "\u201d"); // closing doubles
a = a.replace(/--/g, "\u2014"); // em-dashes
return a
};
@textarcana
textarcana / git-log2json.sh
Last active March 1, 2024 05:26
Convert Git logs to JSON. The first script (git-log2json.sh) is all you need, the other two files contain only optional bonus features 😀THIS GIST NOW HAS A FULL GIT REPO: https://github.com/context-driven-testing-toolkit/git-log2json
#!/usr/bin/env bash
# Use this one-liner to produce a JSON literal from the Git log:
git log \
--pretty=format:'{%n "commit": "%H",%n "author": "%aN <%aE>",%n "date": "%ad",%n "message": "%f"%n},' \
$@ | \
perl -pe 'BEGIN{print "["}; END{print "]\n"}' | \
perl -pe 's/},]/}]/'
@derickson
derickson / map.xqy
Created January 10, 2012 05:47
XQuery Choropleth complete
xquery version "1.0-ml";
import module namespace search="http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
declare namespace kml = "http://www.opengis.net/kml/2.2";
(:White to red color scale in BBGGRR format :)
declare variable $COLOR_SCALE :=
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@wolfgangmm
wolfgangmm / gist:5871157
Created June 26, 2013 20:09
Change group on all resources/collections in eXist-db root collection.
xquery version "3.0";
import module namespace dbutil="http://exist-db.org/xquery/dbutil" at "/db/apps/shared-resources/content/dbutils.xql";
let $root := "/db"
return
dbutil:scan(xs:anyURI($root), function($collection, $resource) {
if ($resource) then
sm:chgrp($resource, "biblio.users")
else
@CliffordAnderson
CliffordAnderson / luhn-3.1.xqy
Last active December 3, 2016 22:08
An attempt at the Luhn algorithm in XQuery
(: Signature of the fold function changed :)
xquery version "3.1";
(: Implements the Luhn Algorithm (http://en.wikipedia.org/wiki/Luhn_algorithm) in XQuery :)
declare function local:check-luhn($num as xs:integer) as xs:boolean
{
let $seq := fn:reverse(local:number-to-seq(($num)))
let $even-seq := $seq[position() mod 2 = 0]
@wolfgangmm
wolfgangmm / gist:5880377
Last active July 16, 2020 12:59
eXist-db: reinstall dashboard and shared-resources if broken. Run the following query through eXide - or if this fails: the Java admin client.
repo:remove("http://exist-db.org/apps/shared"),
repo:remove("http://exist-db.org/apps/dashboard"),
repo:install-and-deploy("http://exist-db.org/apps/shared", "http://exist-db.org/exist/apps/public-repo/find"),
repo:install-and-deploy("http://exist-db.org/apps/dashboard", "http://exist-db.org/exist/apps/public-repo/find")
@grantmacken
grantmacken / gist:6528369
Created September 11, 2013 19:12
My ant build target for building and uploading xar from project folder.
<target name="xar-build-upload" >
<buildnumber file="build.version"/>
<property name="project.version" value="${version.major}.${build.number}"/>
<property name="xar-location" value="${dir.project}/${dir.build}/${project.abbrev}-${project.version}.xar"/>
<property name="repo.url" value="http://${host.local}:8080/exist/apps/public-repo/public/"/>
<property name="repo.update" value="http://${host.local}:8080/exist/apps/public-repo/modules/update.xql"/>
<property name="xar-file" value="${project.abbrev}-${project.version}.xar"/>
<echo>project.version: ${project.version}</echo>
<antcall target="deployment-folder"/>
@lisamelton
lisamelton / transcode-video.sh
Last active September 8, 2023 23:51
Transcode video file (works best with Blu-ray or DVD rip) into MP4 (or optionally Matroska) format, with configuration and at bitrate similar to popular online downloads.
#!/bin/bash
#
# transcode-video.sh
#
# Copyright (c) 2013-2015 Don Melton
#
about() {
cat <<EOF
$program 5.13 of April 8, 2015
# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
$ cabextract PowerPointViewer.exe
$ cabextract ppviewer.cab