Slim/Stylus/Coffee
A Pen by Billy Moon on CodePen.
$.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); |
/* 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 |
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); |
/** | |
* 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 | |
* | |
*/ |
var module = { | |
exports : {} | |
} | |
YUI.add('dlp-jquery-commonjs', function(Y) { | |
function getFile(url) { | |
if (window.XMLHttpRequest) { | |
AJAX=new XMLHttpRequest(); | |
} else { |
Slim/Stylus/Coffee
A Pen by Billy Moon on CodePen.
there were 0.6299692264292389 green bottles..! |
// slight discrepency with... | |
// var str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestias veritatis, quis sunt cumque quod, dolorum! Itaque, inventore, sed. Nisi natus illum minima architecto, reprehenderit fugiat repellendus doloremque dolore adipisci aspernatur? suscipit, esse delectus tempora dolor aliquam excepturi, tempore non mollitia eum dolorem quidem eius quasi est, explicabo eos doloremque. Impedit! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo, dolores, perferendis. At perferendis porro quidem in praesentium quia fuga nihil fugiat ratione. Provident, minima labore blanditiis mollitia sit voluptatibus quod."; | |
// wordwrap(str, 60, '\n', 2); | |
// but pretty close to functionally equavalent. | |
function wordwrap(str, intWidth, strBreak, cut) { | |
intWidth = typeof intWidth !== 'undefined' ? intWidth : 75; | |
strBreak = typeof strBreak !== 'undefined' ? strBreak : '\n'; | |
cut = typeof cut !== 'undefined' ? cut : 0; |