Skip to content

Instantly share code, notes, and snippets.

View BillyHilly's full-sized avatar

Billy Hill BillyHilly

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML Sitemap</title>
@alanwsmith
alanwsmith / output-commas-except-for-last-item.xslt
Created July 11, 2012 16:47
Putting commas after each value in a loop except for the last one. Useful for JSON and the like
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--
Example of putting commas after everything but the last item in a list.
This will process the XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
@bzerangue
bzerangue / transform-html5.php
Created August 29, 2012 20:41
PHP: XSLT Transformation to build HTML5 html output (use xhtml 1.0 strict as your settings in your XSLT stylesheet)
<?php
// Load the XML source
$xml = new DOMDocument;
$xml->load('XML_SOURCE_LINK_HERE');
// Load XSLT stylesheet
$xsl = new DOMDocument;
$xsl->load('XSL_STYLESHEET_PAGE_LINK_HERE');
@ericrallen
ericrallen / relative-date.php
Created January 22, 2013 22:47
Create an estimated relative date for any past date string via PHP.
<?php
/*--------------------------------------------------------------------------
This function accepts any date string that str_to_time() can handle
and returns a relative date string
It can account for seconds, minutes, days, weeks, months, years,
decades, centuries, and millenia
@ksafranski
ksafranski / SimpleStore.js
Last active July 2, 2022 15:25
Simple localStorage function with Cookie fallback for older browsers.
/**
* Simple localStorage with Cookie Fallback
* v.1.0.0
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store('my_key', 'some_value');
*
* Retrieve:
html{
background-image: linear-gradient(#0ff 1px, transparent 1px);
background-size: auto 1.5em;
}
@ijy
ijy / check-null-empty.xsl
Created September 15, 2013 17:14
XSLT: Check if a string is null or empty.
<!--
CHECK IF A STRING IS NULL OR EMPTY
-->
<!-- Example XML -->
<group>
<item>
<id>item 1</id>
<CategoryName>blue</CategoryName>
</item>
@JeffreyWay
JeffreyWay / .vimrc
Last active January 22, 2024 11:42
My .vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
@jrsouth
jrsouth / up-down-monitor.php
Created October 24, 2013 12:55
Monitor Scripts
<?php
$search = 'Patient information'; // String to search for in the raw HTML
$url = 'http://leukaemialymphomaresearch.org.uk';
$repeat_delay = 1; // Time in hours between repeat notifications (you will get notifications more often if the site repeatedly goes up and down)
$peak_start = 6; // Time to start peak monitoring
$peak_end = 11; // Time to start off-peak monitoring
$timeout_peak = 10; //timeout in seconds during peak times
@dylanahsmith
dylanahsmith / tcp-no-delay-benchmark.rb
Created January 9, 2014 23:04
Benchmarking Net::HTTP with and without keep-alive and TCP_NODELAY
#!/usr/bin/env ruby
require 'net/http'
require 'net/http/persistent'
require 'benchmark'
class HttpNoTcpDelay < Net::HTTP
def on_connect
@socket.io.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
nil