Skip to content

Instantly share code, notes, and snippets.

View manuelnelson's full-sized avatar

Emmanuel Nelson manuelnelson

  • Detroit, Michigan
View GitHub Profile
@manuelnelson
manuelnelson / MiniProfilerHandler.cs
Created May 28, 2012 18:54
Temporary fix to Service Stack Mini Profiler
if (profiler != null)
{
// HACK: unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet,
// so go ahead and add it to the end - it's usually the only id, but if there was a redirect somewhere, it'll be there, too
Profiler.Settings.EnsureStorageStrategy();
var ids = Profiler.Settings.Storage.GetUnviewedIds(profiler.User);
ids.Add(profiler.Id);
path = @"/" + (path ?? "") + EndpointHost.Config.ServiceStackHandlerFactoryPath;
@manuelnelson
manuelnelson / AzureCacheClient.cs
Created May 28, 2012 20:00
Azure Cache Client With Service Stack
using System;
using System.Collections.Generic;
using Elmah;
using Microsoft.ApplicationServer.Caching;
using ServiceStack.CacheAccess;
namespace BusinessLogic
{
public class AzureCacheClient : ICacheClient
{
@manuelnelson
manuelnelson / gist:2821543
Created May 28, 2012 22:53
Example of CORS with SharpGs
/// <summary>
/// Sets the Cross Origin Response Object for a given bucket
/// </summary>
/// <param name="bucket"></param>
private void SetCors(IBucket bucket)
{
ICors cors = new Cors();
cors.AddOrigin("http://yourdomainhere.com");
cors.AddMethod("GET");
cors.MaxAge = 1800;
@manuelnelson
manuelnelson / gist:2945258
Created June 17, 2012 18:15
Modifying and Sending Raw Binary Data in Javascript Example
$('#saveSample').click(function () {
$('#loading').show();
try {
var buffer = getFinalSampleBuffer();
}
catch (ex) {
Mashup.ShowMessage(ex);
return false;
}
@manuelnelson
manuelnelson / PDF.cs
Created October 2, 2012 16:27
Pechkin PDF Print form
public JsonResult PrintForm(string html)
{
try
{
var contentPath = Server.MapPath("~/Content/");
var css = System.IO.File.ReadAllText(Path.Combine(contentPath + "bootstrap.css"));
var fullHtml = string.Format(@"<!DOCTYPE html> <html> <head><style type='text/css'> {0} </style></head><body> {1} </body></html>",css, html);
var config = new ObjectConfig();
config.SetAllowLocalContent(true);
@manuelnelson
manuelnelson / Pechkin
Created December 3, 2012 15:36
Pechkin set content spacing
public ActionResult PrintForm(string html)
{
var globalConfig = new GlobalConfig();
globalConfig.SetPaperSize(PaperKind.Letter);
var margins = new Margins(100, 100, 100, 100);
globalConfig.SetMargins(margins);
var synchronizedPechkin = new SynchronizedPechkin(globalConfig);
var config = new ObjectConfig();
config.SetAllowLocalContent(true)
@manuelnelson
manuelnelson / Pechkin.cs
Created December 3, 2012 15:37
Pechkin set content spacing
public ActionResult PrintForm(string html)
{
var globalConfig = new GlobalConfig();
globalConfig.SetPaperSize(PaperKind.Letter);
var margins = new Margins(100, 100, 100, 100);
globalConfig.SetMargins(margins);
var synchronizedPechkin = new SynchronizedPechkin(globalConfig);
var config = new ObjectConfig();
config.SetAllowLocalContent(true)
We couldn’t find that file to show.