Skip to content

Instantly share code, notes, and snippets.

View hahmed's full-sized avatar

Haroon Ahmed hahmed

View GitHub Profile
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active July 21, 2024 01:20
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@tclem
tclem / libgit2sharp.cs
Created March 28, 2011 16:18
API design thoughts for libgit2sharp
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")) { }
@robashton
robashton / BloatedController.cs
Created June 13, 2011 16:32
Partially Refactored controller
public class ReducedController : Controller
{
private readonly IContainProducts productRepository;
private readonly ISearchForProducts productsIndex;
private readonly IContainCustomers customerRepository;
private readonly IShipProducts productShipper;
private readonly ICoordinateSales salesCatalog;
public ReducedController(
IContainProducts productRepository,
@rcravens
rcravens / msbuilder.py
Created July 19, 2011 19:06
Python Script to Automate MSBuild Tasks
# Generic build script that builds, tests, and creates nuget packages.
#
# INSTRUCTIONS:
# Update the following project paths:
# proj Path to the project file (.csproj)
# test Path to the test project (.csproj)
# nuspec Path to the package definition for NuGet.
#
# delete any of the lines if not applicable
#
@innotekservices
innotekservices / jquery.spin.js
Created October 16, 2011 02:39
jQuery Plugin for Spin.js
/*
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.
@sr
sr / Gemfile
Created December 19, 2011 13:55
Janky on Heroku
source "http://rubygems.org"
gem "janky", "~>0.9"
gem "pg"
gem "thin"
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@dhh
dhh / gist:2643144
Created May 9, 2012 08:57
Coding stats from the new Basecamp
bcx david$ rake stats
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 3704 | 2942 | 72 | 479 | 6 | 4 |
| Helpers | 1901 | 1529 | 13 | 261 | 20 | 3 |
| Models | 5310 | 4116 | 50 | 653 | 13 | 4 |
| Libraries | 2167 | 1593 | 51 | 200 | 3 | 5 |
| Integration tests | 297 | 217 | 6 | 1 | 0 | 215 |
| Functional tests | 3897 | 3065 | 61 | 11 | 0 | 276 |
@foca
foca / wizard.html
Created July 10, 2012 05:12
Wizard navigation in CSS (using Twitter Bootstrap)
<ol class="wizard-nav">
<li class="done"><a href="#">Step 1</a></li>
<li class="done"><a href="#">Step 2</a></li>
<li class="active"><a href="#">Step 3</a></li>
<li><a href="#" data-disabled>Step 4</a></li>
<li><a href="#" data-disabled>Step 5</a></li>
</ol>
@ruslanas
ruslanas / typeahead_with_id.js
Created September 10, 2012 23:26
Typeahead with id
/*
* CakePHP Twitter Bootstrap Typeahead with id
* ProjectsController.php
* <?php $this->set('projects', $this->Project->find('list'); $this->render('list', 'ajax'); ?>
* /app/View/Projects/list.ctp
* <?php echo json_encode($projects); ?>
* data = {'id': 'item name', ..};
* /app/View/Tasks/index.ctp
* <input type="hidden" id="TaskProjectId" name="data[Task][project_id]"/>
* <input autocomplete="off" data-provide="typeahead" class="typeahead" type="search" id="TaskProject">