Skip to content

Instantly share code, notes, and snippets.

View hahmed's full-sized avatar

Haroon Ahmed hahmed

View GitHub Profile
@hahmed
hahmed / sinatra.md
Created October 31, 2015 11:43
Sinatra app on heroku failing...

Gemfile

source "https://rubygems.org"
ruby "2.2.3"

gem 'sinatra'
gem 'thin'

Procfile

@hahmed
hahmed / Ecrion.cs
Last active February 25, 2023 19:41
Ecrion Template rendering
public class LocalTemplateRenderer : ITemplateRenderer
{
public byte[] ToPdf(System.Xml.Linq.XDocument dataStructure, System.IO.Stream template)
{
// Prepare rendering parameters
var _param = new RenderingParameters();
var _output = new OutputInformation();
_param.OutputFormat = Engine.OutputFormat.PDF;
_param.Template = new LocalDocumentTemplate(template, null, Engine.XsltEngine.MSXML, "en_EN", null);
@hahmed
hahmed / gist:8511092
Last active January 3, 2016 19:49
Git stuff
#DangerZone so be sure to "back up" your current work by creating a new branch.
git co org-teams
git branch org-teams-bak
You should have a remote named upstream that points to the original octokit repository. To very, run:
git remote -v
If you don't have a remote named upstream, you can run this command:
git remote add upstream https://github.com/octokit/octokit.net.git
using (var repo = new Repository("path\to\repo.git"))
{
// Object lookup
var obj = repo.Lookup("sha");
var commit = repo.Lookup<Commit>("sha");
var tree = repo.Lookup<Tree>("sha");
var tag = repo.Lookup<Tag>("sha");
// Rev walking
foreach (var c in repo.Commits.Walk("sha")) { }
@hahmed
hahmed / slider.js
Created March 27, 2013 14:59
Slide IT...
function slideIt(current, next) {
var container = $('#slider');
var width = parseInt($('#slider').css('width'));
container.find(current).animate({ 'margin-left': '-' + width + 'px' }, 300, function () {
container.find(current).addClass("hide").css("margin-left", 0);
container.find(next).removeClass("hide");
});
return false;
};
/*
You can now create a spinner using any of the variants below:
$("#el").spin(); // Produces default Spinner using the text color of #el.
$("#el").spin("small"); // Produces a 'small' Spinner using the text color of #el.
$("#el").spin("large", "white"); // Produces a 'large' Spinner in white (or any valid CSS color).
$("#el").spin({ ... }); // Produces a Spinner using your custom settings.
$("#el").spin(false); // Kills the spinner.
@hahmed
hahmed / gist:3792754
Created September 27, 2012 07:55
nhibernate session
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Application["NHSessionFactory"] = CreateSessionFactory();
}
private static ISessionFactory CreateSessionFactory()
{
return Fluently.Configure()
@hahmed
hahmed / gist:3403465
Created August 20, 2012 11:49
interesting query
Map = orders => from order in orders
let lastPayment = order.Payments.LastOrDefault()
select new
{
Query = new object[]
{
order.FirstName,
order.LastName,
order.OrderNumber,
order.Email,
@hahmed
hahmed / gist:2558242
Created April 30, 2012 13:12
word to pdf
public sealed class WordToPdfConverter : IDisposable
{
private readonly MsWordApplication _application = new MsWordApplication {Visible = true};
internal WordToPdfConverter()
{
}
public void Convert(string from, string to)
{
@hahmed
hahmed / gist:2490907
Created April 25, 2012 16:00
col resizer
<script type="text/javascript">
/**
* Author: Rob Audenaerde
*/
function resetTableSizes (table, change, columnIndex)
{
//calculate new width;
var tableId = table.attr('id');
var myWidth = $('#'+tableId+' TR TH').get(columnIndex).offsetWidth;