Skip to content

Instantly share code, notes, and snippets.

@jlafitte
jlafitte / sshauth.sh
Created August 25, 2014 03:33
Automate uploading your public ssh key to a remote system authorized keys
#!/bin/bash
echo "-- Adds your id_rsa.pub to a remote system authorized keys --"
echo "Usage: $0 <user>@<host>"
if [ -z "$1" ]; then
echo -n "User: "
read user
echo -n "Host: "
@jlafitte
jlafitte / string-replace-all.xsl
Created July 13, 2012 23:57
A replace-all XSL template. Very useful if you are stuck in XSLT 1.0 world, but made obsolete in XSLT 2.0+
<xsl:template name="string-replace-all">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="by"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$by"/>
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
@jlafitte
jlafitte / sam-href-override-extended.xsl
Last active December 16, 2015 02:39
SAM href-override extended functionality. When there is a manual override specified, in SAM Admin it will show a message to the user so they know the page will not be seen. In stage and publish it will create script and fallback meta tag to redirect the page. Technically meta tags are meant to be in the head block, my testing seems to indicate i…
<xsl:variable name="href-override" select="/SAM/navigation/link[@id = /SAM/page/@id]/href-override" />
<xsl:if test="$href-override">
<xsl:choose>
<xsl:when test="@directive = 'admin'">
<p class="error" style="text-align:center">
This page is redirecting to <a href="{$href-override}" target="_blank"><xsl:value-of select="$href-override"/></a>.<br />
You may change this in Architecture &gt; Edit Page Info &gt; Edit Advanced &gt; Manual URL Override.
</p>
</xsl:when>
<xsl:otherwise>
@jlafitte
jlafitte / api.js
Last active December 16, 2015 02:58
My spas-simple modification to support passing through a header object.
var request = require("request"),
_ = require("underscore")._;
/*
# Simple API Request
*/
exports["request"] = function(params, credentials, cb) {
var reqString = params.url,
@jlafitte
jlafitte / xslt.clips
Created August 5, 2013 16:13
XSLT Clips for Coda 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>$archiver</key>
<string>NSKeyedArchiver</string>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
@jlafitte
jlafitte / disk-space.asp
Created June 8, 2016 23:11
Get disk space in ASP
<%
function getGB(bytes)
getGB = Fix(bytes / 1073741824)
end function
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive("C:")
response.write getGB(d.FreeSpace) & "GB free of " & getGB(d.TotalSize) & " GB"
%>
@jlafitte
jlafitte / cleanmgr.bat
Last active March 29, 2018 18:26
Windows Server 2008 Clean Manager Enabler
@echo off
echo Installing Disk Cleanup if not already installed.
if not exist %SYSTEMROOT%\System32\cleanmgr.exe (
copy /Y C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe %SYSTEMROOT%\System32\
)
if not exist %SYSTEMROOT%\System32\en-US\cleanmgr.exe.mui (
copy /Y C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui %SYSTEMROOT%\System32\en-US\
)
@jlafitte
jlafitte / me.screenshot.plist
Last active June 19, 2018 21:20
OS X Screenshot Script
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>me.screenshot</string>
<key>ProgramArguments</key>
<array>
<string>/Users/john/scripts/screenshot.sh</string>
</array>
@jlafitte
jlafitte / onion-skin.js
Last active December 6, 2018 01:59 — forked from dtex/gist:4337176
Onion skinning plugin for jQuery
(function( $ ){
var methods = {
init : function( options ) {
return this.each(function(){
oSkin = $('<div class="onionSkin" style="width:100%;text-align:center;position:absolute;opacity:.5;display:none;" />');
oImg = $('<img src="'+options.src+'" />');
oImg.css(options.imgStyles);
@jlafitte
jlafitte / url-encode.xsl
Created December 9, 2018 15:53
XSLT URL Encoding
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
<!-- ISO-8859-1 based URL-encoding demo
Written by Mike J. Brown, mike@skew.org.
Updated 2015-10-24 (to update the license).
License: CC0 <https://creativecommons.org/publicdomain/zero/1.0/deed.en>