Skip to content

Instantly share code, notes, and snippets.

function convert($char, $string)
{
$internet = new DataSiftConnection($string);
$data = $internet->call('character', array('integer'=>$char), HTTP_METH_GET, 'php');
return json_decode($data, true);
}
@chrisalexander
chrisalexander / Heuristic Problem
Created October 16, 2010 16:47
Problem of the Week from 16/10/10
Mr Smith and his wife invited four couples for a party. When everyone arrived, some of the people in the room shook hands with some of the others. Of course, nobody shook hands with their spouse and nobody shook hands with the same person twice.
After that, Mr Smith asked everyone how many times they shook someone's hand. He received different answers from everybody.
How many times did Mrs. Smith shake someone's hand?
@chrisalexander
chrisalexander / BBC News
Created January 2, 2011 12:01
Apparently the BBC think this is a great way of coding their web pages...
<!--[if lte IE 6]><body class="news ie"><![endif]-->
<!--[if IE 7]><body class="news ie7"><![endif]-->
<!--[if IE 8]><body class="news ie8"><![endif]-->
<!--[if !IE]>--><body class="news"><!--<![endif]-->
@chrisalexander
chrisalexander / TestAbusingPHP
Created February 20, 2011 17:05
How to abuse PHP's implementation of object privacy to do what you want.
<?php
class TestAbusingPHP
{
public $property;
private function Write()
{
echo '#' . $this->property . '#';
}
Script for doing an update - works if "test" object is already in the index, but not if it does not.
curl -XPOST localhost:9200/00000000-0000-0000-0000-000000000000/tag/test/_update -d '{ "script": "ctx._source.count += 1" }'
Workaround - create an object if it doesn't exist then do the update, every time:
curl -XPOST localhost:9200/00000000-0000-0000-0000-000000000000/tag/test/?op_type=create -d '{"count":0}'
curl -XPOST localhost:9200/00000000-0000-0000-0000-000000000000/tag/test/_update -d '{ "script": "ctx._source.count += 1" }'
@chrisalexander
chrisalexander / gist:4665145
Created January 29, 2013 15:35
Demo SWT + XULrunner app which fails on tooltips on OS X
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@chrisalexander
chrisalexander / hg_diff
Last active December 12, 2015 01:28
Outputs of xulrunner debug build, outside and inside swt
diff -r fd559328eaf3 configure.in
--- a/configure.in Thu Jan 03 09:27:39 2013 -0800
+++ b/configure.in Fri Feb 01 13:57:01 2013 +0000
@@ -8737,7 +8737,7 @@
# (apparently) only need this hack when egrep's "pattern" is particularly
# long (as in the following code). See bug 655339.
case "$host" in
-*-apple-darwin*)
+*-apple-darwin11*)
FIXED_EGREP="arch -arch i386 egrep"
<!DOCTYPE html>
<html>
<head>
<script src="//d7xe6yl2ckrgs.cloudfront.net/js/2/importio.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
importio.init({"auth": {
"userGuid": "c4148a01-6fe5-48a2-996f-adce08b49a4f",
"apiKey": "(sign in to import.io then visit http://api.import.io/auth/apikeyadmin?password=[YOUR_PASSWORD]"
}});
@chrisalexander
chrisalexander / NetworkInterface.json
Created January 16, 2014 16:59
NetworkInterface for NTP with CloudFormation
{
"Type": "AWS::EC2::NetworkInterface",
"Properties": {
"Tags": [ "any tags" ],
"Description": "NTP Server Private ENI",
"SourceDestCheck": "true",
"GroupSet": [ "your security groups" ],
"SubnetId": "your subnet",
"PrivateIpAddress": "10.0.0.10"
}
@chrisalexander
chrisalexander / EIP.json
Created January 16, 2014 17:02
EIP for NTP with CloudFormation
{
"Type": "AWS::EC2::EIP",
"Properties": {
"Domain": "vpc"
}
}