Skip to content

Instantly share code, notes, and snippets.

View philsinatra's full-sized avatar
🤘

Phil Sinatra philsinatra

🤘
View GitHub Profile
@philsinatra
philsinatra / consoleLog
Created January 3, 2013 12:59
Javascript function checking for console support. Helpful when there needs to be support for browsers that don't support the console (<=IE8)
function consoleLog(msg) {
if (typeof console !== ‘undefined’) {
console.log(msg);
}
}
@philsinatra
philsinatra / hyphens
Created January 3, 2013 13:02
HTML/CSS Hyphens
body {hyphens: auto;}
code, var, kbd, samp, tt, dir, listing, plaintext, xmp,
abbr, acronym, blockquote, q {hyphens: none;}
@philsinatra
philsinatra / modal
Last active December 10, 2015 13:49
Bootstrap modal html markup
<div class="modal hide" id="<#id#>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">
<#modal-title#>
</h3>
</div>
<div class="modal-body">
<#modal-body#>
</div>
@philsinatra
philsinatra / jquery-target
Created January 3, 2013 13:13
In jQuery event.target always refers to the element that triggered the event, where ‘event’ is the parameter passes to the function. http://docs.jquery.com/Events_(Guide)
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
@philsinatra
philsinatra / find-remove
Created January 4, 2013 15:39
Find and remove files recursively with Terminal
cd to/dir/where/you/want/to/start
find . -type d -name '.svn' -print -exec rm -rf {} \;
@philsinatra
philsinatra / iOS-app-exists-check
Last active December 10, 2015 22:48
iOS check if an app is installed with a fallback event.
function doesAppExist() {
// try to open iOS application
document.location = 'customiosappurl://';
// if above failed, nothing happened
// set a timeout and do something else
!window.document.webkitHidden && setTimeout(function() {
setTimeout(function() {
window.location = '//apple.itunes.com/whatever'
}, 100);
@philsinatra
philsinatra / sb2_fetch
Last active December 12, 2015 09:49
Sublime Text 2 Fetch file list
{
"files":
{
"Dynamic-Carousel": "https://raw.github.com/Wilto/Dynamic-Carousel/master/plugin.js",
"FitText": "https://raw.github.com/davatron5000/FitText.js/master/jquery.fittext.js",
"FitVids": "https://raw.github.com/davatron5000/FitVids.js/master/jquery.fitvids.js",
"backbone": "http://documentcloud.github.com/backbone/backbone.js",
"backbone.min": "http://documentcloud.github.com/backbone/backbone-min.js",
"Eric-Meyer-Reset": "http://meyerweb.com/eric/tools/css/reset/reset.css",
"history": "https://raw.github.com/balupton/history.js/master/scripts/compressed/history.js",
@philsinatra
philsinatra / index.html
Created February 12, 2013 14:57
A CodePen by Phil Sinatra. Insert @ Caret - Insert some html text or in this case an HTML entity at the cursor location in an input.
<div id="symbolsetter">
<table>
<tr>
<td><input type="button" name="sym-copy" onclick="insertSymbol('copy')" value="&copy;" /></td>
</tr>
<tr>
<td><input type="button" name="sym-reg" onclick="insertSymbol('reg')" value="&reg;" /></td>
</tr>
<tr>
<td><input type="button" name="sym-trade" onclick="insertSymbol('trade')" value="&trade;" /></td>
@philsinatra
philsinatra / meta_edit
Created February 12, 2013 16:47
Dynamically edit a meta tag
viewport = document.querySelector("meta[name=viewport]");
viewport.setAttribute('content', 'initial-scale=1.0, user-scalable=no, width=device-width, maximum-scale=1.0');
@philsinatra
philsinatra / Word Press Template Detector
Created February 20, 2013 15:30
http://www.wpmayor.com/wordpress-hacks/output-name-of-wordpress-template-file-being-used/ This is a handy function which I tend to use from time to time when debugging my blogs, it outputs the name of the template file being used to display the current page. Just paste the following into your functions.php file:
add_action('wp_head', 'show_template');
function show_template() {
global $template;
print_r($template);
}