Skip to content

Instantly share code, notes, and snippets.

@Quinten
Quinten / inline-block-IE
Created April 21, 2011 12:46
inline-block in IE (finally)
li {
display: -moz-inline-stack; /* Firefox 2 */
display: inline-block;
zoom: 1; /* IE hack to trigger hasLayout */
*display: inline; /* IE hack to achieve inline-block behavior */
}
@Quinten
Quinten / shuffle_assoc
Created May 9, 2011 10:59
shuffle an array while preserving keys
<?php
function shuffle_assoc($list) {
if (!is_array($list)) return $list;
$keys = array_keys($list);
shuffle($keys);
$random = array();
foreach ($keys as $key)
$random[$key] = $list[$key];
return $random;
@Quinten
Quinten / object_property_sort
Created May 9, 2011 15:00
sort an array of objects on the values of certain properties in mysql style
// sort an array of objects on the values of certain properties
// Usage: $obj_list = object_property_sort($obj_list, "title ASC");
function object_property_sort($obj_arr, $order_by) {
$sort = explode(" ", $order_by);
$property = $sort[0];
$dir = ($sort[1] == "ASC") ? SORT_ASC : SORT_DESC;
$sort_on_arr = array();
foreach($obj_arr as $key => $object)
$to_sort_arr[(string)$key] = $object->$property;
@Quinten
Quinten / properXML
Created June 6, 2011 13:01
aggressive formatting for xml in php. Seems to solve most of the encoding and html entity problems. experimental
function properXML($str){
//return iconv("UTF-8", "ISO-8859-1//TRANSLIT", preg_replace("/&/", "and", html_entity_decode(strip_tags($str), ENT_COMPAT, 'UTF-8')));
return utf8_encode(preg_replace("/&/", "and", html_entity_decode(strip_tags($str), ENT_COMPAT, 'UTF-8')));
}
@Quinten
Quinten / css triangle tooltip
Last active July 26, 2022 14:35
tooltip triangle on the top of an element in css
#element:before {
content: "";
position: absolute;
width: 0;
height: 0;
border-left: 16px solid transparent;
border-right: 16px solid transparent;
border-bottom: 16px solid #fff;
top: -15px;
left: 27px;
@Quinten
Quinten / css transition and box-shadow
Created June 6, 2013 09:11
float in transition in css (and a good looking boxshadow)
#element {
position: absolute;
top: 102px;
background: #fff;
opacity: 0;
visibility: hidden;
transition-property: top,opacity;
transition-duration: 0.4s;
transition-timing-function: ease-in-out;
-webkit-transition-property: top,opacity;
@Quinten
Quinten / cross-browser opacity
Created June 10, 2013 12:44
cross-browser opacity
#element {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity=30);
-moz-opacity: 0.3;
-khtml-opacity: 0.3;
opacity: 0.3;
}
@Quinten
Quinten / fast js google map
Created June 17, 2013 13:04
implement a google map (js) fast
<div class="contact-map">
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false&amp;language=nl"></script>
<script type="text/javascript">// <![CDATA[
function initialize() {
var myLatlng = new google.maps.LatLng(51.2074746, 3.2263338000000203);
var mapOptions = {
zoom: 16,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
@Quinten
Quinten / jQuery plugin skeleton
Created June 28, 2013 07:52
simple skeleton code to start a jquery plugin
(function( $ ) {
$.fn.pluginSkeleton = function ( options ) {
var settings = $.extend({
option1: "bones",
option2: "skull"
}, options );
return this.each(function() {
@Quinten
Quinten / clear text-password field on focus
Created July 2, 2013 08:01
clear text/password field on focus Every element that needs to clear on focus should have the class clearfocus
jQuery(document).ready(function () {
var $ = jQuery;
$('.clearfocus').each(function( index ) {
if ($(this).attr('type') == 'password') {
var fakeInput = $('<input type="text" />');
fakeInput.val($(this).val()).addClass('input-text').addClass('passclearfocus');
$(this).after(fakeInput);
$(this).hide();