Skip to content

Instantly share code, notes, and snippets.

Avatar
🍋
Hanging around.

Robert Lemon rlemon

🍋
Hanging around.
View GitHub Profile
View gist:1392389
-- phpMyAdmin SQL Dump
-- version 3.4.5deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 24, 2011 at 04:54 PM
-- Server version: 5.1.58
-- PHP Version: 5.3.6-13ubuntu3.2
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
@rlemon
rlemon / gist:1399198
Created Nov 28, 2011
sql dump from work
View gist:1399198
-- phpMyAdmin SQL Dump
-- version 3.4.5deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 05, 2012 at 04:54 PM
-- Server version: 5.1.58
-- PHP Version: 5.3.6-13ubuntu3.3
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
@rlemon
rlemon / gist:1404876
Created Nov 29, 2011
do not use innerHTML
View gist:1404876
//when you do this:
elem.innerHTML = 'I want to set elem\'s text!';
//you're calling the browser's html parser. why so surprised? innerHTML takes an html string and turns it into DOM elements.
//you can't do that without calling an html parser.
//after the browser is done parsing your (invalid) html, it sees that it only contains text and _assumes_ you just want text and puts it into
//a text node.
//now what? it empties the element out of everything and appends the new text node. it then re-parses, re-flows and re-paints your entire page
// (since your innerHTML call can do many other things, and affect everything else in the page)
View bootstrap.php
class Bootstrap {
function __construct() {
$url = isset($_GET['url']) ? explode('/', rtrim($_GET['url'], '/')) : null;
if( empty($url[0]) ) {
$url[0] = 'index'; // default value
}
@rlemon
rlemon / snippet.php
Created Dec 6, 2011
updateItem method
View snippet.php
public function updateItem($id, $map, $groups) {
$this->updateData('inventory', $id, $map); // I update all the columns in the item table
$dbo = $this->db->exec('DELETE FROM group_item_mapping WHERE item_id = ' . $id); // here is where I remove the group enrollments.
for($i = 0, $l = count($groups); $i < $l; $i++) {
// here I re-add the enrollments for the selected checkbox options.
$this->addData('INSERT INTO group_item_mapping (item_id, group_id) VALUES (:item_id, :group_id)', array( ':item_id' => $id, ':group_id' => $groups[$i] ));
}
}
View gist:1443248
http://stackoverflow.com/a/8417913/829835 [Class vs. ID - Readability]
View gist:1446948
function codeRunner(){
var cb = document.getElementById("checkbox"), ppab = document.getElementById("ppa-box"); // checkbox is used twice, no need to select it twice. Same for ppa-box (referenced three times, called twice)
// Unlock PPA when Checkbox is ticked
cb.onclick = function(){
if(cb.checked){
ppab.disabled=false;
}
else
{
ppab.disabled=true;
View gist:1468750
@Raynos
("textContent" in Element.prototype) || Object.defineProperty(Element.prototype, "textContent", {
get: function () { return this.innerText; },
set: function (v) { this.innerText = v; }
});
@Zirak
var getText = (function () {
var textProp = 'textContent' in document.createElement( 'div' ) ? 'textContent' : 'innerText';
View gist:1468913
// Embed the CSS
function injectCSS(rulez) {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = rulez;
document.head.appendChild(style);
}
// Embed the Script tags
function injectScript(url) {
var script = document.createElement('script');
View gist:1472061
/*
█░░░░░█░░░░░░░░░░░░░░░░░░░░░█░░█░░░░░░░░░░░░░░█▀▀█
█░█▀█░█░░█░█░░█▀█▀█░█▀▀█░█▀▀█░░█▀▀█░█▀▀░█▀▀▀█░░░░█
█░█░█░█░░█░█░░█░█░█░█▀▀█░█░░█░░█░░█░█░░░█░░░█░░▀▀▀
▀░▀▀▀░▀░░▀▀▀░░▀░░░▀░▀░░▀░▀▀▀▀░░▀▀▀▀░▀░░░▀▀▀▀▀░░█░░
*/