Skip to content

Instantly share code, notes, and snippets.

NAnt:
<move todir="${package.dir}\${new.name}" includeemptydirs="true">
<fileset basedir="${package.dir}\${old.name}" >
<include name="**\*" />
</fileset>
</move>
<delete dir="${package.dir}\${old.name}" />
Rake:
require 'fileutils'
unless (@settings[:properties].nil?)
properties_strings = []
@settings[:properties].sort.each do |key, value|
properties_strings << "#{key}=#{value}"
end
file.puts(" /property:#{properties_strings.join(';')}") unless properties_strings.length == 0
end
def build_options(option_name, option_values={})
if (option_values.length > 0)
option_text = "/#{option_name}:#{option_values}.build_parameters".chop
end
option_text
end
#monkeypatch for hash (not sure how this is done exactly)
def build_parameters
option_text = ''
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
keypressCount := 0
lockedKeypressCount := 0
locked := false
lockedKey = ""
doLog := false
#Short story, after 500 letters are typed on the keyboard, the 500th letter will be disabled for 10 letter presses.
#It also disables ctrl, alt, shift and win key combos with this letter (only the single key, not combos like ctrl-alt)
#So if the 500th letter was T, you could not type t, T, ctrl-T, alt-T or win-T until 10 letters have been pressed.
#After 10 letter presses, everything goes back to normal.
#Remember, this can be compiled into a .exe (named say... rundll32.exe) and run on any system without AHK
#Then all you have to do is get it started at boot time... just saying.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
var primes = Enumerable.Range(1, endVal).Select(x =>
{
if (
(!Enumerable.Range(2, x/2).Any(y => x%y == 0) &&
x > 1) || x == 2) return x;
return 0;
}).Where(x => x != 0);
public static class AssertionExtensions
{
public static void should_be_equal_to<T>(this T actual, T expected)
{
Assert.That(actual, Is.EqualTo(expected));
}
public static void should_be_equal_to(this double actual, double expected, int precision)
{
Assert.That(Math.Round(actual, precision), Is.EqualTo(expected));
# Note that the unzip app that i'm using is in my path from an Oracle installation.
# You can get unzip here: http://info-zip.org/UnZip.html and put it in your path
# Or replace the `unzip -o #{zipfile}` command with the unzip command line of your choice
# Personally, I also have an update.bat file which I use to run this script which I have indexed in launchy
require 'uri'
require 'net/http'
require 'fileutils'
#uses transient baz
class Foo
def new(baz = Baz.new)
@baz = baz
end
# do stuff with baz here
end
#!/bin/bash
powershell -Command $*
#place in your path (ex: /usr/local/bin) and now just prefix your powershell command with psh. Ex: psh dir will do a dir.