Skip to content

Instantly share code, notes, and snippets.

View ronnieoverby's full-sized avatar
🏠
Working from home

Ronnie Overby ronnieoverby

🏠
Working from home
  • Olo
  • Lexington, NC
View GitHub Profile
function AppViewModel(dataModel) {
// Private state
var self = this;
// Private operations
function cleanUpLocation() {
window.location.hash = "";
if (typeof (history.pushState) !== "undefined") {
history.pushState("", document.title, location.pathname);
public interface IFoo
{
[Sql("select 1")]
int GetNumber();
}
public interface IBar
{
public abstract class Testing : DbConnectionWrapper
{
public bool CtorCalled { get; set; }
protected Testing(IDbConnection innerConnection)
: base(innerConnection)
{
CtorCalled = true;
}
}
@ronnieoverby
ronnieoverby / countG.cs
Created September 18, 2014 00:32
Ways to count the occurrences of character 'g' in the string "debugging"
///////////////////////////////////////////
// Method #1
// Uses a for loop and substring
///////////////////////////////////////////
int letterCount = 0;
string strText = "Debugging";
string letter;
for (int i = 0; i < strText.Length; i++)
SELECT [Id], ROW_NUMBER() OVER(ORDER BY (SELECT NULL) [RowNumber]
FROM [Whatever]
@ronnieoverby
ronnieoverby / fizzbuzz.cs
Last active August 29, 2015 14:06
FizzBuzz
/* "Write a program that prints the numbers from 1 to 100.
But for multiples of three print “Fizz” instead of the number
and for the multiples of five print “Buzz”.
For numbers which are multiples of both three and five print “FizzBuzz”." */
Console.Write(string.Join(Environment.NewLine,
from n in Enumerable.Range(1, 100)
let m3 = n % 3 == 0 ? "Fizz" : ""
let m5 = n % 5 == 0 ? "Buzz" : ""
let s = m3 + m5
@ronnieoverby
ronnieoverby / csv.cs
Created September 26, 2014 19:33
Helping someone using CoreTechs.Common Nuget package.
void Main()
{
var filePath = @"C:\Users\roverby\Desktop\New Text Document.txt";
using (var reader = File.OpenText(filePath))
{
// if you can count on your text file being relatively small
// you can buffer the records into memory and use as many times
// as you like
var fileContents_Buffered = reader.ReadCsv().ToArray();
@ronnieoverby
ronnieoverby / accumulator.cs
Created October 7, 2014 22:57
file processing with coretechs.common
string text = @"
FRONT MATTER
FRONT MATTER #2
NAME: Billy B Goode
BIRTHDATE: 5/10/1984
GENDER: Male
MIDDLE MATTER
MIDDLE MATTER #2
[Test]
public async void Sqlite_Orders_And_Returns_DateTimeOffsets_Correctly()
{
using (var db = DatabaseBuilder.BuildDatabase())
{
db.ExecuteSql("CREATE TABLE \"Tests\" (\"Time\" TEXT NOT NULL)");
var later = DateTimeOffset.Parse("10/23/2014 11:35:18 AM -04:00").ToLocalTime();
var earlier = later.AddMinutes(-10).ToUniversalTime();
var ordered = new[] {later, earlier}.OrderBy(x => x);
@ronnieoverby
ronnieoverby / epiphany.cs
Last active August 29, 2015 14:13
Comment after something happens, not before!
public void Write(RecordBase record)
{
if (record == null)
throw new ArgumentNullException("record");
// we have something to write
var spec = Spec.GetRecordSpec(record);
if (spec == null)
throw new UnknownRecordTypeException("Unknown record type: " + record.GetType().FullName);