Skip to content

Instantly share code, notes, and snippets.

@phuedx
phuedx / sublime-text-2-icns.sh
Created July 16, 2012 09:15
Replace Sublime Text 2's default icon with Daniel Matarazzo's
ROOT="/Applications/Sublime Text 2.app/Contents/Resources"
TEMP=$(/usr/bin/env mktemp -d '/tmp/Sublime-Text-2-Icon.XXXXXX')
git clone git://github.com/dmatarazzo/Sublime-Text-2-Icon.git $TEMP
cp "$ROOT/Sublime Text 2.icns" "$ROOT/Sublime Text 2.icns.old"
cp "$TEMP/Sublime Text 2.icns" "$ROOT/Sublime Text 2.icns"
rm -rf $TEMP
@phuedx
phuedx / 1311137514.json
Created November 26, 2012 10:51
A scrobble in the JSON variant of HAL.
{
"_links": {
"self": {
"href": "/scrobbles/phuedx/1311137514"
}
},
"_embedded": {
"track": {
"_links": {
"self": {
@phuedx
phuedx / call-me-maybe.php
Last active December 14, 2015 13:38
Hey, I've just called you, And this is crazy, But I misspelled you, So proxy, maybe?
<?php
class CallMeMaybe
{
public function __call($name, $arguments)
{
$class = new ReflectionClass($this);
$weightedMethods = array();
foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
$methodName = $method->getName();
<?php
require __DIR__ . '/wmgUseGettingStarted.php'; // Modified to initialise $wmgUseGettingStarted
function getSitelinksByID( $id ) {
$url = "https://www.wikidata.org/w/api.php?format=json&action=wbgetentities&props=sitelinks&ids={$id}";
$responseBodyRaw = file_get_contents( $url );
$responseBody = json_decode( $responseBodyRaw, true );
$entity = $responseBody[ 'entities' ][ $id ];
$result = array();
@phuedx
phuedx / gist:0639a279b6efb1a71474
Created May 29, 2014 16:56
ext.guidedTour.animations.less
.fade-in-keyframes-for-direction(@direction, @dx, @dy) {
@-webkit-keyframes mwe-gt-fade-in-@{direction} {
.mwe-gt-fade-in-translate-frames(@dx, @dy);
}
@-moz-keyframes mwe-gt-fade-in-@{direction} {
.mwe-gt-fade-in-translate-frames(@dx, @dy);
}
@-o-keyframes mwe-gt-fade-in-@{direction} {
@phuedx
phuedx / bands_without_mbids.php
Created August 8, 2014 14:50
If you're in any doubt, then write an API.
<?php
function is_instance_of( $item ) {
return "CLAIM[31:{$item}]";
}
function is_instance_of_band() {
return is_instance_of( '215380' );
}
@phuedx
phuedx / firehose.py
Last active August 29, 2015 14:05
Listen to a wiki's recentchanges feed and publishes them as standardised JSON strings via a ØMQ PUB socket.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Listens to a wiki's recentchanges feed and publishes them as standardised JSON
events, converted to strings, via a ØMQ PUB socket.
Usage:
./firehose.py <api_url> <endpoint>
Options:
@phuedx
phuedx / identity.hh
Last active August 29, 2015 14:06
The Identity monad.
<?hh
type F1<Ta, Tb> = (function(Ta): Tb);
class Identity<Ta> {
public function __construct(private Ta $value) {}
public function bind<Tb>(F1<Ta, Identity<Tb>> $f): Identity<Tb> {
return $f($this->value);
}
@phuedx
phuedx / effective_tld_names.dat
Created November 5, 2014 15:07
Find the highest level part of the host that isn't a public suffix as listed at https://publicsuffix.org
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// ===BEGIN ICANN DOMAINS===
// ac : http://en.wikipedia.org/wiki/.ac
ac
com.ac
edu.ac
@phuedx
phuedx / MyAwesomeFeature.experiment
Last active August 29, 2015 14:10
Can we repurpose the Gherkin syntax to define simple experiments?
Experiment: version
Scenario:
Given the user is logged in
Then they should have a 70% chance of being "A"
And they should have a 30% chance of being "B"