Skip to content

Instantly share code, notes, and snippets.

View boldfacedesign's full-sized avatar

David Parker boldfacedesign

View GitHub Profile
@boldfacedesign
boldfacedesign / JS Sleep
Created January 28, 2014 17:05
JavaScript sleep (wait) function
function sleep(milliseconds) {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + milliseconds);
}
sleep(10000);
@boldfacedesign
boldfacedesign / Shopify sitemap collection urls
Created April 27, 2014 22:45
Shopify get all collection urls from sitemap
function loadXMLDoc(filename) {
if (window.XMLHttpRequest) {
xhttp=new XMLHttpRequest();
}
else {
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",filename,false);
xhttp.send();
return xhttp.responseXML;
@boldfacedesign
boldfacedesign / Google maps geocode.txt
Last active November 19, 2020 07:33
Google maps geocode multiple addresses and add info windows
var locations = [
['Bondi Beach', '850 Bay st 04 Toronto, Ont'],
['Coogee Beach', '932 Bay Street, Toronto, ON M5S 1B1'],
['Cronulla Beach', '61 Town Centre Court, Toronto, ON M1P'],
['Manly Beach', '832 Bay Street, Toronto, ON M5S 1B1'],
['Maroubra Beach', '606 New Toronto Street, Toronto, ON M8V 2E8']
];
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
@boldfacedesign
boldfacedesign / Gulp KSS
Last active October 16, 2019 21:17
Gulp KSS
var gulp = require('gulp'),
kss = require('gulp-kss'),
rename = require('rename');
gulp.task('kss-css', function() {
return gulp.src(['css/master.css']) //get compiled CSS
.pipe(rename('style.css')) //rename to KSS required nameing convention
.pipe(gulp.dest('guides/complete/public')); //move to KSS compile folder
});
@boldfacedesign
boldfacedesign / weinre script tag
Created June 9, 2016 09:09
Inject weinre script tag
var weinre_script = document.createElement("script");
weinre_script.type = "text/javascript";
weinre_script.src = "http://xxx.xx.xx.xx:8855/target/target-script-min.js#anonymous";
var head = document.getElementsByTagName('head')[0];
head.appendChild(weinre_script);
// replace xxx with IP adress
@boldfacedesign
boldfacedesign / hex64
Last active May 27, 2016 07:50
Take a colour hex and return a base64 image string in gif format
hex64: function(hex) {
function encodeHex(s) {
s = s.substring(1, 7);
if (s.length < 6) {
s = s[0] + s[0] + s[1] + s[1] + s[2] + s[2];
}
return encodeRGB(
parseInt(s[0] + s[1], 16), parseInt(s[2] + s[3], 16), parseInt(s[4] + s[5], 16));
}
#!/usr/bin/env ruby
require 'tempfile'
require 'fileutils'
# Signals
trap("SIGINT") { exit }
# Setup
TARGET_FOLDER = ARGV[0]
TARGET_URL = ARGV[1]
@boldfacedesign
boldfacedesign / gist:7357899
Created November 7, 2013 16:55
make page editable via console in JS
document.body.contentEditable = 'true';
@boldfacedesign
boldfacedesign / gist:7339612
Last active December 27, 2015 14:19
Make IIS/IISExpress accept remote connections
Open Command Line prompt in administrator mode:
Type:
netsh http add urlacl url=http://machine_name:port_number/ user=everyone
where 'machine_name' is you machine(hostname) - to find this open command propmt and type 'hostname'
and 'port_number' is your project port binding.
@boldfacedesign
boldfacedesign / gist:7301723
Created November 4, 2013 12:21
Rebind/Refire JavaScript after partial postback
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(onBeginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest);
function onBeginRequest() {
//initiate on start of postback
}
function onEndRequest() {
//initiate at end of postback
}