Skip to content

Instantly share code, notes, and snippets.

View bwsewell's full-sized avatar

Brian Sewell bwsewell

View GitHub Profile
@bwsewell
bwsewell / app.js
Last active April 5, 2017 16:56
Intro to Firebase Realtime Database
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
};
firebase.initializeApp(config);
var database = firebase.database();
var notesRef = database.ref('notes');
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<STYLE TYPE="text/css">
A:LINK { color: #000000;
font-weight: none;
text-decoration: none; }
A:VISITED { color: #000000;
@bwsewell
bwsewell / events.php
Created December 21, 2013 16:26
Event Listeners in Laravel
<?php
// app/global.php
require app_path().'/events.php';
// app/events.php
Event::listen('student.change', function() {
Cache::forget('query.student.all');
})
// app/models/Student.php
@bwsewell
bwsewell / laravel_appfog.htaccess
Created July 11, 2013 01:15
.htaccess file to use with Laravel on AppFog
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ /public/$1 [L]
@bwsewell
bwsewell / VCAP_SERVICES.php
Created July 11, 2013 01:10
An easy way to grab MySQL environment variables from an AppFog bound service
<?php
$services_json = json_decode(getenv("VCAP_SERVICES"),true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
?>
@bwsewell
bwsewell / double_keystroke.js
Created February 8, 2013 15:22
Capturing a double keystroke with jQuery
// Will fire an alert if user presses the "F" key twice within 300 miliseconds
var dblCtrlKey = 0;
$(document).keydown(function(e) {
if (dblCtrlKey != 0 && e.which == 70) {
alert("Ok double F");
} else {
dblCtrlKey = setTimeout('dblCtrlKey = 0;', 300);
}
});
@bwsewell
bwsewell / appfog-ci-db-confg.php
Created December 12, 2012 15:05
AppFog Codeigniter Database Configuration
<?php
$services_json = json_decode(getenv("VCAP_SERVICES"),true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
$db['default']['hostname'] = $mysql_config['hostname'];
$db['default']['username'] = $mysql_config['user'];
$db['default']['password'] = $mysql_config['password'];
$db['default']['database'] = $mysql_config['name'];
$db['default']['port'] = $mysql_config['port'];
@bwsewell
bwsewell / retina.css
Created October 3, 2012 02:37
CSS for retina display
/* Retina Display */
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-device-pixel-ratio: 2) {
/* YOUR CSS HERE */
}
@bwsewell
bwsewell / rubymotion-userAgent.rb
Created August 23, 2012 13:36
Modify User Agent in RubyMotion
# Modify UserAgent
NSUserDefaults.standardUserDefaults.registerDefaults({UserAgent: "my-custom-user-agent-name"})