Skip to content

Instantly share code, notes, and snippets.

View aliostad's full-sized avatar
🐒
I may be slow to respond.

Ali Kheyrollahi aliostad

🐒
I may be slow to respond.
View GitHub Profile
Date/Time: 2014-02-13 01:55:04 +0000
OS Version: 10.9 (Build 13A3028)
Architecture: x86_64
Report Version: 18
Event: Sleep Wake Failure
Steps: 44
Hardware model: MacBookPro11,1
Active cpus: 4
public static class CircuitBreakerExtensions
{
/// <summary>
///
/// </summary>
/// <param name="circuit">async work</param>
/// <param name="timeout">it abandons the work if not finished until this timeout</param>
/// <param name="finalTimeout">timeout for when the task runs for final time</param>
/// <param name="tries">number of times to try the work</param>
/// <param name="retryRemedy">after each unscuccessful retry, this will be called and the index will be passed</param>
public interface IConnectionProvider
{
IConnection GetConnection();
}
public class ConnectionProvider : IConnectionProvider
{
private IConnection _connection;
private SortedDictionary<FactoryWrapperScore, IConnectionFactoryWrapper> _stats =
new SortedDictionary<FactoryWrapperScore, IConnectionFactoryWrapper>();
@aliostad
aliostad / elasticsearch snippets.md
Created October 26, 2014 13:06
elasticsearch snippets

Sort and define numbers to return

{
	"query": {"match_all" :{}}
    ,
	"size": 10,
	"sort": { "PubDate":{ "order": "desc" }}
}
@aliostad
aliostad / TableStorageDumper.cs
Created November 26, 2014 15:25
Table Storage Dumper
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
namespace TableStorageDumper
@aliostad
aliostad / es_index_copier
Created December 2, 2014 21:02
Copies an ElasticSearch index between two servers using Bulk method
from __future__ import unicode_literals
import requests
import json
from io import StringIO
from requests.auth import HTTPBasicAuth
import datetime, pytz
def copy_indexes(sourceSearchUrl, destinationBulkUrl, newIndexName=None, newTypeName=None, auth=None):
BatchSize = 40
@aliostad
aliostad / utf8-unicode.cs
Created January 18, 2015 22:36
Turns UTF-8 hex representation of the character to its Unicode code in Little Endian
var hex = "d8a7";
var utf8 = Enumerable.Range(0, hex.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
.ToArray();
var s = Encoding.UTF8.GetString(utf8);
var uni = Encoding.Unicode.GetBytes(s);
Console.WriteLine("0x" + string.Join("", uni.Reverse().Select(x => x.ToString("X"))));
@aliostad
aliostad / App.Config
Last active August 29, 2015 14:15
Tool for benchmarking reads against Azure Table Storage
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
@aliostad
aliostad / rock_acts
Created June 29, 2015 21:22
Most influential Rock acts
The Beatles
Bob Dylan
Black Sabbath
U2
Led Zeppelin
Nirvana (band)
Metallica
Pink Floyd
Neil Young
The Rolling Stones
@aliostad
aliostad / Top 100 Most Influential Rock acts
Created June 29, 2015 22:59
Top 100 Most Influential Rock Figures (Bands/Artists/Producers/Composers)
Top 100 Most Influential Rock figures (according to SNA Betweenness)
====================================================================
U2
Led Zeppelin
Nirvana (band)
Kiss (band)
Emmylou Harris
The Beatles
Beck