Skip to content

Instantly share code, notes, and snippets.

@lukaskonarovsky
lukaskonarovsky / dynamicarray.cpp
Created April 6, 2009 21:33
C++ dynamic array implementation
#include "dynamicarray.h"
using namespace std;
DynamicArray::DynamicArray() {
DynamicArray::DynamicArray(5);
}
DynamicArray::DynamicArray(int initSize) {
size = initSize;
@bartoszmajsak
bartoszmajsak / prepare-commit-msg.sh
Last active March 20, 2024 08:12
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@afeld
afeld / _body.html.erb
Created December 12, 2011 20:47
using HTML in a RSS feed in Rails
<h1><%= record.name %></h1>
<!-- etc -->
@casidiablo
casidiablo / rails-and-mongo.md
Created December 30, 2011 18:39
Steps to create a Rails application with MongoDb

This document contains the steps to create a mongo-enabled Rails 3.1 application. This is just for personal reference actually.

Create base application

We have to skip the Active Record stuff:

rails new app_name --skip-active-record

Add mongo and bson_ext to the Gemfile

@kyleturner
kyleturner / Remove Submodule
Created January 5, 2012 01:07
How to remove a submodule from a Github project
To remove a submodule you need to:
Delete the relevant line from the .gitmodules file.
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Commit and delete the now untracked submodule files.
@asmallteapot
asmallteapot / nginx.conf
Created March 14, 2012 19:00
My default Nginx configuration for serving Django projects.
# file: /etc/nginx/sites-available/example.com
# nginx configuration for example.com
server {
listen 80;
server_name example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
# pass root to django
@tejinderss
tejinderss / render_to.py
Created October 29, 2012 10:40
render_to decorator for django views
import os
from django.http import HttpResponse
from django.shortcuts import render
from django.utils.functional import wraps
from django.utils import simplejson
def render_to(view=None, template_name=None):
"""
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
@wacko
wacko / gist:5577187
Last active July 13, 2024 00:48
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

@mynameispj
mynameispj / application_helper.rb
Created June 2, 2013 00:24
Rails - Easy "active" classes for menu links in Rails
module ApplicationHelper
def current_class?(test_path)
return 'active' if request.path == test_path
''
end
end