Skip to content

Instantly share code, notes, and snippets.

@bhameyie
bhameyie / gist:5666895
Created May 28, 2013 23:22
Person control andoird
public class PersonControl : LinearLayout, IPersonView
{
private Activity m_context;
public PersonControl(Context context)
: base(context)
{
Init(context);
}
public PersonControl(Context context, IAttributeSet attrs)
@bhameyie
bhameyie / gist:5666902
Created May 28, 2013 23:23
Person control layout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:paddingRight="2px"
android:paddingLeft="2px"
android:paddingBottom="2px"
android:paddingTop="2px">
@bhameyie
bhameyie / gist:5679240
Created May 30, 2013 16:29
My Task Catalog
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Linq;
using System.Text;
using OC.SchedulerInterface;
using System.ComponentModel.Composition.Primitives;
@bhameyie
bhameyie / CoffeshopExample.scala
Created June 1, 2013 01:19
Coffeeshop with Scala
import akka.actor.{ActorSystem, Props, Actor, Inbox, ActorRef}
import scala.concurrent.duration._
case class NoSoupForYou
case class OpenShop
case class CloseShop
case class CappucinoRequest
case class TeaRequest
case class Check(amount: Int)
@bhameyie
bhameyie / ModuleSecurity.cs
Created June 17, 2013 01:10
Extension class that helps handle my security needs
public static class ModuleSecurity
{
public static void ShouldBeAuthenticated(this NancyModule module)
{
module.Before.AddItemToEndOfPipeline(ShouldBeAuthenticated);
}
private static Response ShouldBeAuthenticated(NancyContext context)
{
Response response = null;
@bhameyie
bhameyie / SecureModule.cs
Created June 17, 2013 01:12
Base secure Module class for NancyFx
public abstract class SecureModule : NancyModule
{
protected SecureModule():this("")
{
}
protected SecureModule(string path):base(path)
{
this.ShouldBeAuthenticated();
@bhameyie
bhameyie / BloggerModule.cs
Last active December 18, 2015 13:59
A simple Secured Module
public class BloggerModule : SecureModule
{
private readonly IBlogServiceClient m_blogService;
public BloggerModule(IBlogServiceClient blogService)
: base("/blog")
{
m_blogService = blogService;
Get["/{Id}"] = parameters =>
{
@bhameyie
bhameyie / BlogBootstrapper.cs
Last active December 18, 2015 13:59
Simple Blog bootstrapper
public class BlogBootstrapper : AutofacNancyBootstrapper
{
protected override void ApplicationStartup(Autofac.ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
#if DEBUG
StaticConfiguration.DisableErrorTraces = false;
#endif
CookieBasedSessions.Enable(pipelines);
@bhameyie
bhameyie / AccountModule.cs
Created June 17, 2013 01:21
A simple account module to handle logging in and off
public class AccountModule : NancyModule
{
private readonly IAuthenticationServiceClient m_authenticationService;
public AccountModule(IAuthenticationServiceClient authenticationService)
: base("/Account")
{
m_authenticationService = authenticationService;
Post["/Login"] = args =>
{
@bhameyie
bhameyie / LoginFormViewModel.coffee
Last active December 18, 2015 15:08
Using Coffeescript with KnockoutJS
class LoginFormViewModel
constructor: -> #from my many attempts, things works out best when you set them up from the constructor
@email= ko.observable("")
@pass= ko.observable("")
@logon= => #notice the fat arrow here
$.post '/Account/Login',
userId: @email()
password: @pass()
(data) -> $('body').append "Successfully posted to the page."