Skip to content

Instantly share code, notes, and snippets.

@namklabs
namklabs / equal-height.js
Created February 20, 2014 16:46
jQuery Equal Height
$.fn.equalheight = function( remove ){
if( remove == false ){
$.each( this, function(){
this.css('height','auto');
});
return;
}
// Reset heights from the last viewport resize so that values do not get wacky-large.
@namklabs
namklabs / checkjQuery.js
Created March 4, 2014 14:57
run code to check when jQuery is ready
function checkjQuery() {
if (window.jQuery) {
$(function() {
//your code here
});
} else {
window.setTimeout(checkjQuery, 100);
}
}
checkjQuery();
@namklabs
namklabs / bookmarklet
Created March 5, 2014 00:49
random game from thegamesdb
javascript:window.location="http://thegamesdb.net/game/"+Math.floor(Math.random()*18000);
[
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }
]
@namklabs
namklabs / rgba2hex.js
Created June 19, 2014 18:02
rgb/a color to hex color
// Partial credit for this goes to the broken script I found at http://www.sitepoint.com/jquery-convert-rgb-hex-color/
function rgb2hex(rgb){
rgb = rgb.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*(\d*)\.?(\d*)\s*)?\)$/);
return "#" +
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3],10).toString(16)).slice(-2);
}
@namklabs
namklabs / get_block.php
Created June 26, 2014 22:03
Drupal - get block via PHP on template
# https://www.drupal.org/node/1032068#comment-5633442
<?php
# print render(module_invoke('MODULE_NAME', 'block_view', 'BLOCK_DELTA'));
?>
<?php
print render(module_invoke('search', 'block_view', '1'));
# import the search block anywhere
?>
@namklabs
namklabs / get_view.php
Created June 27, 2014 20:20
Drupal - embed a view via PHP
<div class="focus">
<?php
echo views_embed_view('focus_area', $display_id = 'block');
# from https://www.drupal.org/node/48816#comment-4582424
?>
</div>
alert(([][[]]+[])[!+[]+!![]+!![]+!![]]+([]
[[]]+[])[+[]]+(!![]+[])[+[]]+([][[]]+[])
[+[]]+([]+{})[!+[]+!![]]+([][[]]+[])[!
+[]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!!
[]]+([][[]]+[])[!+[]+!![]+!![]]+([][[]]+[])
[!+[]+!![]+!![]]+(!![]+[])[+[]])
@namklabs
namklabs / query.js
Created January 28, 2015 17:02
URL Get Query String Parameter Arguments JavaScript
//http://stackoverflow.com/a/901144
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Usage:
@namklabs
namklabs / collapse-expand.html
Created April 16, 2015 19:40
Bootstrap Collapse & Expand Buttons
<div class="btn-group pull-right" role="group">
<button class="btn btn-default inline" data-target="#content .panel:not('.in')" data-toggle="collapse" id="info-page-uncollapse-all">Expand All <span class="glyphicon glyphicon-chevron-down">​</span></button>
<button class="btn btn-default" data-target="#content .panel.in" data-toggle="collapse" id="info-page-collapse-all">Collapse All <span class="glyphicon glyphicon-chevron-up">​</span></button>
</div>