Skip to content

Instantly share code, notes, and snippets.

View AlphaGit's full-sized avatar

Alpha AlphaGit

View GitHub Profile
@AlphaGit
AlphaGit / BigArray.cs
Last active May 24, 2017 11:43
BigArray.cs -- Allowing more than Int32.MaxValue elements in an array
namespace SomeLargeDataHolder
{
// adapted from https://blogs.msdn.microsoft.com/joshwil/2005/08/10/bigarrayt-getting-around-the-2gb-array-size-limit/
// Goal: create an array that allows for a number of elements > Int.MaxValue
class BigArray<T>
{
// These need to be const so that the getter/setter get inlined by the JIT into
// calling methods just like with a real array to have any chance of meeting our
// performance goals.
@AlphaGit
AlphaGit / question.markdown
Last active February 13, 2017 02:19
Protractor and Travis, cross-platform scripts

(Note: this post was originally a question in StackOverflow, but has been removed as the question received no answers or activity in over a year, and was deemed an abandoned question.)

Protractor and Travis, cross-platform scripts

"...and other horror stories."

I've been trying for the past few days to get this to work with no luck. As such, I have a long story to tell but I'll break it down to parts so that it is easier to understand.

My goal:

@AlphaGit
AlphaGit / MySingletonClass.cs
Created April 25, 2016 01:42
Typical Singleton Pattern
public class MySingletonClass {
private static MySingletonClass _instance;
// private constructor
private MySingletonClass() { }
// public accessor property that instantiates if needed
public static Instance => _instance ?? (_instance = new MySingletonClass());
}
@AlphaGit
AlphaGit / ConsumerTests.cs
Created March 21, 2016 00:32
Coupled consumer Fakes Aseembly tests
using ClassDependencyTest.Example.Coupled;
using ClassDependencyTest.Example.Coupled.Fakes;
using Microsoft.QualityTools.Testing.Fakes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ClassDependencyTestTests.Example.Coupled
{
[TestClass]
public class ConsumerTests
{
@AlphaGit
AlphaGit / Consumer.cs
Created March 21, 2016 00:16
Decoupled Producer/Consumer, renovating instances
public class Consumer
{
private Type _producerClass;
public Consumer(Type producerClass)
{
if (!typeof (IProducer).IsAssignableFrom(producerClass))
throw new ArgumentException("producerClass must be a IProducer type");
_producerClass = producerClass;
@AlphaGit
AlphaGit / Consumer.cs
Created March 20, 2016 23:44
Decoupled Producer/Consumer classes
public class Consumer {
private IProducer _producer;
// Constructor
public Consumer(IProducer producer) {
_producer = producer;
}
public void DoConsumption() {
var value = _producer.DoProduction();
@AlphaGit
AlphaGit / Consumer.cs
Last active March 20, 2016 23:45
Coupled Producer/Consumer classes
public class Consumer {
public void DoConsumption() {
var producer = new Producer();
var value = producer.DoProduction();
// do something with value
}
}
@AlphaGit
AlphaGit / sum.js
Created January 9, 2016 22:26
Knowledge management
function sum(value1, value2) {
return value1 + value2;
}
sum(2, 2); // 4
sum(0.2, 0.6); // 0.8
sum(0.2, 0.7); // 0.8999999999999999
@AlphaGit
AlphaGit / code.gs
Last active December 17, 2016 21:31
Google Script: automatically logging calendar times to JIRA
function logHoursForToday() {
setDatesToYesterday();
var options = readOptions();
logHours(options);
}
function setDatesToYesterday() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Setup");
// based on https://developers.google.com/adwords/scripts/docs/features/dates#creating_a_date_object_from_a_formatted_date_string
@AlphaGit
AlphaGit / .travis.yml
Last active August 29, 2015 14:26
Configuring Protractor to run on Travis and SauceLabs
language: node_js
sudo: false
cache:
directories:
- node_modules
- bower_components
- $(npm config get prefix)/bin/grunt-cli
- $(npm config get prefix)/bin/bower
node_js:
- 0.10