Skip to content

Instantly share code, notes, and snippets.

@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 / .bash_profile
Last active August 9, 2022 16:43
MacOS Clean Install Procedures
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:~/scripts
export CLICOLOR=1
export LSCOLORS=hxFxBxDxCxegedabagacad
alias dir="ls -lahG"
alias ll="ls -lahG"
alias qws="python -m SimpleHTTPServer"
alias rscp='rsync -aP'
alias rsmv='rsync -aP --remove-source-files'
@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 / 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 / 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 / .eslintrc
Last active June 24, 2021 05:48
Idiomatic ESLint
//Put this in your home directory... Unless you need project specific settings
{
"extends": "idiomatic",
"rules": {
"quotes": ["warn","double"],
"space-in-parens": ["warn","never"],
"array-bracket-spacing": ["warn","never"],
"computed-property-spacing": ["warn","never"],
"one-var-declaration-per-line": ["warn","initializations"],
"semi": ["error","always",{
@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\
)