Skip to content

Instantly share code, notes, and snippets.

View dana-ross's full-sized avatar

Dana Ross dana-ross

View GitHub Profile
@dana-ross
dana-ross / http2-link.php
Last active August 29, 2015 14:25
Experimental WordPress plugin to enable HTTP/2 server-push. I know it sends link: headers. Not sure it's actually doing anything.
@dana-ross
dana-ross / rc.local
Created May 9, 2015 01:10
Make ZoomFloppy device available to non-root users
# /etc/rc.local
`lsusb -d 16d0:0504 | sed "s/Bus /chmod o+w \/dev\/bus\/usb\//" | sed "s/ Device /\//" | cut -d ":" -f 1`
exit 0
@dana-ross
dana-ross / gist:d5e15b6b0ebd44e09962
Last active August 29, 2015 14:13
XSS through jQuery.html() example
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
window.addEventListener('DOMContentLoaded', function() {
// Assume hacked_string started off as something completely fine, but a third-party script changed its value so now it looks like...
var hacked_string = "\"\>\<script\>alert(\"haxx0r3d\")\<\/script\>";
// Use the DOM API to build a node. Use hacked_string as its id
@dana-ross
dana-ross / podcasts.txt
Created December 8, 2014 15:20
Current podcast favorites
Last updated: 2014-12-08
A Responsive Web Design Podcast
Boagworld Web Show
On the Grid
Word-Break Show
The Web Ahead
Debug
Polygamer
((function ($) {
$.scrollWindowTo = function (pos, duration, cb) {
if (duration == null) {
duration = 0;
}
if (pos === $(window).scrollTop()) {
$(window).trigger('scroll');
if (typeof cb === "function") {
cb();
}
@dana-ross
dana-ross / formbuilder_sample.json
Created October 23, 2014 21:31
Sample JSON structure for formbuilder plugin
[
{
"label":"Text field label",
"field_type":"text",
"required":true,
"field_options":{
"size":"small",
"description":"Text field description",
"minlength":"1",
"maxlength":"100"
@dana-ross
dana-ross / gist:32024b26b1a834f2e3f4
Last active August 29, 2015 14:04
Override "Lost your password?" in WordPress
add_filter( 'gettext', 'change_lost_pw_link', 30, 2 );
/**
* Override translations
*
* @param string $translated Translated string
* @param string $untranslated Untranslated string
*
* @return string translated string
*/
@dana-ross
dana-ross / setup-new-mac.sh
Last active September 10, 2016 00:45
Re-create my dev environment if my laptop fails
#!/bin/bash
# (not really -- run these commands by hand & pay attention to the comments)
# Homebrew: The missing package manager for OS X
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
# Fish: Finally, a command line shell for the 90s
brew install fish
# Git
@dana-ross
dana-ross / gist:8625999
Last active January 4, 2016 13:09
WP_Session mods to recursively check dirty flag
/**
* Write the data from the current session to the data storage system.
*/
public function write_data() {
$option_key = "_wp_session_{$this->session_id}";
// Only write the collection to the DB if it's changed.
$this->recursive_dirty_check( $this );
if ( $this->dirty ) {
if ( false === get_option( $option_key ) ) {
// There should be an "ajaxurl" variable set that you can use instead of hard-coding the url here
jQuery.get('/wp-admin/admin-ajax.php', {'action': 'this_sucks', 'postid': '1234'}, function(data, status, jqXHR) {
// Display post here
});