Skip to content

Instantly share code, notes, and snippets.

View NigelThorne's full-sized avatar

Nigel Thorne NigelThorne

View GitHub Profile
@NigelThorne
NigelThorne / Parse_C_Enum.rb
Created November 29, 2011 02:53
Parse C C++ C# enum definition to make a ruby hash of the values and names
# Parse C C++ C# enum definition to make a ruby hash of the values and names
# By Nigel Thorne (nwt) www.nigelthorne.com
# https://gist.github.com/1403153
require 'rubygems'
require 'parslet'
include Parslet
class Array
def to_h
@NigelThorne
NigelThorne / gist:1408193
Created November 30, 2011 05:41
monadic stack attempt in coffee script
# GOAL - immutable objects
# to make these composable they need to both have the same signature...
compose = (f, g) -> (x) -> g(f(x))
c = (f, args...) ->
if(f)
compose(f, c.apply(this,args))
else
nil
@NigelThorne
NigelThorne / styler.css
Created March 1, 2012 22:42
WorkFlowy userscript to add css classes to nodes based on their tags
/* I use Stylish (a chome addin) to set these styles
* URLs on the domain workflowy
*/
.next-row {
border: 2px solid #46A546 !important;
border-top-left-radius:0.5em;
background-color: #CCFFCC !important;
}
@NigelThorne
NigelThorne / gist:2424782
Created April 19, 2012 23:07
AutoHotKey Script for CNC style window focus control
; AutoHotKey script file
; press Ctrl+win+1 to make Win+1 give focus to whatever the current window is
; press Ctrl+win+2 to make Win+2 give focus to whatever the current window is
; press Ctrl+win+3 to make Win+3 give focus to whatever the current window is
; press Ctrl+win+4 to make Win+4 give focus to whatever the current window is
; press Ctrl+win+5 to make Win+5 give focus to whatever the current window is
;;;;;;;;;;;;;;;;;CNC KEYS;;;;;;;;;;;;;;;;;;;;;;;;;
CNCKey1 =
^#1:: ;save current focused window to a variable
@NigelThorne
NigelThorne / load_jquery.js
Created May 8, 2012 22:51
Load JQuery & JQueryUI programatically
//Taken from http://www.jquery4u.com/javascript/dynamically-load-jquery-library-javascript/
//Load jQuery library using plain JavaScript
(function(){
var newscript = document.createElement('script');
newscript.type = 'text/javascript';
newscript.async = true;
newscript.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js';
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(newscript);
})();
@NigelThorne
NigelThorne / hash_inverse.rb
Last active October 25, 2017 05:43
ruby hash invert
require './hash_inverse'
describe Hash do
describe "when empty and asked for the inverse" do
it "returns an empty hash" do
{}.inverse.must_equal Hash.new
end
end
describe "when mapping are unique and asked for the inverse" do
@NigelThorne
NigelThorne / gist:2992186
Created June 25, 2012 23:57
grep on windows
@REM On windows grep's slashes are the wrong way around.
@"%~dp0tools\grep.exe" %* | ruby -n -e' x = $_.split(":"); x[0].gsub!(/\//, "\\"); puts x.join(":")'
@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 / purple_op_plugin.rb
Created October 6, 2012 11:17
PurpleOp0.3 = Minecraft Purugin Plugin.
require 'java'
java_import org.kitteh.tag.PlayerReceiveNameTagEvent
java_import org.kitteh.tag.TagAPI
module Purugin
module Event
# FIXME: This only handles normal priority. Real fix is to generate these on demand versus up
# front. We can reify what we need. This will also fix custom event types.
@NigelThorne
NigelThorne / PurpleOp2.rb
Created October 7, 2012 08:00
PurpleOp0.2
require 'java'
module Purugin
module Event
# FIXME: This only handles normal priority. Real fix is to generate these on demand versus up
# front. We can reify what we need. This will also fix custom event types.
require 'jruby/core_ext'