Skip to content

Instantly share code, notes, and snippets.

View BaylorRae's full-sized avatar

Baylor Weathers BaylorRae

View GitHub Profile
<?php
// connect to the db
$mysql = new mysqli('localhost', 'root', 'root', 'users');
/*
* This is the "official" object oriented way to do it,
* BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
*/
if ($mysql->connect_error) {
@BaylorRae
BaylorRae / dabblet.css
Created March 7, 2012 16:18
Search Suggestions
/*
Search Suggestions
Original design by Visual Idiot - http://dribbble.com/shots/377281-Search-Suggestions
*/
html {
min-height: 100%;
background: -webkit-linear-gradient(#dbddde, #b6babb);
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
ul {
list-style: none;
}
li {
margin-bottom: 20px;
}
a {
display: block;
@BaylorRae
BaylorRae / doc_block.php
Created July 17, 2012 20:38
Parse PHP Doc Blocks
<?php
class DocBlock {
public $docblock,
$description = null,
$all_params = array();
/**
* Parses a docblock;
@BaylorRae
BaylorRae / version-1.js
Created August 15, 2012 00:53
Create fixed table headers with jQuery
// http://obvcode.blogspot.com/2007/11/easiest-way-to-check-ie-version-with.html
var Browser = {
version: function() {
var version = 999; // we assume a sane browser
if (navigator.appVersion.indexOf("MSIE") != -1) {
// bah, IE again, lets downgrade version number
version = parseFloat(navigator.appVersion.split("MSIE")[1]);
}
return version;
<?php include 'flash.php'; ?>
...
<?php foreach( Flash::$messages as $id => $msg ) : ?>
<div class="flash_<?php echo $id ?>"><?php echo $msg ?></div>
<?php endforeach; ?>
<?php
class Benchmark {
/**
* Creates a loop that lasts for $allowed_time and logs how many
* times a function was able to run
*
* @param string $name the name of the test
* @param function $test the function to run
<ol>
<li>
<a data-notifications="10" class="button" href="#">New Comments on Your Posts</a>
</li>
<li>
<a class="button" href="#">Number of Post Likes :)</a>
</li>
<ol>
def link_to_with_notifications(*args, &block)
# get notification count from hash
notifications = args[2][:notifications] || 0
# create the data- attribute unless notifications.zero?
args[2]['data-notifications'] = notifications unless notifications.zero?
# delete original notifications hash
args[2].delete(:notifications)
<?php for( $i = 0; $i < 9; $i++ ) : ?>
<p><?php echo cycle('one', 'two', 'three') ?></p>
<?php endfor; ?>