Skip to content

Instantly share code, notes, and snippets.

View ai7ch's full-sized avatar
:octocat:
Git-tying up some code

ai7ch ai7ch

:octocat:
Git-tying up some code
View GitHub Profile
@ijmccallum
ijmccallum / PHP breadcrumbs
Created April 21, 2014 15:54
PHP breadcrumb fun! Just a really simple way of doing it, if you've got a better way let me know - I'm keen to learn!
<ol class="breadcrumb">
<?php
/*
* This requires a couple of things ot be set:
* $homePath = relative path of the site
* $crumbCut = number of links to ignore in the trail
* See the working version here: http://iainjmccallum.com/guides.php
*/
/*
@pascalpoitras
pascalpoitras / 1.md
Last active May 1, 2025 10:42
My WeeChat configuration

This configuration is not maintained anymore. You should think twice before using it, Breaking change and security issue will likely eventually happens as any abandonned project.

@danharper
danharper / background.js
Last active April 29, 2025 04:09
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@baderj
baderj / gist:7887807
Created December 10, 2013 09:13
Wordpress filter to highlight the menu item labeled "blog" if not on static pages. Add the code to functions.php
/* ------------------------------------------------------------------------ */
/* highlight the menu item labeled "blog" if not on static pages */
function add_custom_class($classes=array(), $menu_item=false) {
if ( !is_page() && 'Blog' == $menu_item->title && ! in_array( 'current-menu-item', $classes ) ) {
$classes[] = 'current-menu-item';
}
return $classes;
}
add_filter('nav_menu_css_class', 'add_custom_class', 100, 2);
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
@kevingessner
kevingessner / parent.htm
Created May 17, 2013 13:09
Detect browser zoom in javascript 'zoom' event is triggered on window on every browser zoom change. No polling!
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
<iframe id="frame" style="width: 250px; border: solid 1px red;" ></iframe>
<script type="text/javascript">
var elFrame = $('#frame')[0];
$(elFrame.contentWindow).resize(function() {
$(window).trigger('zoom');
@jtdp
jtdp / gist:5443297
Last active April 2, 2025 22:15
See changes before pulling from remote git repository
# fetch the changes from the remote
git fetch origin
# show commit logs of changes
git log master..origin/master
# show diffs of changes
git diff master..origin/master
# apply the changes by merge..
@snowman-repos
snowman-repos / gist:3825198
Created October 3, 2012 05:28
JavaScript: Detect Orientation Change on Mobile Devices
// Listen for orientation changes
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
alert(window.orientation);
}, false);
// Listen for resize changes
window.addEventListener("resize", function() {
// Get screen size (inner/outerWidth, inner/outerHeight)
@pwenzel
pwenzel / require_all_helper.php
Created August 23, 2012 17:07
Recursively include all PHP files
<?php
/**
* Scan the api path, recursively including all PHP files
*
* @param string $dir
* @param int $depth (optional)
*/
protected function _require_all($dir, $depth=0) {
if ($depth > $this->max_scan_depth) {
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r