Skip to content

Instantly share code, notes, and snippets.

View davestewart's full-sized avatar
⚙️
Workin' on Chrome extensions!

Dave Stewart davestewart

⚙️
Workin' on Chrome extensions!
View GitHub Profile
@davestewart
davestewart / heart-domain-unlock.js
Last active August 29, 2015 13:57
Unlock all heart domains from their "list domains" page.
var str = '';
$('a[href^="/domains/"]').each(function(i, e){
var $e = $(e);
var url = $(e).attr('href').replace('index.cgi', 'action.cgi?action=lock_unset');
$(e).attr('href', url);
$.get(url, function(data){
data = data.replace(/^[\s\S]+?<body.+?>|<\/body>[\s\S]+$/g, '');
var $dom = $('<div>').html(data);
str += $dom.find('#yesbox p').text() + '\n';
console.clear();
@davestewart
davestewart / log.js
Last active August 29, 2015 13:57
Console.log shortcut. Mainly useful for sticking in a jQuery .each() loop...
// function
function log(){ console.log.apply(console, Array.prototype.slice.call(arguments, 0)); }
// as a shortcut
log(1,2,3);
// 1 2 3
@davestewart
davestewart / mixture.js
Last active August 29, 2015 13:58
Commented mixture settings file
{
// --------------------------------------------------------------------------------
// project
"projectName" : "Haven",
"projectDescription" : "New Haven site, built using Mixture",
// --------------------------------------------------------------------------------
@davestewart
davestewart / open-files-patterns.js
Last active August 29, 2015 14:00 — forked from Naatan/gist:9231532
Komodo IDE - Open Files patterns
/**
* Wildcard patterns:
*
* . - period (converts to regexp \. )
* / - folder delimiter (converts to regexp \/ )
* + - wildcard (converts to regexp .+? )
* * - wildcard (converts to regexp .*? )
*/
var patterns =
@davestewart
davestewart / load-images.html
Created July 10, 2014 09:07
jQuery asset queing using promises
<!DOCTYPE html>
<html>
<head>
<title>Image Load</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
@davestewart
davestewart / ternary-test.js
Last active August 29, 2015 14:04
Comparison of ternary, if/else, switch and hashed-methods to calculate a value
/**
* Comparison of ternary, if/else, switch and hashed-methods to calculate a value
*
* @author dave stewart
* @date weds 16th january 2014
* @see conversation at http://codepen.io/markmiro/blog/awesome-ternary-operator
*
* Results of 100,000 tests each:
*
* - testIf : 35 ms = 1.52 x
@davestewart
davestewart / get-posts.sql
Created August 8, 2014 14:42
SQL to select post data by category, tag or post format
SET @slug = "tools";
SET @taxonomy = "category"; # post_tag, category, post_format
SELECT
post_name,
post_title,
post_content,
post_content_filtered,
post_excerpt,
post_status,
@davestewart
davestewart / start server.applescript
Created August 25, 2014 12:12
Start Server Apple Script
# Starts server in current folder
tell application "Finder"
set currentDir to POSIX path of ((container of (path to me)) as text)
end tell
tell application "Terminal" to activate
tell application "Terminal"
do script ("cd '" & currentDir & "'")
@davestewart
davestewart / tidy-expense-categories.js
Created October 23, 2014 10:41
TamperMonkey script for FreeAgent to hide unused expense categories on Explanation screen
// ==UserScript==
// @name Hide unused FreeAgent expense categories
// @namespace http://davestewart.uk
// @version 0.1
// @description Hides unused categories on FreeAgent Explanation screen
// @author Dave Stewart
// @match https://davestewart.freeagent.com/bank_accounts/
// @grant none
// ==/UserScript==
@davestewart
davestewart / start server.bat
Created November 10, 2014 10:04
Start server and launch browser on Windows
REM you can use any resolvable address, such as local.yourdomain.com
start "" "http://localhost:8000"
php -S localhost:8000