Skip to content

Instantly share code, notes, and snippets.

View magickatt's full-sized avatar

Andrew Kirkpatrick magickatt

View GitHub Profile
@magickatt
magickatt / gist:9078526
Created February 18, 2014 19:47
Delete only directories (not files) in a directory
#!/bin/bash
# Make a directory with some test directories and files inside
mkdir test
cd test
mkdir test1
mkdir test2
mkdir test3
touch hello.txt
touch goodbye.txt
@magickatt
magickatt / gist:e93a3c84ac5fd041b6d0
Created May 2, 2014 10:34
Unserialize PHP data
<?php
/*
* Yes this isn't sanitised, in case there are
* special characters in the serialized data
*
* ... therefore no this isn't safe to put on a
* public web server!
*/
@magickatt
magickatt / mysql_general_query_log_enable
Created April 29, 2015 15:11
Quick way to enable MySQL General Query Log
SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file = '/var/log/mysql/all.log';
<!DOCTYPE html>
<html ng-app='something'>
<head>
<meta charset='utf-8'>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<script
src="//cdn.rawgit.com/jpillora/xdomain/0.7.3/dist/xdomain.min.js"
slave="//api.yourdomain.ca/proxy.html">
<!DOCTYPE HTML>
<script
src="//cdn.rawgit.com/jpillora/xdomain/0.7.3/dist/xdomain.min.js"
master="https://www.yourdomain.ca">
</script>
@magickatt
magickatt / queryparam_replace.js
Created November 4, 2015 21:09
Replace value of URL query parameter in a string with another value
var url = 'https://www.example.com/mortgages?province_id=4';
var provinceId = 7;
var regularExpression = new RegExp("[\\?&]" + 'province_id' + "=([^&#]*)"),
delimeter = regularExpression.exec(url)[0].charAt(0),
newUrl = url.replace(regularExpression, delimeter + 'province_id' + "=" + provinceId);
alert(url);
alert(newUrl);
@magickatt
magickatt / behat.yml
Last active November 11, 2015 18:27
Fix SSL certificate problem with Behat, Guzzle and Goutte
default:
suites:
web:
paths: [ %paths.base%/features ]
contexts: [ WebContext ]
extensions:
Behat\MinkExtension:
base_url: 'https://localhost'
goutte:
@magickatt
magickatt / gist:5412216
Created April 18, 2013 12:04
Zend Server 6.0 default http (port 80) virtual host
Include "/usr/local/zend/etc/sites.d/http/__default__/0/*.conf"
<Directory "/usr/local/zend/var/apps/http/__default__/0/">
Allow From All
</Directory>
@magickatt
magickatt / gist:5412240
Created April 18, 2013 12:07
Zend Server 6.0 lighttpd (port 10088) virtual host
Include "/usr/local/zend/etc/sites.d/http/__default__/0/*.conf"
<Directory "/usr/local/zend/var/apps/http/__default__/0/">
Allow From All
</Directory>
@magickatt
magickatt / gist:5466324
Created April 26, 2013 10:23
Write data directly to FTP server without saving on the local filesystem
<pre>
<?php
// Host
$host = 'yourhostname.com';
$port = 21;
$timeout = 90;
// Credentials
$username = 'yourusername';