Some html:
<a id="redLink" class="red link" href="#">Click me!</a>
CSS specifity, low to high:
a { color: red; }
body a { color: red; }
a.red { color: red; }
body a.red { color: red; }
(function($){ | |
$.fn.showFilter = function(selectors, criteria, options) { | |
this.data("lastVal", this.val()); | |
var id = 1; | |
while($(".showFilter"+id).length > 0) id++; | |
this.addClass(".showFilter"+id); | |
var input = this; | |
var filterInput = function(input) { return $.trim(input).toLowerCase().replace(/\s+/, " ") } | |
var test = function() { | |
var c = criteria($(this)); |
(function($){ | |
$.fn.outerHtml = function() { | |
if (this.length == 0) return false; | |
var elem = this[0], name = elem.tagName.toLowerCase(); | |
if (elem.outerHTML) return elem.outerHTML; | |
var attrs = $.map(elem.attributes, function(i) { return i.name+'="'+i.value+'"'; }); | |
return "<"+name+(attrs.length > 0 ? " "+attrs.join(" ") : "")+">"+elem.innerHTML+"</"+name+">"; | |
}; | |
})(jQuery); |
// Limits the number of characters in a textarea and displays characters remaining | |
// Accepts a jQuery element statusElem which displays how many characters are remaining | |
$.fn.textLimiter = function(statusElem, length) { | |
return this.each(function() { | |
var input = $(this); | |
var visible = true; | |
var initial = statusElem.text(); |
public function setSegments($segments) | |
{ | |
$mandango = $this->getMandango(); | |
$segments = array_map(function($name) use ($mandango) { | |
return $mandango->create('Model\Intervention\InterventionSetSegment')->setName($name); | |
}, $segments); | |
$segmentGroup = parent::getSegments(); | |
$segmentGroup->remove($segmentGroup->all()); |
Some html:
<a id="redLink" class="red link" href="#">Click me!</a>
CSS specifity, low to high:
a { color: red; }
body a { color: red; }
a.red { color: red; }
body a.red { color: red; }
<!DOCTYPE html> | |
<html> | |
<head><title>Novalidate bug test</title></head> | |
<style> | |
button { | |
border: 0 background: red; | |
} | |
button span { | |
background: green; | |
} |
Better variable dumping for PHP
debug($variable)
prints html and source code friendly variable informationinspect($variable)
returns the variable information as a stringAssociative arrays are printed as:
{
key: 'value'
'key 2': 'value 2'
# Normally a block is passed after the arguments | |
[1,2,3].map(){ |i| i.next } | |
# & passes the argument as a block | |
[1,2,3].map(&:next) | |
# & arguments are cast to a Proc | |
[1,2,3].map(&:next.to_proc) | |
# Procs are already procs |
How to intercept any request that matches a route (in this case '/admin') in three different languages/frameworks.
var pad = function(string, length, char) { | |
return (new Array(length).join(char[0] || '0') + string).slice(-Math.max(string.toString().length, length)); | |
}; |