Skip to content

Instantly share code, notes, and snippets.

@jjmartucci
jjmartucci / gist:fe2b7fd811782fdf1dc2
Created May 16, 2014 18:46
Dump Drupal variables
<?php
print '<pre>';
var_dump(get_defined_vars());
print '</pre>';
?>
@jjmartucci
jjmartucci / gist:1e9d27b4fdab9081092b
Created June 4, 2014 15:02
Clone Git repository into existing folder
git init
git remote add origin PATH/TO/REPO
git fetch
git checkout -t origin/master
@jjmartucci
jjmartucci / SASS Button with Hover State
Created November 13, 2014 18:36
Automatically lighten or darken button on hover given background lightness value.
.button{
@extend %backgroundTransition;
padding: 8px 20px;
text-transform: uppercase;
cursor: pointer;
height: auto;
}
.button-primary{
@jjmartucci
jjmartucci / gist:443461bdd069f308e33a
Created January 29, 2015 15:56
jQuery verify a radio button group has been checked
if (!$("input[name='html_elements']:checked").val()) {
alert('Nothing is checked!');
}
else {
alert('One of the radio buttons is checked!');
}
@jjmartucci
jjmartucci / gist:0b9bd6872259440fc129
Created February 2, 2015 20:03
Sort by DateTime
$arr = array(...);
usort($arr, function($a, $b) {
$ad = new DateTime($a['dateTime']);
$bd = new DateTime($b['dateTime']);
if ($ad == $bd) {
return 0;
}
@jjmartucci
jjmartucci / gist:fce756cdedd6a94b7646
Created February 9, 2015 15:52
Xdebug on Vagrant
zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.idekey = "PHPSTORM"
xdebug.remote_handler = "dbgp"
xdebug.remote_port = 9000
@jjmartucci
jjmartucci / gist:752d1be204fb241ff48a
Created November 5, 2015 14:31
BEM Nested Selectors for Hover State
.photo-of-the-day {
$root: &;
&--title{
font-size: 16px;
}
&:hover{
#{$root}--title {
text-decoration: underline;
}
}
@jjmartucci
jjmartucci / gist:8634125
Created January 26, 2014 15:06
New Google Maps in Responsive Layout
<style>
.google-maps {
position: relative;
padding-bottom: 75%; // This is the aspect ratio
height: 0;
overflow: hidden;
}
.google-maps iframe {
position: absolute;
top: 0;
sudo apt-get install libicu-dev
cd /tmp
# Install depot_tools first (needed for source checkout)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
# Download v8
fetch v8
@jjmartucci
jjmartucci / get-page-by-slug.php
Created June 21, 2016 13:02 — forked from matheuseduardo/get-page-by-slug.php
get_page_by_slug - wordpress
<?php
/**
* Retrieve a page given its slug.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $page_slug Page slug
* @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
* Default OBJECT.
* @param string|array $post_type Optional. Post type or array of post types. Default 'page'.