Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
static bool IsWindows81OrHigher()
{
var notepad = Environment.ExpandEnvironmentVariables("%SystemRoot%\\Notepad.exe");
var realOsVersion = FileVersionInfo.GetVersionInfo(notepad);
return (new Version(realOsVersion.ProductVersion) >= new Version(6, 3, 0, 0));
}
paul@nyx:~/code/akavache/Akavache% git diff
diff --git a/Akavache/Akavache_Portable.csproj b/Akavache/Akavache_Portable.csproj
index 4ac31be..bc5f97a 100644
--- a/Akavache/Akavache_Portable.csproj
+++ b/Akavache/Akavache_Portable.csproj
@@ -98,12 +98,5 @@
<Target Name="AfterBuild">
</Target>
-->
- <ItemGroup>
@anaisbetts
anaisbetts / AsyncReaderWriterLock.cs
Created March 12, 2014 20:45
Async reader/writer lock via abusing ConcurrentExclusiveSchedulerPair
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
#!/bin/bash
git branch --merged | while read line
do
# If the line is in the format '* master' (indicating the current branch),
# this will be effectively empty, so we don't somehow delete the current
# branch
BRANCH=`echo "$line" | awk -F '*' '{ print $1 }'`
if [ -z "$BRANCH" ]

Keybase proof

I hereby claim:

  • I am paulcbetts on github.
  • I am paulcbetts (https://keybase.io/paulcbetts) on keybase.
  • I have a public key whose fingerprint is 9F9A DB76 3FDF 30D9 DAA2 A8B1 1480 91B1 9A6F C3D5

To claim this, I am signing this object:

require 'active_support'
require 'active_support/time'
require 'active_support/core_ext'
require 'net/http'
require 'mechanize'
a = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
a.get('http://www.loseit.com') do |p|
login = a.click(p.link_with(:text => "Sign In"))
class DataTaskDelegate : NSUrlSessionDataDelegate
{
NSUrlSessionHandler This { get; set; }
public DataTaskDelegate(NSUrlSessionHandler that)
{
this.This = that;
}
public override void DidReceiveChallenge(NSUrlSession session, NSUrlSessionTask task, NSUrlAuthenticationChallenge challenge, Action<NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)

The fly in this soup is, that switching the segmentation registers is actually far more expensive than changing CR3, so an operating system written this way would be quite slow.

This is why the segment registers are rigged in every modern OS to just be the entire valid address space. In fact, on amd64, CS/SS/DS/ES are all hard-coded to be this value. FS and GS are usually abused to do other tricky things - on Windows NT, FS is used as a pointer to the current thread.

diff -r f08c9e9a4709 .nuget/NuGet.targets
--- a/.nuget/NuGet.targets Mon Mar 17 10:22:34 2014 -0400
+++ b/.nuget/NuGet.targets Mon Apr 14 01:48:56 2014 -0700
@@ -10,7 +10,7 @@
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
<!-- Determines if package restore consent is required to restore packages -->
- <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
+ <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">false</RequireRestoreConsent>
#!/usr/bin/env ruby
require 'octokit'
pass_re = /^password: "(.*)"$/
token = '***** GET A TOKEN *****'
c = Octokit::Client.new(:access_token => token)
user_login = c.user.login