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
# rename multiple files in a directory using regex | |
# source: http://stackoverflow.com/questions/5574648/use-regex-powershell-to-rename-files | |
ls | %{ ren $_ $($_.name -replace '(TestFile_\w+)(\d+)(\.txt)', '${1}20140910${3}')} |
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
// fetch "grab this part!" | |
Regex.Match("blah blah (grab this part!)", @"\(([^)]*)\)").Groups[1].Value | |
// source: http://stackoverflow.com/questions/378415/how-do-i-extract-a-string-of-text-that-lies-between-two-parenthesis-using-net |
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
Rect r = EditorGUILayout.BeginVertical(); | |
EditorGUI.ProgressBar(r, 0.1f, "Doing something helpful"); | |
GUILayout.Space(18); | |
EditorGUILayout.EndVertical(); |
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.Runtime.Remoting.Messaging; | |
using System.Threading; | |
// capture the ui thread context for completion callback | |
private SynchronizationContext context = SynchronizationContext.Current; | |
Action action = () => { | |
/* do some stuff */ | |
}; | |
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
from __future__ import print_function | |
import argparse | |
import lxml.etree as ET | |
import urllib | |
parser = argparse.ArgumentParser(description="Transforms and Validates XML") | |
parser.add_argument("--feeds", help="the text file that holds the urls to be validated", default="feeds.txt") | |
parser.add_argument("--log", help="the output log file that reports all errors", default="log.txt") | |
parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true") |
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
' invoke vsvars32.bat. just do it. | |
call "C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat" | |
' temporary environment variables assignment | |
' set ENV_VAR = value | |
' temporary path modification | |
set path=%path%;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE | |
' launch visual studio |
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
#!/bin/bash | |
################################################################################ | |
# Installing Redis on CentOS | |
# with lots of help from: | |
# * https://gist.github.com/coder4web/5762999 | |
# * http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/ | |
# * https://coderwall.com/p/ypo94q | |
# * https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server | |
################################################################################ |
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
enum DaysOfTheWeek { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; | |
var tues = (DaysOfTheWeek)Enum.Parse(typeof(DaysOfTheWeek), "Tuesday"); |
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
from __future__ import print_function | |
import heapq | |
# construct initial collection | |
initial_col = [1, 5, 3, 9, 4] | |
# construct heap | |
heap = [] | |
# assemble the heap, store tuples as such: (original_value, original_index) |
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
private static List<List<T>> GetPermutations<T>(List<T> values) | |
{ | |
if (values.Count <= 1) return new List<List<T>>() { values }; | |
var results = new List<List<T>>(); | |
var perms = GetPermutations(values.Skip(1).ToList()); | |
foreach (var perm in perms) | |
{ |
NewerOlder