Skip to content

Instantly share code, notes, and snippets.

Swinging from the trees

John Serrao jserrao

Swinging from the trees
View GitHub Profile
jserrao / gist:9271692
Created Feb 28, 2014
Peakaboo: hide a div
View gist:9271692
// Target a class and hide it
$( "div" ).parent( ".dont-print-me" ).css( "display", "none" );
jserrao / .htaccess
Created Mar 27, 2014
Redirects: to 'www' & 'www' to
View .htaccess
# to 'www'
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
# 'www' to
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
jserrao / ipad-media-queries.css
Created May 13, 2014
Media Queries for iPad
View ipad-media-queries.css
/* CSS for iPad in Portrait (includes iPad mini, iPad air, etc) */
@media all and (device-width: 768px) and (device-height: 1024px) and (orientation:portrait) { }
/* CSS for iPad in Landscape (includes iPad mini, iPad air, etc) */
@media all and (device-width: 768px) and (device-height: 1024px) and (orientation:landscape) { }
/* Target Landscape and Portrait iPad in oen call */
@media all and (device-width: 768px) and (device-height: 1024px) and (orientation:portrait), @media all and (device-width: 768px) and (device-height: 1024px) and (orientation:landscape) { }
View twandle.js
function(i,html) {
return html.replace(/(@\w+)/g, '<span>$&</span>');
jserrao /
Created Mar 2, 2015
Keybase authorization for github

Keybase proof

I hereby claim:

  • I am jserrao on github.
  • I am jserrao ( on keybase.
  • I have a public key whose fingerprint is A4BC B0A6 30A5 51D7 6F1F 3A55 9801 75DF 4D20 E14A

To claim this, I am signing this object:

jserrao / controller-test.js
Created Mar 6, 2015
React to a model change inside of controller using $watch (angular.js)
View controller-test.js
// professional.fullName validation, $watch looks at our model
// If our field's value is less than 4, we set the formElementErrorState variable to true
$scope.$watch("professional.fullName", function(newValue, oldValue) {
if ($scope.professional.fullName.length < 4) {
$scope.formElementErrorState = true;
jserrao / archive-check.php
Created Dec 14, 2015
Conditional Wordpress Archive Check for archive.php
View archive-check.php
// A lot of this conditional checking is deprecated now with the_archive_title();
// See how it works here:
// 1- Check for Date Archive
if (is_date() == true) {
// 2- Check for Tag Archive
elseif (is_tag() == true) {
jserrao / modulus.php
Last active Dec 17, 2015
PHP modulus in action
View modulus.php
// % is modulus; it takes $object, divides by 5 and looks at the remainder
// It's a good way to find the nth item in an array for PHP
$object = 20;
// Case 1
// in this case 20/5 = 4.0, making the remainder 0, satisfying the if case
// result: $boo = true
if ($object % 5 == 0) {
$boo = true;
jserrao / jquery-accordion-icon-font.js
Created Sep 16, 2013
Doing an accordion with font icons that fade in/out
View jquery-accordion-icon-font.js
<script type="text/javascript">
(function($) {
//hides all older job panels to start and icons
var allPanels = $('.accordion > ul').hide();
var upIcons = $('.icon-circle-arrow-up').hide();
//.toggle function opens panel, switches icon on first click, closes panel, resets icon on second click
$('.accordion > h3 > a').toggle(
function() {
jserrao / file_my_path.php
Created Oct 20, 2013
Easy way to figure out your server's path to the folder you are in. Just call this file in whatever folder and it will spit out the directory string.
View file_my_path.php
$my_path = dirname(__FILE__);
echo $my_path;