Skip to content

Instantly share code, notes, and snippets.

View awithy's full-sized avatar

Adrian Withy awithy

  • Pleasant Hill, CA
View GitHub Profile
public class CecilAssembly : IILAssembly
{
private readonly AssemblyDefinition _assemblyDefinition;
private readonly string _assemblyPath;
public CecilAssembly(string assemblyPath)
{
_assemblyPath = assemblyPath;
_assemblyDefinition = AssemblyDefinition.ReadAssembly(assemblyPath);
}
@awithy
awithy / GcConfigurationXml.cs
Created January 27, 2012 11:17
GcConfigurationXml
<configuration>
<runtime>
<gcConcurrent enabled="false"/>
</runtime>
</configuration>
@awithy
awithy / WorkingSetMemoryIssues.cs
Created January 27, 2012 11:16
WorkingSetMemoryIssues
var workingSet = Environment.WorkingSet;
if (workingSet >= RecycleThresholdBytes)
{
Logger.TraceWarning("Maximum working set exceeded (" + workingSet + "). Role shall now be recycled.");
RoleEnvironment.RequestRecycle();
}
else if(workingSet >= WarningThresholdBytes)
{
ErrorSink.Error("The worker role process has an elevated working set (" + workingSet + ").");
}
@awithy
awithy / ITableStorageService.cs
Created January 26, 2012 17:43
ITableStorageService
public interface ITableStorageService
{
T Get<T>(TableUri tableUri, string partitionKey, string rowKey) where T : TableEntityBase;
void Put<T>(TableUri tableUri, T entity) where T : TableEntityBase;
void CreateTableIfNotExist(TableUri tableUri);
void Delete<T>(TableUri tableUri, string partitionKey, string rowKey) where T : TableEntityBase;
void BulkDelete<T>(TableUri tableUri, string partitionKey, Func<T, bool> entityPredicate) where T : TableEntityBase;
IEnumerable<T> GetAll<T>(TableUri tableUri, string partitionKey) where T : TableEntityBase;
}
@awithy
awithy / IQueueService.cs
Created January 26, 2012 17:42
IQueueService
public interface IQueueService
{
void Enqueue(QueueUri queueUri, string queueMessage);
QueueMessage Dequeue(QueueUri queueUri, TimeSpan visibilityTimeout);
QueueMessage Dequeue(QueueUri queueUri, TimeSpan visibilityTimeout, TimeSpan pollingWaitPeriod);
QueueMessage DequeueNoBlock(QueueUri queueUri, TimeSpan visibilityTimeout);
void DeleteQueueMessage(QueueUri queueUri, QueueMessage queueMessage);
void ClearQueue(QueueUri queueUri);
int GetMessageCount(QueueUri queueUri);
void CreateIfNotExists(QueueUri queueUri);
@awithy
awithy / IBlobStorageService.cs
Created January 26, 2012 17:41
IBlobStorageService
public interface IBlobStorageService
{
void Store(BlobUri blobUri, byte[] data);
void Delete(BlobUri uri);
bool Exists(BlobUri uri);
void BlockUpload(BlobUri uri, string fileToUpload);
void BlockDownload(BlobUri uri, string filePath);
void DownloadPageBlob(BlobUri blobUri, string filePath);
string Download(BlobUri blobUri);
void DeleteContainerIfExists(ContainerUri containerUri);
@awithy
awithy / todownloadablob.cs
Created January 26, 2012 17:39
todownloadablob
var blobUri = new BlobUri(storageAccountName, containerName, blobName);
var downloadPath = Path.Combine(workingDirectory, blobName);
blobStorageService.Download(blobUri, downloadPath);
@awithy
awithy / enqueueingamessage.cs
Created January 26, 2012 17:36
enqueuiing a message
var storageAccountName = "myStorageAccountName";
var queueName = new QueueName("my-queue-name");
var queueMessage = "Hello";
var queueUri = new QueueUri(storageAccountName, queueName);
queueStorageService.Enqueue(queueUri, queueMessage);
@awithy
awithy / azuremsbuildenvvars.ps1
Created January 26, 2012 17:21
Set Azure MSBuild environment variables
> $env:CloudExtensionsDir = PATH_TO_AZURE_MS_BUILD_TASKS
> $env:ServiceHostingSDKInstallDir = PATH_TO_AZURE_SDK_DIR
> $env:ServiceHostingSDKSupport = 7
> $env:ServiceHostingSDKBinDir = PATH_TO_AZURE_SDK_DIR\bin
> $env:_CSPACK_FORCE_NOENCRYPT_=’true’
@awithy
awithy / makecert.cmd
Created January 26, 2012 17:14
makecert
> makecert -r -pe -a sha1 -n “CN=My Certificate Name” -ss My -len 2048 -sp “Microsoft Enhanced RSA and AES Cryptographic Provider” -sy 24 CertificateFilename.cer
> makecert -r -pe -n “CN=My Certificate Name” -sky exchange “CertificateFilename.cer” -sv “CertificateFilename.pvk”
> pvk2pfx -pvk “CertificateFilename.pvk” -spc “CertificateFilename.cer” -pfx “CertificateFilename.pfx” -pi CERTIFICATE_PASSWORD