Skip to content

Instantly share code, notes, and snippets.

View andredublin's full-sized avatar
🐝
buzz

Andre Dublin andredublin

🐝
buzz
View GitHub Profile
@andredublin
andredublin / get_files
Created August 27, 2011 05:28
Scans files and adds all files to an array
/**
* Scans folder and adds all folders to array.
*
* @param string $path folder path
* @return array found folders in array
*/
function get_folders($path) {
$folders = scan_dir($path);
$import = array();
foreach ($folders as $folder) {
@andredublin
andredublin / menu hover effect
Created August 31, 2011 19:48
start of selecable menu hover effect, jquery plugin idea
function selectable() {
var arrow = "<div class='arrow'><p>Hey</p></div>";
$('.selectable').css('position','relative');
$(arrow).css('position','absolute');
$('.selectable').append(arrow);
}
selectable();
// starting arrow on the first index
// cache the height of the ul
// the arrow will be centered by the height/2 of the current li
@andredublin
andredublin / whichclick.js
Created September 8, 2011 18:37
Find current item event out of a collection of objects
var objs = document.getElementsByTagName('li');
$(objs).hover(function(event) {
if (this == event.currentTarget) {
console.log('yep');
} else {
console.log('nope');
}
});
$(objs).click(function(event) {
@andredublin
andredublin / newText.js
Created September 13, 2011 17:54
Find text of html element, replace with modified text
function newText(obj, text, classy) {
var hLen = text.length,
firstIdx = text.indexOf(' '),
startStr = text.slice(0, firstIdx),
endStr = text.slice(firstIdx, hLen),
newStr = startStr + '<span class="'+classy+'">' + endStr + '</span>';
$(obj).html(newStr);
}
@andredublin
andredublin / cloud.css
Created October 4, 2011 22:44
Updated animation script
.bkgEnvi {
position: relative;
z-index: 1;
}
.moveCloud {
position: absolute;
top: 10px;
right: 50px;
z-index: 5;
}
@andredublin
andredublin / loopy.php
Created October 4, 2011 23:18
Wordpress loop that assign an associative array to an array then echo json
define('WP_USE_THEMES', false);
require($_SERVER['DOCUMENT_ROOT'] . '/wp-blog-header.php');
header('HTTP/1.1 200 OK');
header('Content-type: application/json;');
$posts = array();
if (have_post()) :
while (have_posts()) :
$posts = the_post();
$posts['id'] = the_ID();
@andredublin
andredublin / data_access_layer.php
Created October 27, 2011 20:57
Usually I have to create custom scripts to respond to ajax
/**
* Define WP_USE_THEMES
*
**/
define('WP_USE_THEMES', false);
require($_SERVER['DOCUMENT_ROOT'] . '/wp-blog-header.php');
header('HTTP/1.1 200 OK');
header('Content-type: application/json;');
@andredublin
andredublin / html5-data.js
Created November 23, 2011 14:46 — forked from remy/html5-data.js
data-* support
(function () {
var forEach = [].forEach,
regex = /^data-(.+)/,
dashChar = /\-([a-z])/ig,
el = document.createElement('div'),
mutationSupported = false,
match
;
function detectMutation() {
@andredublin
andredublin / gist:1441363
Created December 7, 2011 03:46
activerecord rpsec pg error
Failure/Error: Unable to find matching line from backtrace
ActiveRecord::StatementInvalid:
PGError: ERROR: syntax error at or near "IDENTITY"
LINE 1: TRUNCATE TABLE RESTART IDENTITY CASCADE;
^
: TRUNCATE TABLE RESTART IDENTITY CASCADE;
@andredublin
andredublin / gist:1487289
Created December 16, 2011 18:33 — forked from JeffreyWay/gist:1486709
Autosave CSS from Chrome
Autosave from Chrome Notes:
Watch: http://addyosmani.com/blog/autosave-changes-chrome-dev-tools/
Installation Instructions: https://github.com/NV/chrome-devtools-autosave
Afraid of Node? Here's a one-click install: https://sites.google.com/site/nodejsmacosx/
To monitor changes, you have to run `node chrome-devtools-autosave-server/index.js` in the Terminal. This is hard to remember,
so create an alias. Run