Skip to content

Instantly share code, notes, and snippets.

@chrismccoy
chrismccoy / gitcheats.txt
Last active November 30, 2025 16:30
git cheats
# alias to edit commit messages without using rebase interactive
# example: git reword commithash message
reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f"
# completely wipe git history
wipe-history = "!f() { git add . && git reset --soft $(git rev-list --max-parents=0 HEAD) && git commit --amend -m \"${1:-sup}\" && git push --force; }; f"
# squash the last N commits
squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
@harshamv
harshamv / url_slug.php
Created January 5, 2013 06:17
Generate URL Slug for CakePHP
// Creates a URL Slug
function _url_slug($string) {
$string = strtolower(trim($string));
$string = preg_replace('/[^a-z0-9-]/', '-', $string);
$string = preg_replace('/-+/', "-", $string);
return $string;
}
// Gets a Unique slug string by checking in the database
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active August 25, 2025 12:52 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@og-shawn-crigger
og-shawn-crigger / ci_uri_info.md
Created April 7, 2012 06:41
CodeIgniter Snippets - How to get Controller, Method and Module name - Router | URI Classes

CodeIgniter - Working with URL Params

Target a Specific Value

$this->uri->segment(n); // n=1 for controller, n=2 for method, etc

Using the Router Class

@og-shawn-crigger
og-shawn-crigger / MY_Config.php
Created October 30, 2011 01:02
Start of reading/writing Config Options From Database
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Config extends CI_Config {
public function database()
{
if (function_exists('get_instance'))
{
$CI =& get_instance();
$query = $CI->db->get('config');