This file contains hidden or 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 IEnumerable<string> GetExecutableFromPaths(string fileName) | |
{ | |
var path = Environment.GetEnvironmentVariable("PATH"); | |
var pathFolders = path.Split(';'); | |
foreach (var folder in pathFolders) | |
{ | |
var fullPath = Path.Combine(folder, fileName); | |
if (File.Exists(fullPath)) | |
yield return fullPath; |
This file contains hidden or 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
// tinypubsub: | |
// https://gist.github.com/cowboy/661855 | |
// code assumes you have shimmed jquery with the correct version in requirejs config: | |
// http://requirejs.org/docs/jquery.html#modulename | |
define(["jquery"], function (jQuery) { | |
var o = jQuery({}); | |
jQuery.subscribe = function () { |
This file contains hidden or 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
// Needs System.Net; | |
// Prefer HttpClient for real situations other than testing | |
void Main() | |
{ | |
while(true) { | |
try { | |
var url = "http://example.com/sub/dir/page.aspx?a=1234&b=something"; | |
var request = (System.Net.HttpWebRequest) System.Net.WebRequest.Create (url); | |
var response = (System.Net.HttpWebResponse)request.GetResponse (); |
This file contains hidden or 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; | |
using System.Threading; | |
namespace Alexw.RunningConsoleApp | |
{ | |
public class Program | |
{ | |
static readonly ManualResetEvent QuitEvent = new ManualResetEvent(false); | |
static void Main(string[] args) |
This file contains hidden or 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
def patiently(&block) | |
cycles = 0 | |
begin | |
yield | |
rescue => e | |
cycles += 1 | |
sleep 0.1 | |
if cycles < 10 | |
retry | |
else |
This file contains hidden or 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
public static class UnixTimestamp | |
{ | |
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
public static double Convert(this DateTime dateTime) | |
{ | |
return dateTime.Subtract(Epoch).TotalMilliseconds; | |
} | |
public static DateTime Convert(this double offset) |
NewerOlder