Skip to content

Instantly share code, notes, and snippets.

@namklabs
namklabs / terminus-search-replace.sh
Last active April 1, 2016 14:19 — forked from wpscholar/terminus-search-replace.sh
WP-CLI Search and Replace via Terminus (on Pantheon)
terminus wp "search-replace 'find' 'replace' --dry-run" --site=mysite --env=dev|test|live
@namklabs
namklabs / add-www-alias.sh
Created January 22, 2016 19:51
alias www to your MAMP folder on OS X
echo "alias www='cd ~/Desktop/www;clear;pwd;ls -a'" >> ~/.bash_profile
@namklabs
namklabs / php-process-user.php
Created January 20, 2016 17:00
find username executing PHP process
# http://stackoverflow.com/questions/9557646/php-mkdir-permissions-denied-mac
$processUser = posix_getpwuid(posix_geteuid());
echo($processUser['name']);
@namklabs
namklabs / gist:e1a89c3f80e2e7f9c644
Created July 1, 2015 15:25
Prevent form submission by Enter key (jQuery)
var code = null;
jQuery(window).keypress(function(e){
code = e.which;
});
jQuery('#myform').submit(function(e){
if( code == 13 ){//if Enter is pressed...
code = null;//Reset keycode to allow submission via click.
e.preventDefault();
@namklabs
namklabs / trimText.js
Last active August 29, 2015 14:20 — forked from Edukanezza/trimText.js
// Trim text.
/*
- Respects word boundaries by default (will not chop a word up to create ellipses by default).
- Allows for ellipses or no ellipses.
*/
function trimText( jquery_obj_to_trim, int_trim_length, bool_ellipses, bool_respect_word_boundaries ){
var ellipses;
if( typeof bool_ellipses === "undefined" ){
@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>
@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:
alert(([][[]]+[])[!+[]+!![]+!![]+!![]]+([]
[[]]+[])[+[]]+(!![]+[])[+[]]+([][[]]+[])
[+[]]+([]+{})[!+[]+!![]]+([][[]]+[])[!
+[]+!![]+!![]+!![]+!![]]+(![]+[])[!+[]+!!
[]]+([][[]]+[])[!+[]+!![]+!![]]+([][[]]+[])
[!+[]+!![]+!![]]+(!![]+[])[+[]])
@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>
@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
?>