Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
<html>
<head>
<script type="text/javascript" src="lib/jquery-1.6.2.js"></script>
<script type="text/javascript" src="lib/rx.js"></script>
<script type="text/javascript" src="lib/rx.jQuery.js"></script>
</head>
<body>
<p id="content">Do you still remember the Konami code?</p>
<p id="hint" style="display: none">Up Up Down Down Left Right Left Right b a Enter</p>
</body>
var grouped = input.GroupBy(x => x.Login);
var loginTimes = grouped.Select(x => {
return x.Window(x, _ => Observable.Empty<Unit>().Delay(TimeSpan.FromMinutes(5), sched))
.SelectMany(y => y.Count())
.Select(n => new { Login = x.Key, Times = n });
}).Merge();
loginTimes.Where(x => x.Times > 2)
.Select(x => String.Format("Bad user {0}!", x.Login))
+-----------------------+
| |
| Step 1. Get drunk |
| |
+-----------+-----------+
|
|
| +----------------------+
Administrator@DEMETER ~/Desktop/libgit2-xp-mingw (development|MERGING)
$ ./libgit2_test.exe
Suite "core": ....................
OK (20 tests)
Suite "rawobjects": ................................
OK (32 tests)
Suite "objread": ...........
OK (11 tests)
Suite "objwrite": .......
OK (7 tests)
Module Module1
Sub Main()
"Hello World!"
End Sub
End Module
// Is there a BOM of various kinds? (http://en.wikipedia.org/wiki/Byte_order_mark)
var BOMPatterns = new[]
{
new {Pattern = new byte[] {0xEF, 0xBB, 0xFF}, Encoding = Encoding.UTF8},
new {Pattern = new byte[] {0xFE, 0xFF}, Encoding = Encoding.BigEndianUnicode},
new {Pattern = new byte[] {0xFF, 0xFE}, Encoding = Encoding.Unicode},
new {Pattern = new byte[] {0xFF, 0xFE, 0x00, 0x00}, Encoding = Encoding.UTF32},
new {Pattern = new byte[] {0x2B, 0x2F, 0x76, 0x38}, Encoding = Encoding.UTF7},
new {Pattern = new byte[] {0x2B, 0x2F, 0x76, 0x39}, Encoding = Encoding.UTF7},
new {Pattern = new byte[] {0x2B, 0x2F, 0x76, 0x2B}, Encoding = Encoding.UTF7},
public static void EnsureSetup()
{
// NB: We don't actually care what this method does, it'll just make
// sure the static ctor gets run. Its content is non-empty so the
// optimizer can't nuke it. Tricky!
Console.Write("");
}
Start / Run / gpedit.msc / Local Computer Policy /
Computer Configuration / Administrative Templates /
Windows Components / Windows Update / Re-prompt for restart with scheduled installations
public IObservable<WebResponse> MakeWebRequest(
Uri uri,
Dictionary<string, string> headers = null,
string content = null,
int retries = 3,
TimeSpan? timeout = null)
{
var request = Observable.Defer(() =>
{
var hwr = WebRequest.Create(uri);
IObservable<CacheEntry> downloadUriAndSave(Uri uri, string cacheDirectory, DateTimeOffset? expiration, Dictionary<string, string> headers, string content)
{
var request = Observable.Defer(() =>
{
var hwr = WebRequest.Create(uri);
if (headers != null)
{
headers.ForEach(x => hwr.Headers[x.Key] = x.Value);
}