Skip to content

Instantly share code, notes, and snippets.

View ao's full-sized avatar
😶‍🌫️

Andrew O ao

😶‍🌫️
View GitHub Profile
@ao
ao / gist:c793ffaf52c60e041927
Created October 17, 2013 14:17
speedtest from commandline
wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip
@ao
ao / gist:2b6ca4a4df66fe48b7a6
Created December 18, 2013 11:56
AngularJS - Get parent scope!
var scope = angular.element(document).scope();
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@ao
ao / README.md
Created April 15, 2014 13:24 — forked from oodavid/README.md

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
<?php
function fch($csm)
{
if($csm < 0)
$csm += 4294967296.0;
$a = (int)fmod($csm, 10);
$t = 1;
$b = (int)($csm / 10);
@ao
ao / crc32test.php
Created August 21, 2014 09:44
crc32test.php - Calculate crc32 loss
<?php
ini_set('memory_limit', '16000M');
$arrays = array();
$total = 50000000;
for ($i=0; $i<$total; $i++) {
$arrays[crc32($i)] = '';
function commafy( nStr ) {
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while( rgx.test( x1 )) {
x1 = x1.replace( rgx, '$1' + ',' + '$2');
}
return x1 + x2;
@ao
ao / gist:21eaf78b47e28ab65363
Created October 17, 2014 15:11
ChartJS - hide x-labels
If you want to hide the labels when there are too many, you can use the following extension. It just pushes the x-labels off the canvas so they are painted but not visible.
Chart.types.Line.extend({
name : "AltLine",
initialize : function(data) {
Chart.types.Line.prototype.initialize.apply(this, arguments);
this.scale.draw = function() {
if (this.display && (this.xLabelRotation > 90)) {
this.endPoint = this.height - 5;
@ao
ao / gist:b9c6a03782cc17b36554
Created November 24, 2014 09:46
Javascript $_GET variables
function $_GET(q, s) {
s = s ? s : window.location.search;
var re = new RegExp('&' + q + '(?:=([^&]*))?(?=&|$)', 'i');
return (s = s.replace(/^\?/, '&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined;
}
@ao
ao / gist:084dba82635f04d67ac1
Created January 15, 2015 09:00
Test nginx configuration
/usr/sbin/nginx -t