Skip to content

Instantly share code, notes, and snippets.

View btompkins's full-sized avatar

Brendan Tompkins btompkins

View GitHub Profile
[ServiceContract]
public class ContactsResource
{
private static int nextId = 1;
[WebInvoke(UriTemplate = "", Method = "POST")]
public JsonValue Post(JsonValue contact)
{
var postedContact = (dynamic)contact;
var contactResponse = (dynamic)new JsonObject();
public class ContactManagerConfiguration : HostConfiguration
{
public override void RegisterRequestProcessorsForOperation( HttpOperationDescription operation,
IList<Processor> processors, MediaTypeProcessorMode mode)
{
processors.Add(new JsonProcessor(operation, mode));
processors.Add(new FormUrlEncodedProcessor(operation, mode));
}
public override void RegisterResponseProcessorsForOperation( HttpOperationDescription operation,
protected void Application_Start(object sender, EventArgs e)
{
var configuration = new ContactManagerConfiguration();
RouteTable.Routes.AddServiceRoute<ContactResource>( “contact“, configuration);
RouteTable.Routes.AddServiceRoute<ContactsResource>( “contacts“, configuration);
}
public class PngProcessor : MediaTypeProcessor
{
public PngProcessor(HttpOperationDescription operation,
MediaTypeProcessorMode mode) : base (operation, mode)
{
}
public override IEnumerable< string > SupportedMediaTypes
{
get
@btompkins
btompkins / Fabric-UserSetup.py
Created February 7, 2011 18:15
Simple fabric function to create a new user
def new_user(admin_username, admin_password):
env.user = 'root'
# Create the admin group and add it to the sudoers file
admin_group = 'admin'
runcmd('addgroup {group}'.format(group=admin_group))
runcmd('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format(
group=admin_group))
# Create the new admin user (default group=username); add to admin group