Skip to content

Instantly share code, notes, and snippets.

View philsinatra's full-sized avatar
🤘

Phil Sinatra philsinatra

🤘
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / gitignore
Created August 15, 2013 13:43
A git ignore starter file
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.sass-cache
@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 / js-assert
Created August 16, 2013 14:03
Javascript assertion test function.
// Add 'alert' style fallback for console.log commands (IE8)
var alertFallback = true;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
}
else
@philsinatra
philsinatra / speech_recognition
Created September 9, 2013 11:35
Javascript Speech Recognition
r = new webkitSpeechRecognition;
r.continuous = true;
r.interimResults = true;
r.onresult = function(ev) {
console.log(ev.results[ev.results.length-1][0].transcript);
};
r.start()
@philsinatra
philsinatra / htaccess
Created November 11, 2013 18:43
Starter htaccess file
# htaccess starter template
# v20121004 htaccessbook.com/changelog
# Enable mod_rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
# Enable symbolic links
Options +FollowSymLinks