Skip to content

Instantly share code, notes, and snippets.

View dhensby's full-sized avatar

Daniel Hensby dhensby

  • London, UK
  • 13:00 (UTC +01:00)
  • X @dhensby
View GitHub Profile
@dhensby
dhensby / multiple-form-submitter.js
Created January 30, 2014 17:49
A simple script to iterate over links and request the page they link to. Then finding a form field, selecting it and submitting the form.
//go through each link
$('a.resolved').each(function() {
//request the page being linked to
$.get($(this).attr('href'), function(data) {
//set the field we want and find the form
var $form = $(data).find('#comment_status_id_4').trigger('click').closest('form');
//submit the form
$.post($form.prop('action'), $form.serialize());
});
});
@dhensby
dhensby / install-ss-with-vagrant.bat
Last active August 29, 2015 13:56
Basic steps to get a clean [SilverStripe](https://github.com/silverstripe) install using [vagrant-skeleton](https://github.com/BetterBrief/vagrant-skeleton) - This is pseudo and untested code
# Bash script for installing SS into a Vagrant machine
# using windows 8
#
# Author Dan Hensby <https://github.com/dhensby>
# clone the git repo for the Vagrant skeleton
git clone https://github.com/BetterBrief/vagrant-skeleton.git .
# Remove the .git folder, we don't really want that
del .git -R -Force # this doesn't work so well on win 8 as it prompts
# Create the webroot
@dhensby
dhensby / do-makewaves.js
Last active August 29, 2015 13:56
Script to auto reload DigitalOcean graphs on the droplet page
/**
* Refreshes the graphs at their interval
*/
//generic function for generating a graph by parent ID
function genNewGraphByID(id) {
$(id).find('div.graph').each(function() {
$(this).children().remove();
drawGraph(this);
});
@dhensby
dhensby / csv-301.php
Created February 28, 2014 15:35
CSV to .htaccess 301 map
<?php
/**
* Assuming that we have a CSV like so:
* old/url, new/url
*/
$csv = '/path/to/csv/file.csv';
$hasHeaderRow = true;
@dhensby
dhensby / diff-scroller.js
Last active August 29, 2015 14:00
Scroll to the next diff in a PR summary window!
(function($, w, undefined) {
var $diffs = $('.diff-view .js-details-container');
var $comments = $('.diff-view .js-comment');
var $w = $(w);
var $a = $('<a/>', {
'class': 'js-next-diff',
'href': '#'
}).css({
'position': 'fixed',
'font-size': 'large',
WARNING: Manifest not flushed. Add flush=1 as an argument to discover new classes or files.
PHPUnit 3.7.37 by Sebastian Bergmann.
Configuration read from /var/www/test/phpunit.xml.dist
..I.EE..EEE.EEEE........E....EE....E.....E.EE.....EE..EEEEEE. 61 / 1603 ( 3%)
....................EE.....EE..E............................. 122 / 1603 ( 7%)
.......................................................EE.... 183 / 1603 ( 11%)
...............EE.EEE.E...............E...................... 244 / 1603 ( 15%)
@dhensby
dhensby / osb-install-fe.sh
Last active August 29, 2015 14:12
OSB installer for CentOS 7
#create my install dirs
mkdir -p ~/osb-installer/src
cd ~/osb-installer
#install required software
yum install -y vim wget unzip git java-1.6.0-openjdk-devel mariadb-server
#Start mysql on boot and now
systemctl enable mariadb.service
systemctl start mariadb.service
@dhensby
dhensby / CSVFormatter.php
Created February 13, 2015 09:55
SilverStripe compatible CSV formatter
<?php
/**
* Usage CSVFormatter::format_list(Member::get(), array('CSVColumnTitle' => 'Database Field'), (bool)$headerRow)
*/
class CSVFormatter {
private static $value_quoter = '"';
private static $column_separator = ',';
@dhensby
dhensby / ActivityAggregatorItem.php
Last active August 29, 2015 14:16
Simple aggregator for SilverStripe
<?php
class ActivityAggregatorItem {
/** @var callable */
private $listFunction;
/** @var int */
private $limit;
<?php
class CRMAdmin extends ModelAdmin {
private static $url_segment = "crm";
private static $menu_title = "CRM";
private static $managed_models = array(
"Client",
"Contact",