Skip to content

Instantly share code, notes, and snippets.

View jserrao's full-sized avatar
🦍
Swinging from the trees

John Serrao jserrao

🦍
Swinging from the trees
View GitHub Profile
@jserrao
jserrao / jquery-accordion-icon-font.js
Created September 16, 2013 14:39
Doing an accordion with font icons that fade in/out
<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() {
$(this).parent().next().slideDown();
@jserrao
jserrao / file_my_path.php
Created October 20, 2013 20:14
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.
<?php
$my_path = dirname(__FILE__);
echo $my_path;
?>
@jserrao
jserrao / gist:9271692
Created February 28, 2014 14:07
Peakaboo: hide a div
// Target a class and hide it
$( "div" ).parent( ".dont-print-me" ).css( "display", "none" );
@jserrao
jserrao / .htaccess
Created March 27, 2014 15:30
Redirects: example.com to 'www' & 'www' to example.com
# example.com to 'www'
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# 'www' to example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
@jserrao
jserrao / ipad-media-queries.css
Created May 13, 2014 16:03
Media Queries for iPad
/* 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) { }
$('div').html(
function(i,html) {
return html.replace(/(@\w+)/g, '<span>$&</span>');
});​
@jserrao
jserrao / keybase.md
Created March 2, 2015 16:40
Keybase authorization for github

Keybase proof

I hereby claim:

  • I am jserrao on github.
  • I am jserrao (https://keybase.io/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
jserrao / controller-test.js
Created March 6, 2015 01:37
React to a model change inside of controller using $watch (angular.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
jserrao / archive-check.php
Created December 14, 2015 17:25
Conditional Wordpress Archive Check for archive.php
<?php
// A lot of this conditional checking is deprecated now with the_archive_title();
// See how it works here: https://developer.wordpress.org/reference/functions/get_the_archive_title/
// 1- Check for Date Archive
if (is_date() == true) {
}
// 2- Check for Tag Archive
elseif (is_tag() == true) {
}
@jserrao
jserrao / modulus.php
Last active December 17, 2015 11:11
PHP modulus in action
<?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;