Skip to content

Instantly share code, notes, and snippets.

@rutger1140
rutger1140 / vendor-prefix.css
Created April 15, 2011 12:12
Example of vendor prefix indenting - taken from initializr
aside{
color:white;
padding:20px;
float:right;
width:200px;
background-color:#f16529;
border-bottom:20px solid #e44d26;
margin-bottom:50px;
-webkit-box-shadow:0 0px 40px -10px #AAA;
-moz-box-shadow:0 0px 40px -10px #AAA;
@rutger1140
rutger1140 / placeholder.js
Last active September 25, 2015 12:27 — forked from mrcgrtz/placeholder.js
Adds HTML5 placeholders when they are not supported by your browser. Uses jQuery.
/**
* HTML5 Placeholders for old browsers
* by Rutger Laurman
*
* Adds HTML5 placeholders to non-supported browsers with jQuery
* Fork from Marc Görtz
*/
var HTML5Placeholders;
HTML5Placeholders = {
@rutger1140
rutger1140 / passwordgenerator.php
Created May 25, 2011 10:17
Basic single file password generator
<?php
/**
* Password generator script
* Optimized with help from http://forrst.com/people/nicholasruunu
*/
// Set default number of passwords to generate
$amount = isset($_GET['amount']) ? $_GET['amount'] : 5;
// Set default length
@rutger1140
rutger1140 / curvycorners.js
Created June 9, 2011 12:09
CurvyCorners with IE9 support disabled
/**
* CurvyCorners + IE9 support
* Updated: Check for IE9, since that browser supports border-radius out of the box
*/
function curvyObject(){var a;this.box=arguments[1],this.settings=arguments[0],this.topContainer=this.bottomContainer=this.shell=a=null;var b=this.box.clientWidth;if("canHaveChildren"in this.box&&!this.box.canHaveChildren||this.box.tagName==="TABLE")throw new Error(this.errmsg("You cannot apply corners to "+this.box.tagName+" elements.","Error"));!b&&curvyBrowser.isIE&&(this.box.style.zoom=1,b=this.box.clientWidth),!b&&curvyBrowser.get_style(this.box,"display")==="inline"&&(this.box.style.display="inline-block",curvyCorners.alert(this.errmsg("Converting inline element to inline-block","warning")),b=this.box.clientWidth);if(!b){if(!this.box.parentNode)throw this.newError("box has no parent!");for(a=this.box;;a=a.parentNode){if(!a||a.tagName==="BODY"){this.applyCorners=function(){},curvyCorners.alert(this.errmsg("zero-width box with no accountable parent","warning"));return}if(curvyBrowser.ge
@rutger1140
rutger1140 / convertdb.php
Created June 16, 2011 14:02
Convert MySQL character set and collations to utf8_unicode_ci
<?php
/**
* Convert MySQL tables to utf8_unicode_ci
*/
// Prevent accidental execution
die("Please open and update this file before executing it :)");
// Your connection
mysql_connect("localhost","development","development");
@rutger1140
rutger1140 / activemenu.js
Created September 27, 2011 13:57
An old javascript I used for setting active menu classes (with @ppk his W3CDOM checker)
var W3CDOM = (document.getElementsByTagName && document.createElement);
function init(){
if(!W3CDOM) return;
setActiveMenuItem();
}
function setActiveMenuItem(){
menuobject = document.getElementsByTagName('li');
@rutger1140
rutger1140 / fadein.js
Created November 22, 2011 16:30
Fade in elements with jQuery
/**
* Self-executing callback chain on an arbitrary jQuery object
*/
// Recursively fade in all products
(function shownext(jq){
jq.eq(0).fadeIn("fast", function(){
(jq=jq.slice(1)).length && shownext(jq);
});
})($('#products .product'))
@rutger1140
rutger1140 / printr.php
Last active September 28, 2015 17:47
PHP helper methods for debugging; printr
<?php
/*= PHP helper functions
****************************************************************************/
// Wrapper methods
function printr($r, $s = '') {
return printRecursive($r, array('name'=>$s));
}
/**
* Prints a variable/resource recursively on screen in html pre tag
@rutger1140
rutger1140 / fixedscroll.jquery.js
Created January 5, 2012 12:00
Fix position of element when scrollheight is met
// Make position fixed after scrollheight is met
$(window).scroll(function(e){
var scrollTo = 180;
var scrollClass = '#gf_page_steps_3';
$el = $(scrollClass);
position = $el.position();
if ($(this).scrollTop() > scrollTo && $el.css('position') != 'fixed'){
$(scrollClass).css({'position': 'fixed', 'top': '20px'});
@rutger1140
rutger1140 / fauxconsole.js
Created January 11, 2012 09:58
Faux Console for IE, by Chris Heilmann
/* Faux Console by Chris Heilmann http://wait-till-i.com */
if (!window.console) {
var console = {init: function() {
console.d = document.createElement('div');
document.body.appendChild(console.d);
var a = document.createElement('a');
a.href = 'javascript:console.hide()';
a.innerHTML = 'close';
console.d.appendChild(a);