Skip to content

Instantly share code, notes, and snippets.

View khalidabuhakmeh's full-sized avatar
👨‍⚖️
talking & listening to developers

Khalid Abuhakmeh khalidabuhakmeh

👨‍⚖️
talking & listening to developers
View GitHub Profile
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;
@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)
{
public var GetPost(string id) {
var post = Db.Posts.Find(id);
return post as IPost;
}
@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)
@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)
// 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 / documentation.cs
Created November 22, 2013 14:10
Documentation Framework that turns your unit tests into documentation. While there are explicit settings below, you would most likely have sensible defaults for titles, section names, and documentation files external to your unit tests.
[Documentation(Section = "Math",
Intro = "addition_intro.md",
Conclusion = "addition_conclusion.md",
Order = 1 )]
public class Addition
{
[Fact]
[Documentation(Title = "Adding Two Numbers", Intro = "adding_two_numbers.md", Order = 1)]
public void Adding_two_numbers()
{
@khalidabuhakmeh
khalidabuhakmeh / gist:8115759
Created December 24, 2013 17:06
Searching Jekyll directory for results
// put this in your browser
https://api.github.com/search/code?q=kotlin+repo:hhariri/hhariri.github.io
// Get a list of JSON results back :)
// Potentially do some JSON / JavaScript magic to show the results and links.
@khalidabuhakmeh
khalidabuhakmeh / gist:9057639
Last active August 29, 2015 13:56
How Read a File From A Line
var username = **YOUR USERNAME**;
var password = **YOUR PASSWORD**;
var url = "http://hackers-endpoint.com?username={0}&password={1}";
var client = new HttpClient();
var response = await client.GetAsync(string.Format(url, username, password));
response.EnsureSuccessStatusCode();
public ActionResult Index() {
return ProgressFlushResult(x => {
x.PartialView("First");
x.PartialView("Second");
x.PartialView("Third");
});
}