Skip to content

Instantly share code, notes, and snippets.

@kenny-evitt
kenny-evitt / Regex for strings that do not begin with specific text
Created June 13, 2013 16:17
Regular expression (regex) for matching a string that does NOT begin with specific text (i.e. "Something - " in the code).
^(?:(?!Something\s\-\s).)*$
@kenny-evitt
kenny-evitt / Regex for strings that do not end with specific text
Created June 13, 2013 16:18
Regular expression (regex) for matching a string that does NOT end with specific text (i.e. ".config" in the code).
^(?:.(?!config$))*$
@kenny-evitt
kenny-evitt / Regex for strings that do not contain specific text but do end with specific text
Created June 13, 2013 20:01
Regular expression (regex) for matching a string that does NOT contain specific text (i.e. "\Configs\" in the code), but DOES end with specific text (i.e. ".config" in the code).
^(?:(?!\\Configs\\).)*\.config$
@kenny-evitt
kenny-evitt / FogBugz text snippets
Created June 14, 2013 15:45
Various text snippets for use with FogBugz. Currently the snippets include one for inserting a 'fold' in emails forwarded to FogBugz and another HTML snippet for highlighting text (usually non-code technical details).
-----Original Message-----
<span style="background-color:WhiteSmoke;border:1px dotted Black"></span>
@kenny-evitt
kenny-evitt / Visual Studio source control "Configure User Tools" dialog field values for Compare It!
Created June 17, 2013 15:56
Visual Studio source control "Configure User Tools" dialog field values for Compare It!
Command:
C:\Program Files (x86)\Compare It!\wincmp3.exe
Arguments:
%1 /=%6 %2 /=%7
@kenny-evitt
kenny-evitt / Generate table of dates from numbers (T-SQL)
Created June 24, 2013 20:11
Generate a temporary table of dates from a 'numbers' table. The minimum 'Number' value in the table dbo.Numbers is 1. The "DATEDIFF(...)" expression removes the time portion of the "GETDATE()" function value.
SELECT NumberedDate = DATEADD( day, DATEDIFF(day, 0, GETDATE()) - Number + 1, 0 )
INTO #lastSixtyDays
FROM dbo.Numbers
WHERE Number < 62;
@kenny-evitt
kenny-evitt / Git commands
Last active May 9, 2017 19:44
Various commands for Git
# Remove a file from the repository, but not the file system; the 'f' option forces the removal; the 'r' option performs a recursive removal (if a directory is specified)
git rm -f -r --cached './Mri.Web.Mvc/DocumentArchiveErrors_*.xls'
# Fix commits (not already pushed to a remote repository); also, see the much more verbose example below
git rebase --interactive $parent_of_flawed_commit
git rebase --interactive flawed_commit_hash^ # Note the '^'
# Change message of last commit; this is only safe is it has not already been pushed to a remote repository
git commit --amend -m "New commit message"
@kenny-evitt
kenny-evitt / gist:9121755
Created February 20, 2014 19:48
NHibernate QueryOver AndRestrictionOn IsIn generated SQL
exec sp_executesql N'SELECT this_.ThingId as ThingId261_0_, this_.SomethingRelatedId as SomethingRelatedId261_0_, this_.Label as Label261_0_, this_.IsAwesome as IsAwesome261_0_, this_.IsAmazing as IsAmazing261_0_, this_.IsCool as IsCool261_0_, this_.FriendlyName as FriendlyName261_0_, this_.TypeId as Ty8_261_0_, this_.StatusId as StatusId9_261_0_, this_.LastUpdatedUserId as LastUpdatedUserId261_0_ FROM Things this_ WHERE this_.ThingId in (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14)',N'@p0 int,@p1 int,@p2 int,@p3 int,@p4 int,@p5 int,@p6 int,@p7 int,@p8 int,@p9 int,@p10 int,@p11 int,@p12 int,@p13 int,@p14 int',@p0=9436,@p1=9411,@p2=8905,@p3=8829,@p4=8803,@p5=8804,@p6=8683,@p7=8930,@p8=10012,@p9=10012,@p10=10012,@p11=8449,@p12=8470,@p13=8461,@p14=8443
@kenny-evitt
kenny-evitt / gist:8e2da026122fbc1825ef
Last active August 29, 2015 14:01
Stack Overflow search for inactive questions with few answers, none of which have been accepted

The following search should return questions tagged sql', with three answers or less, none of which have been accepted, and last active on the specified date.

[sql] answers:..3 lastactive:2014-04-16 hasaccepted:0

@kenny-evitt
kenny-evitt / wrapping-function.clj
Last active August 29, 2015 14:01
Wrapping-function for a function with optional parameters
(defn f [a b & c]
(* a (apply + `(~b ~@c))))
(f 1 2 3) ; -> 5
;; Wrapping the function
(defn wrapping-f [a b & c]
(apply f `(~a ~b ~@c)))