This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub InsertLotsOfFiles() | |
' | |
' InsertLotsOfFiles Macro | |
' Macro written 21/09/2009 by Nigel Thorne | |
' | |
Dim No_Of_Files As Integer | |
Dim kk25 As Integer | |
Dim File_Path As String | |
File_Path = "..." 'change this to the path you want to use. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Taken from http://coderrr.wordpress.com/2008/04/22/building-the-right-class-with-sti-in-rails/ | |
class GenericClass < ActiveRecord::Base | |
class << self | |
def new_with_cast(*a, &b) | |
if (h = a.first).is_a? Hash and (type = h[:type] || h['type']) and (klass = type.constantize) != self | |
raise "wtF hax!!" unless klass < self # klass should be a descendant of us | |
return klass.new(*a, &b) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game(rolls: List[Int]) { | |
def score:Int = score(rolls, 10) | |
private def score(rolls:List[Int], index:Int):Int = { | |
if (index == 0) return 0 | |
rolls match { | |
case 10 :: second :: third :: rest | |
=> 10 + second + third + score(second :: third :: rest, index-1) | |
case first :: second :: third :: rest if first + second == 10 | |
=> 10 + third + score(third :: rest, index-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.fromRoman = function() { | |
maps = new Object(); | |
maps["I"] = 1; | |
maps["V"] = 5; | |
maps["X"] = 10; | |
maps["L"] = 50; | |
maps["C"] = 100; | |
maps["D"] = 500; | |
maps["M"] = 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please fork this and make it better :) | |
# | |
# A valid solution follows these rules: | |
# 1 - The output should be the same sql as the input with different whitespace. | |
# 2 - Running the script on a file that is already beautified should do nothing. | |
sql = File.read(ARGV[0]) | |
clean = sql. | |
gsub(/\t/, " "). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mark things you want to resize with class="resizeable" | |
// The ratio between their sizes will be maintained. | |
// works with jquery-1.4.2.min.js | |
// | |
// <script src=".../jquery-1.4.2.min.js"></script> | |
// <script src=".../resize.js"></script> | |
// | |
function resizeNodes(nodes, startsizes, multiplier){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text.RegularExpressions; | |
namespace NigelThorne | |
{ | |
public class CSVParser | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'parslet' | |
#This needs a few more 'as' calls to annotate the output | |
class JSONParser < Parslet::Parser | |
rule(:space) { match('[\s\n]').repeat(1)} | |
rule(:space?) { space.maybe } | |
rule(:digit) { match('[0-9]') } | |
rule(:hexdigit) { match('[0-9a-fA-F]') } | |
rule(:comma) { space? >> str(',') >> space? } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Report SVN logs for a revision span as a csv for analysis in excel. | |
# By Nigel Thorne (nwt) www.nigelthorne.com | |
require 'nokogiri' | |
repo = ARGV[0] || "http://.../trunk" # repository location | |
from = ARGV[1] || "1111" # from revision | |
to = ARGV[2] || "2222" # to revision | |
xml_changes = Nokogiri::XML(`svn.exe log #{repo} -r#{from}:#{to} --xml`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Report On the Worst code in your codebase (for some definition of worst) as reported by Team City and NCover | |
# *******This works for us.. may need editing to work for you!******** | |
# By Nigel Thorne (nwt) www.nigelthorne.com | |
# https://gist.github.com/gists/1403141 | |
#install : | |
# once ruby is installed... | |
# and in your path | |
# gem install nokogiri | |
# gem install mechanize |