Skip to content

Instantly share code, notes, and snippets.

View billymoon's full-sized avatar

Billy Moon billymoon

View GitHub Profile
@billymoon
billymoon / ux-logo.svg
Created July 29, 2014 23:46
Alternative variation of UX logo for ux.stackexchange.com
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@billymoon
billymoon / Dream-Team.markdown
Last active October 31, 2015 14:49
A Pen by Billy Moon.
var module = {
exports : {}
}
YUI.add('dlp-jquery-commonjs', function(Y) {
function getFile(url) {
if (window.XMLHttpRequest) {
AJAX=new XMLHttpRequest();
} else {
@billymoon
billymoon / fiddle.js
Created August 10, 2012 01:07
Manipulate the content of HTML strings without changing the HTML
/**
* Manipulate text inside HTML according to passed function
* @param html the html string to manipulate
* @param manipulator the funciton to manipulate with (will be passed single word)
* @returns manipulated string including unmodified HTML
*
* Currently limited in that manipulator operates on words determined by regex
* word boundaries, and must return same length manipulated word
*
*/
CREATE TABLE IF NOT EXISTS `purchases` (`Purchase_ID` int(11), `Datetime` datetime, `Reward_ID` int(11), `Quantity` int(11), `Student_ID` int(11), `Student_Name` varchar(100), `Date_DealtWith` datetime, `Date_Collected` datetime);
DELETE FROM `purchases`;
INSERT INTO `purchases` (`Purchase_ID`, `Datetime`, `Reward_ID`, `Quantity`, `Student_ID`, `Student_Name`, `Date_DealtWith`, `Date_Collected`) VALUES
(1, '2011-09-27 16:55:16', 1, 1, 34240, '', '2011-09-27 16:55:16', '2011-12-12 15:45:43'),
(2, '2011-09-28 13:02:26', 1, 1, 137636, '', '2011-09-27 16:55:16', '2011-09-27 16:55:16'),
(3, '2011-09-29 11:29:09', 1, 1, 137685, '', NULL, NULL),
(4, '2011-09-29 11:29:09', 1, 1, 928734, '', NULL, NULL);
@billymoon
billymoon / php-auth-linux-account.php
Created October 30, 2011 10:34
function to authenticate users from within php against linux user accounts on the server
/* Need to add www-data to group shadow (and restart apache)
$ sudo adduser www-data shadow
$ sudo /etc/init.d/apache2 restart
Needs whois to be installed to run mkpasswd
$ sudo apt-get install whois
Assumes that sha-512 is used in shadow file
*/
function authenticate($user, $pass){
// run shell command to output shadow file, and extract line for $user
@billymoon
billymoon / jquery-hook-issues
Created September 16, 2011 17:00
explaining problems with jQUery hooks
$.hook = function (fns){
fns = typeof fns === 'string' ? fns.split(' ') : $.makeArray(fns);
jQuery.each( fns, function (i, method) {
var old = $.fn[ method ];
if( old && !old.__hookold ){
$.fn[ method ] = function(){
this.triggerHandler('onbefore'+method);
this.triggerHandler('on'+method);
var ret = old.apply(this, arguments);
this.triggerHandler('onafter'+method);