Skip to content

Instantly share code, notes, and snippets.


Mathew Byrne mathewbyrne

View GitHub Profile
mathewbyrne / CsvResponse.php
Created March 21, 2013 22:54
A small Symfony 2 class for returning a response as a CSV file. Based on the Symfony JsonResponse class.
View CsvResponse.php
namespace Jb\AdminBundle\Http;
use Symfony\Component\HttpFoundation\Response;
class CsvResponse extends Response
protected $data;
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
View slugify.js
function slugify(text)
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text

Keybase proof

I hereby claim:

  • I am mathewbyrne on github.
  • I am mathewbyrne ( on keybase.
  • I have a public key ASBeAW00p8JRympIF3NMKEWZ-7jWHQ14pnYiDQ-YO-aI9wo

To claim this, I am signing this object:

mathewbyrne / location.html
Created March 3, 2015 04:14
A small, single-page tool for getting your current geolocation.
View location.html
<!doctype html>
<meta charset="utf-8">
<title>Navigation Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
var isTouchDevice = 'ontouchstart' in document.documentElement;
window.onload = function () {
var where = document.getElementById('where');
mathewbyrne / code-block.html
Created July 30, 2010 02:47
A fun little experiment playing with CSS box shadows. I think it roughly works in Safari, Chrome and Firefox. No guarantees though.
View code-block.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8" />
<title>Shadows Test</title>
<script src=""></script>
* {
View examples.tsx
interface User {
name: string,
id: number,
avatar?: string,
const user: User = {
name: 'Testing',
id: 1234,
mathewbyrne / README.mdown
Created May 22, 2010 05:30
An asynchronous method for embedding gists in an HTML document using jQuery.
View README.mdown

A quick jQuery plugin for asynchronously embedding a gist in an HTML document.

There are a couple of ways to use it. First is the direct method that will insert it into the current position in the document:


Secondly, there is a more jQuery oriented method:

<div id="placeholder"></div>
mathewbyrne / lowercase.zsh
Created January 10, 2013 03:44
A quick way to rename all files in the current folder to lowercase.
View lowercase.zsh
# Requires zsh with zmv loaded
# autoload -U zmv
zmv '(*)' '${(L)1}'
import sys
import random
all_stats = ['HP', 'Attack', 'Defense', 'Special Attack', 'Special Defense', 'Speed']
def catch_ditto():