Skip to content

Instantly share code, notes, and snippets.

View ArcticEcho's full-sized avatar
👋
I'll get round to it, eventually.

Sam ArcticEcho

👋
I'll get round to it, eventually.
View GitHub Profile
public static KeyValuePair<string, string> GetLastChatMessage(string html)
{
var startIndex = html.LastIndexOf("username owner", StringComparison.Ordinal);
startIndex = html.IndexOf(">", startIndex, StringComparison.Ordinal) + 1;
// Get username.
var username = html.Substring(startIndex, (html.IndexOf(">", startIndex + 1, StringComparison.Ordinal) - startIndex) - 5);
// Get message.
"<p>I recently upgraded to Yosemite, but I'm not sure if this is a Yosemite-related bug.</p>\r\n\r\n<p>My application folder (/Applications) does not open in finder (see screenshots)\r\nThe spinner keep spinning in the bottom right corner.\r\nAlso, when I \"Get Info\", it keeps calculating the size and never completes.\r\nAlso, when I drag the Applications folder to the dock, nothing happens.</p>\r\n\r\n<p>However, it works fine in Terminal:</p>\r\n\r\n<pre><code>$ cd /; ls -lh\r\ndrwxrwxr-x+ 129 root admin 4.3K Oct 17 03:14 Applications\r\n</code></pre>\r\n\r\n<p>When I go inside the Applications folder (in terminal), I can list all the files in it.Oddly enough, most of them are greyed out, and it only says \"total 8\" when I have way more than 8 apps.</p>\r\n\r\n<pre><code>$ cd /Applications; ls -lh\r\ntotal 8\r\ndrwxr-xr-x 4 root wheel 136B Apr 23 2013 3Hub.app\r\ndrwxr-xr-x@ 4 myusername staff 136B May 20 13:02 Adium.app\r\ndrwxrwxr-x 5 root admin 170B Feb 7 2013 Adobe\r\ndrwxrwxr-x
private static void TestMethod1()
{
var str = new [] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' };
// Remove
var t = new char[20];
for (var i = 0; i < 20; i++)
{
public ReportLog()
{
byte[] uncompBytes;
using (var file = File.OpenRead(path))
using (var compStrm = new GZipStream(file, CompressionMode.Decompress))
{
uncompBytes = new byte[file.Length];
var strm = new MemoryStream();
private unsafe static BigInteger Sqrt(BigInteger num, BigInteger n)
{
var squaresUnder100 = new Dictionary<int, int> { { 1, 1 }, { 2, 4 }, { 3, 9 }, { 4, 16 }, { 5, 25 }, { 6, 36 }, { 7, 49 }, { 8, 64 }, { 9, 81 } };
var pairCount = 0;
var pairs = GetSqrtPairs(num, out pairCount);
// Find the largest integer whose square is smaller than or equal to the current pair.
var pairSq = (BigInteger)1;
foreach (var sq in squaresUnder100)
{
if (latestReview != null && latestReview.AuditPassed == false && (DateTime.UtcNow - latestReviewTimestamp).TotalMinutes > 1)
{
// We can be pretty sure they've been temporarily banned.
endSession();
return;
}
if (sessionReviews.Count + TodaysCVReviews.Count >= (reviewsAvailable > 1000 ? 40 : 20))
{
// They've ran out of reviews.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using ChatExchangeDotNet;
namespace Hatman.Commands
{
class CommandName : ICommand
namespace C_Sharp_Benchmarker
{
class Program
{
private static int testIterations = 10000000;
public static void Main(string[] args)
{
var t1 = Test1();
var t2 = Test2();
var leave = false;
while (someCondition && !leave)
{
System.Threading.Thread.Sleep(500);
Application.Current.Dispatcher.Invoke(new Action(() =>
{
if (someOtherCondition)
{
http://stackoverflow.com/q/9845002
http://stackoverflow.com/q/26027582
http://stackoverflow.com/q/23024960
http://stackoverflow.com/q/15223400
http://stackoverflow.com/q/28342612
http://stackoverflow.com/q/28069000
http://stackoverflow.com/q/14109687
http://stackoverflow.com/q/2167481
http://stackoverflow.com/q/34917422
http://stackoverflow.com/q/32219863