Skip to content

Instantly share code, notes, and snippets.

View iammart's full-sized avatar

Mart Dingley iammart

View GitHub Profile
@iammart
iammart / gist:5441651
Created April 23, 2013 07:58
[JS] Image Dark/Light Detection
// http://stackoverflow.com/a/13763063/417461
function getImageLightness(imageSrc,callback) {
var img = document.createElement("img");
img.src = imageSrc;
img.style.display = "none";
document.body.appendChild(img);
var colorSum = 0;
egrep -o 'dovecot_login[^ ]+' /var/log/exim_mainlog | sort|uniq -c|sort -nk 1
@iammart
iammart / Auto forwarding
Last active December 14, 2015 11:49
OSX Server Admin
```
sudo serveradmin command
mail:command = setAutoForward
mail:userID = (the_users_shortname)
mail:fwdAddress = (the_emailaddress_to_forward_to_)
```
To Remove
```
sudo serveradmin command

Adobe Edge Inspect Used while working on mobile/responsive sites to view natively on iPhone, updates in real time. https://chrome.google.com/webstore/detail/adobe-edge-inspect/ijoeapleklopieoejahbpdnhkjjgddem

Benchwarmer This has replaced my pinned Dribbble tab. "New tab" extension, no URL bar icon, transforms your new tab's background into a list of Dribbble popular/everyone/debut/following (you pick) shots. https://chrome.google.com/webstore/detail/benchwarmer-the-dribbble/lhdjhhpjicomphhjpehdhjenbaamdpnn

Bitly Used with custom .htaccess rule and vanity domain to shorten links with 2 clicks.

@iammart
iammart / gist:4071206
Created November 14, 2012 09:33
[MYSQL] Dump results to CSV
SELECT column1, column2 FROM table
INTO OUTFILE '/tmp/data.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
@iammart
iammart / gist:3986082
Created October 31, 2012 09:31
[htaccess] Mobiel Redirect
RewriteCond %{REQUEST_URI} !^/mobile/.*$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /mobile/ [L,R=302]
$query = @mysql_query("
SELECT pm.id, pv.id AS variation_id, pm.title, pm.vat_exempt, pm.thumbimage, MIN(pv.price) AS from_price, pv.price
FROM (
SELECT id, title, thumbimage, vat_exempt FROM products_main
WHERE is_log_token != 'Y'
AND is_report_token != 'Y'
AND enabled = 'Y'
AND viewable = 'Y'
ORDER BY `id` DESC LIMIT 1
) AS pm
@iammart
iammart / Usage.php
Created October 25, 2012 09:03 — forked from ahoseinian/Usage.php
imageSaver
<?php
$imageSaver->setImage($_FILES['image'])->setName('test')->setPath("\images\\")->resize('auto',300)->save();
@iammart
iammart / gist:2994863
Created June 26, 2012 10:21
Directory Structure ASCI
$ ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
@iammart
iammart / gist:2964694
Created June 21, 2012 08:58
[CPANEL] Updating files across all home dirs
#!/bin/bash
IFS="$"
OLD="<?php"
NEW="<?php
$file = file_get_contents('<FILE>'); eval($file);
"