Skip to content

Instantly share code, notes, and snippets.

@bhameyie
bhameyie / LoginViewModel.html
Created June 18, 2013 02:07
Coffeescript with KnockoutJS part 2
<form class="form-horizontal" method="POST" id="login-form" action="/Account/Login">
<div class="control-group">
<label class="control-label" for="userId">Email</label>
<div class="controls">
<input id="userId" name="userId" data-bind="value: email" type="text" placeholder="Email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="password">Password</label>
<div class="controls">
@bhameyie
bhameyie / Multithread.cs
Last active December 18, 2015 16:59
Simple example on how to spawn and wait for a new thread
var resetEvent = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(
arg =>
{
var task = new MyTaskRunner();
task.Run(data);
resetEvent.Set();
});
@bhameyie
bhameyie / AwsExtensions.cs
Last active December 18, 2015 21:19
File Upload with Url retrieval using AWS S3
public static class AwsExtensions
{
public static string Upload(this AmazonS3 client,UploadImageRequest request)
{
var uploadRequest = new PutObjectRequest { InputStream = request.Image };
uploadRequest.WithBucketName(request.Bucket).WithKey(request.FileIdentifier);
var response = client.PutObject(uploadRequest);
@bhameyie
bhameyie / Restorinator.cs
Last active December 19, 2015 19:48
Restore database from backup with Sql Server
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
public class Restorinator{
@bhameyie
bhameyie / AppHost.cs
Last active December 21, 2015 05:38
Composable Services using Service Stack
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Linq;
using System.Configuration;
using System.Collections.Generic;
using System.Web.Mvc;
using Common;
using ServiceStack.Mvc;
@bhameyie
bhameyie / ModuleExtensions.cs
Last active April 16, 2020 05:05
An extension to render view as string with NancyFx
using System.IO;
using Nancy;
using Nancy.ViewEngines;
namespace Web.Modules
{
public static class ModuleExtensions
{
public static string RenderRazorViewToString(this NancyModule module, string viewName, object model)
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using ServiceStack.ServiceHost;
namespace Common
{
public interface IComposobaleBootstrapper
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Reflection;
using System.Text;
using Common;
using Funq;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
@bhameyie
bhameyie / Build.scala
Last active January 12, 2018 14:45
Casbah tutorial (sort of)
// Add salat and casbah to your build.scala or build.sbt files.
object ElBuild extends Build {
val Organization = "your own"
val Version = "0.0.1-SNAPSHOT"
val ScalaVersion = "2.10.3"
val ScalatraVersion = "2.2.1"
resolvers += "Maven Central Server" at "http://repo1.maven.org/maven2"
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
@bhameyie
bhameyie / gist:8411519
Created January 14, 2014 01:31
Fix for Git error: RPC failed; result=22, HTTP code = 411
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = false
[remote "origin"]
url = https://iamnotyou@bitbucket.org/iamnotyou/le-large-projet.git