Skip to content

Instantly share code, notes, and snippets.

Mathew Byrne mathewbyrne

View GitHub Profile
View examples.tsx
interface User {
name: string,
id: number,
avatar?: string,
}
const user: User = {
name: 'Testing',
id: 1234,
@mathewbyrne
mathewbyrne / location.html
Created Mar 3, 2015
A small, single-page tool for getting your current geolocation.
View location.html
<!doctype html>
<html>
<head>
<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">
<script>
var isTouchDevice = 'ontouchstart' in document.documentElement;
window.onload = function () {
var where = document.getElementById('where');
@mathewbyrne
mathewbyrne / CsvResponse.php
Created Mar 21, 2013
A small Symfony 2 class for returning a response as a CSV file. Based on the Symfony JsonResponse class.
View CsvResponse.php
<?php
namespace Jb\AdminBundle\Http;
use Symfony\Component\HttpFoundation\Response;
class CsvResponse extends Response
{
protected $data;
@mathewbyrne
mathewbyrne / lowercase.zsh
Created Jan 10, 2013
A quick way to rename all files in the current folder to lowercase.
View lowercase.zsh
#!/bin/zsh
# Requires zsh with zmv loaded
# autoload -U zmv
zmv '(*)' '${(L)1}'
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
}
View ditto-simulation.py
import sys
import random
all_stats = ['HP', 'Attack', 'Defense', 'Special Attack', 'Special Defense', 'Speed']
def catch_ditto():
@mathewbyrne
mathewbyrne / code-block.html
Created Jul 30, 2010
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">
<head>
<meta charset="utf-8" />
<title>Shadows Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<style>
* {
@mathewbyrne
mathewbyrne / README.mdown
Created May 22, 2010
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:

<script>$.gist(409808)</script>

Secondly, there is a more jQuery oriented method:

<div id="placeholder"></div>
<script>$('#placeholder').gist(409808);
You can’t perform that action at this time.