Skip to content

Instantly share code, notes, and snippets.

View philsinatra's full-sized avatar
🤘

Phil Sinatra philsinatra

🤘
View GitHub Profile
@philsinatra
philsinatra / console_log.sublime-snippet
Created August 15, 2013 15:38
Sublime Text snippets
<snippet>
<content><![CDATA[
console.log(${1:log});
]]></content>
<tabTrigger>log</tabTrigger>
<scope>source.js</scope>
</snippet>
@philsinatra
philsinatra / gitignore
Created August 15, 2013 13:43
A git ignore starter file
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.sass-cache
@philsinatra
philsinatra / php_mailer
Created August 15, 2013 12:25
A simple sample of a contact form submission script using PHP Mailer
<?php
require "includes/class.phpmailer.php"; // https://github.com/Synchro/PHPMailer
if (isset($_POST["submit"])) {
$mail = new PHPMailer;
$mail->From = "[email protected]"; // Email address the message will be sent from
$mail->FromName = "My Website Contact Form"; // Name associated with email address being sent from
$mail->AddAddress("[email protected]"); // Email address that will receive the message
$mail->WordWrap = 50;
@philsinatra
philsinatra / subl-pref
Last active December 19, 2015 12:48
Sublime Text 2 Preferences
// Settings
// Option 1: Chrome Dev Tools
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_with_fields": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/Chrome (SL).tmTheme",
@philsinatra
philsinatra / console.log-fallback
Created June 25, 2013 13:43
A fallback for IE8 when console.log commands are used in js debugging. IE8 will display a window.alert rather than an error message.
var alertFallback = true;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
}
else {
console.log = function() {};
@philsinatra
philsinatra / gist:5831744
Last active December 18, 2015 19:19
PHP sample showing how to output the files in a directory.
<?php
// define the directory location
$dir = 'directoryname';
// open the directory
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
// ignore invisible files
if ($entry != '.' && $entry != '..' && $entry != '.DS_Store') {
// build a list of the contents of the directory
@philsinatra
philsinatra / json parse
Created March 12, 2013 16:42
An example of loading and parsing a JSON file with javascript.
<!--
document.json file content =
[
{
"text" : "Video Button",
"type" : "video",
"link" : "http://google.com",
"script" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vestibulum dictum tortor, a tempor justo ultrices vel. Sed posuere mollis augue eget mattis. Nam sit amet elit eu tortor placerat posuere. Proin velit nunc, consectetur eu pharetra eu, posuere ut leo. Aliquam condimentum rutrum libero, non bibendum nisl condimentum eget. Proin et nulla at nibh pellentesque adipiscing. Maecenas dignissim pellentesque lorem, eu feugiat metus pellentesque nec. Sed pellentesque mi vitae tellus fermentum facilisis ac ut nunc. Nulla elementum condimentum quam, vel dignissim metus semper eget. Vestibulum non massa ipsum, ut pellentesque metus. Aenean non libero libero. Integer lobortis, mi vel cursus porta, lorem sapien porta sapien, sit amet dapibus augue enim a ligula. Ut vitae sem quam."
},
@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);
}
@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 / 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>