Skip to content

Instantly share code, notes, and snippets.

View khalidabuhakmeh's full-sized avatar
🎯
Focusing

Khalid Abuhakmeh khalidabuhakmeh

🎯
Focusing
View GitHub Profile
// for loop
var items = new List<Item>();
foreach (var i in existingItems) {
items.Add(new Item(i));
}
// linq statement
var items = existingItems.Select(x => new Item(x)).ToList();
@khalidabuhakmeh
khalidabuhakmeh / commands.cs
Last active December 19, 2015 09:59
Allow you to set properties on a command, before it is executed. This will let you set Query parameters, paging, and etc.
class Program
{
public static Dictionary<Type, object> Stubs = new Dictionary<Type, object>
{
{
typeof (GetUserById), new StubGetUserById(x => new Person { Name = string.Format("{0} {1} {2}", x.FirstName, x.LastName, "Test") } )
}
};
static void Main(string[] args)
@khalidabuhakmeh
khalidabuhakmeh / HelloWorld.fsx
Created June 18, 2013 15:03
Real World Functional Programming Hello World.
open System.Drawing
open System.Windows.Forms
type HelloWindow() =
let frm = new Form(Width = 400, Height = 140)
let fnt = new Font("Time New Roman", 28.0f)
let lbl = new Label(Dock = DockStyle.Fill, Font = fnt, TextAlign = ContentAlignment.MiddleCenter)
do frm.Controls.Add(lbl)
public var GetPost(string id) {
var post = Db.Posts.Find(id);
return post as IPost;
}
@khalidabuhakmeh
khalidabuhakmeh / firebase.cs
Created March 29, 2013 18:20
A possible wrapper for Firebase HTTP api. Not sure about this, but good demo I guess.
using System;
using System.Dynamic;
using System.Text;
namespace Spiffy
{
class Program
{
static void Main(string[] args)
{
using Funq;
using Raven.Client;
using ServiceStack.Authentication.RavenDb;
using ServiceStack.CacheAccess;
using ServiceStack.CacheAccess.Providers;
using ServiceStack.Configuration;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceInterface.Auth;
using ServiceStack.WebHost.Endpoints;
using System;
using EndToEnd.Core;
using FluentAssertions;
using ServiceStack.FluentValidation;
using ServiceStack.ServiceClient.Web;
using ServiceStack.ServiceInterface.Auth;
using Xunit;
namespace EndToEnd
{
using System;
using EndToEnd.Core;
using FluentAssertions;
using ServiceStack.FluentValidation;
using ServiceStack.ServiceClient.Web;
using ServiceStack.ServiceInterface.Auth;
using Xunit;
namespace EndToEnd
{
using System;
using System.Collections.Generic;
namespace RandomScheduler
{
class Program
{
public static Random R = new Random();
static void Main()
// Had to modify the ScriptCs ScriptExecutor to include System.Configuration
// It works as expected to get the appSettings, but not the natural way
// most devs will be used to with ConfigurationManager.AppSettings, also
// not sure if things like SmtpClient will pickup on it.
using System;
using System.Configuration;
var path = Environment.CurrentDirectory + "\\app.config";
Console.WriteLine(path);