Skip to content

Instantly share code, notes, and snippets.

View NigelThorne's full-sized avatar

Nigel Thorne NigelThorne

View GitHub Profile
@NigelThorne
NigelThorne / webservices.vba
Last active January 3, 2016 17:31
Download json from web service and push onto excel sheet
' Add references in Excel
' * Microsoft XML, v6.0
' * Microsoft Script Control 1.0
Option Explicit
Private ScriptEngine As ScriptControl
Public Function GetWebSource(ByRef URL As String) As String
Dim xml As IXMLHTTPRequest
@NigelThorne
NigelThorne / gist:7671000
Created November 27, 2013 05:18
I like duckduckgo.. but it bothers me that it's above my google results. So.. i moved it I use control freak google chrome plugin to run greasemonkey type scripts.
function move_duckduckgo(){
var node = document.getElementById('ddg_zeroclick');
if(node != null){
document.getElementById('rhs').appendChild(node);
} else {
setTimeout(move_duckduckgo, 10);
}
}
move_duckduckgo();
@NigelThorne
NigelThorne / youtube_hide_button.js
Created December 21, 2015 03:01
Control Freak Script for adding "hide" button to YouTube. So you can listening to music without looking like you are watching music videos.
// add libs
// http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// https://raw.githubusercontent.com/hazzik/livequery/master/dist/jquery.livequery.min.js
$("#upload-btn").livequery(function(){
$("<button id='hide-btn'>Hide</button>").insertAfter("#upload-btn");
$('#hide-btn').click(function(){
if ( $('video').css('visibility') == 'hidden' )
@NigelThorne
NigelThorne / index.html
Last active December 17, 2015 19:29
POC for generating tests from template files.
<html>
<body>
<table width='100%'>
<tr>
<td>Select a TestTemplate File to Load:</td>
<td><input type="file" id="fileToLoad">
<td><a href="javascript:loadFileAsText()">Load Selected File</a><td>
</tr>
<tr>
<td colspan="3">
@NigelThorne
NigelThorne / gist:4718832
Created February 5, 2013 23:48
composing parslet parsers
require 'rubygems'
require 'parslet'
#This needs a few more 'as' calls to annotate the output
class JSONParser < Parslet::Parser
def initialize(number_parser)
@number_parser
end
rule(:space) { match('[\s\n]').repeat(1)}
@NigelThorne
NigelThorne / _step.erb
Last active December 11, 2015 12:38
Problem going to Rails 3
<li class='step'>
<%= sf.hidden_field :id %>
<%= sf.hidden_field :step_definition_id %>
<%= sf.hidden_field :position ,:class=>"position"%>
<%= sf.object.format_with_params { |param| render(:partial=>'scenarios/param' , :locals=>{:param=> param, :sf=>sf})} %>
<% if sf.object.new_record? %>
<%= link_to "Remove", '#', :onclick =>"$(this).parent('.step').remove()" %>
<% else %>
<%= sf.check_box '_destroy' %>
@NigelThorne
NigelThorne / while.rb
Created January 18, 2013 11:43
Functional While look in ruby
class While
def initialize(&src_fn)
@src_fn = src_fn
end
def do
x = @src_fn.call
while(x)
yield(x)
x = @src_fn.call
@NigelThorne
NigelThorne / GmailOutlookMacro.vbs
Last active December 3, 2015 23:55
Gmail behaviour in Outlook
' You need to make a mail folder called "Archive" for the emails to move into, and add this email to your menu bar and call it "&[Archive"
' You also need to open an email and add the macro to your quickbar (I expect it to be item 6, which you can check by typing 'alt')
Sub Archive()
Dim myItem
If TypeName(Application.ActiveWindow) = "Inspector" Then
Set myItem = Application.ActiveWindow.CurrentItem
myItem.UnRead = False
myItem.Move (Application.GetNamespace("MAPI").Folders("Archive"))
Else
@NigelThorne
NigelThorne / collate_and_rescale_pdf.sh
Created October 27, 2015 12:25
Shell script to take two pdfs (one all odd pages, one all even) and merge them then rescale the images to reduce the file size for emailing.
# Example script to collate and reduce size of scanned pdf. Idea taken from Stackoverflow answers
# interleave two pdfs as one
pdftk A=Emma\ front\ half.pdf B=Emma\ back\ half.pdf shuffle A B output Emma.pdf
# convert to postscript
pdf2ps Emma.pdf Emma.ps
# convert back with defined resolution 150
ps2pdf -dPDFSETTINGS=/screen -dDownsampleColorImages=false -dColorImageResolution=150 -dColorImageDownsampleType=/Bicubic Emma.ps Emma_ps150b.pdf
@NigelThorne
NigelThorne / zoom.js
Last active October 20, 2015 05:42
Zoom button for appear.in. Makes "enlarged" screen even bigger. click twice to get massive. (note: close chat area)
/* knicked the Wait for load script from http://stackoverflow.com/questions/5525071/how-to-wait-until-an-element-exists */
/* https://gist.github.com/buu700/4200601 */
(function ($) {
/**
* @function
* @property {object} jQuery plugin which runs handler function once specified element is inserted into the DOM
* @param {function} handler A function to execute at the time when the element is inserted
* @param {bool} shouldRunHandlerOnce Optional: if true, handler is unbound after its first invocation