Skip to content

Instantly share code, notes, and snippets.

View rlemon's full-sized avatar
🍋
Hanging around.

Robert Lemon rlemon

🍋
Hanging around.
  • Dryer Moisture Systems Inc.
  • Kitchener, Ontario. Canada.
View GitHub Profile
@rlemon
rlemon / gist:1392389
Created November 24, 2011 21:54
sql_dump ssi
-- 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 November 28, 2011 05:18
sql dump from work
-- 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 November 29, 2011 13:59
do not use innerHTML
//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)
@rlemon
rlemon / bootstrap.php
Created December 2, 2011 12:29
bootstrap
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 December 6, 2011 17:44
updateItem method
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] ));
}
}
@rlemon
rlemon / gist:1443248
Created December 7, 2011 15:39
Good Answers
http://stackoverflow.com/a/8417913/829835 [Class vs. ID - Readability]
@rlemon
rlemon / gist:1446948
Created December 8, 2011 13:08
nitstorm
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;
@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';
// 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');
@rlemon
rlemon / gist:1472061
Created December 13, 2011 13:03
u mad bro?
/*
█░░░░░█░░░░░░░░░░░░░░░░░░░░░█░░█░░░░░░░░░░░░░░█▀▀█
█░█▀█░█░░█░█░░█▀█▀█░█▀▀█░█▀▀█░░█▀▀█░█▀▀░█▀▀▀█░░░░█
█░█░█░█░░█░█░░█░█░█░█▀▀█░█░░█░░█░░█░█░░░█░░░█░░▀▀▀
▀░▀▀▀░▀░░▀▀▀░░▀░░░▀░▀░░▀░▀▀▀▀░░▀▀▀▀░▀░░░▀▀▀▀▀░░█░░
*/