Skip to content

Instantly share code, notes, and snippets.

@pgeraghty
pgeraghty / gist:4754245
Last active December 12, 2015 09:49
Finding emails and URLs in MySQL columns
# contains email address
where("column_name REGEXP '[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}'").count
# contains url
where("column_name REGEXP ?", "(https?://|www\\.)[\.A-Za-z0-9\-]+\\.[a-zA-Z]{2,4}").count
@pgeraghty
pgeraghty / capture-element.coffee
Last active December 12, 2015 08:39
Captures matching element of page with PhantomJS
page = require('webpage').create()
system = require 'system'
if system.args.length is 1
console.log 'Usage: capture-element.coffee <URL> (filename) (#selector)'
phantom.exit 1
else
address = system.args[1]
filename = system.args[2] || 'capture.png'
selector = system.args[3]
var page = new WebPage(),
url = 'http://localhost/a-search-form',
stepIndex = 0;
/**
* From PhantomJS documentation:
* This callback is invoked when there is a JavaScript console. The callback may accept up to three arguments:
* the string for the message, the line number, and the source identifier.
*/
page.onConsoleMessage = function (msg, line, source) {
$output-media-width: true !default; // true = all, otherwise use a list of numeric values (eg. 320px 23em)
@mixin media-min-width($bp) {
@if type-of($output-media-width) != list {
@media (min-width: $bp) {
@content;
}
} @else {
$output-bp: find-comparable($bp, $output-media-width);
@if not comparable($output-bp, $bp) {