Skip to content

Instantly share code, notes, and snippets.

View AndersDJohnson's full-sized avatar

Anders D. Johnson AndersDJohnson

View GitHub Profile

Keybase proof

I hereby claim:

  • I am andersdjohnson on github.
  • I am andersdjohnson (https://keybase.io/andersdjohnson) on keybase.
  • I have a public key ASBoMNJKbZ96SGvQXpSqFIq-41CVixOc-1JBgignRZ3BHwo

To claim this, I am signing this object:

@AndersDJohnson
AndersDJohnson / bootstrap-version-detect.js
Last active June 5, 2019 13:28
Bootstrap version detect
/**
* Hacks to detect Bootstrap version (2 vs. 3) from JavaScript.
* Does some detection of stringified functions - should be safe against most minification, but please test!
*
* Example:
* ```js
* bootstrapVersionDetect.isVersion('2', $);
* ```
*
* May not be necessary soon for Bootstrap 3+, @see https://github.com/twbs/bootstrap/pull/13578
@AndersDJohnson
AndersDJohnson / jquery-until.js
Last active June 5, 2019 13:32
jquery-until: wait for selector match
var until = function (selector, time, callback) {
var $match = $(selector);
if ($match.length) {
return callback($match);
}
setTimeout(function () {
until(selector, time, callback);
}, time);
};
@AndersDJohnson
AndersDJohnson / ConditionalSpec.groovy
Last active June 5, 2019 13:32
Geb conditional flow
class ConditionalSpec extends GebReportingSpec {
/**
* This should get us to SomePage, handling any interim pages.
*/
def getToSomePage () {
waitFor {
if (isAt(SomePage)) {
println "at some page"
return true
@AndersDJohnson
AndersDJohnson / xml2js-as-promised.js
Last active June 5, 2019 13:32
xml2js-as-promised
var Q = require('q');
var xml2js = require('xml2js');
module.exports = function (input) {
var deferred = Q.defer();
var parser = new xml2js.Parser();
parser.parseString(input, function (err, stdout, stderr) {
if (err) {
return deferred.reject(err);
}
var csv = require('csv');
csv()
.from.path(__dirname+'/export.csv', { delimiter: ',', escape: '"' })
.to.array( function(data){
var labels = data.shift();
var items = [];
data.forEach(function (row) {
var item = {};
row.forEach(function (value, index) {
@AndersDJohnson
AndersDJohnson / starcounter.js
Last active June 5, 2019 13:32 — forked from yyx990803/starcounter.js
Count your total stars!
var https = require('https'),
user = process.argv[2],
opts = parseOpts(process.argv.slice(3))
request('/users/' + user, function (res) {
if (!res.public_repos) {
console.log(res.message)
return
}
var pages = Math.ceil(res.public_repos / 100),
@AndersDJohnson
AndersDJohnson / css-font-smooth.css
Last active June 5, 2019 13:32
CSS Font Smoothing
/**
* http://blakepetersen.io/how-to-clean-up-chrome-and-safaris-webfont-rendering/
*/
.smooth-stroke {
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: .5px;
-webkit-text-stroke-color: rgba(0,0,0,0.5);
}
@AndersDJohnson
AndersDJohnson / wget-download-website.sh
Last active June 5, 2019 13:33
wget download websites for off-line viewing
wget --recursive --domains gnupg.org --no-parent --page-requisites --html-extension --convert-links --restrict-file-names=windows --no-clobber
@AndersDJohnson
AndersDJohnson / generate-ssl-cert.sh
Last active June 5, 2019 13:33
SSL certificate
# See: http://www.houseofding.com/2008/11/generate-a-self-signed-ssl-certificate-for-local-development-on-a-mac/
# Gen­er­ate a host key
ssh-keygen -f host.key
# Gen­er­ate a cer­tifi­cate request file
openssl req -new -key host.key -out request.csr
# Cre­ate a self-signed SSL cer­tifi­cate using the request file.
openssl x509 -req -days 365 -in request.csr -signkey host.key -out server.crt