Skip to content

Instantly share code, notes, and snippets.

@timwco
timwco / gist:9212770
Last active August 29, 2015 13:56
Show/Hide Barley Icon - http://getbarley.com
// Hide the Barley Icon by default
// Show the Barley Icon on ESC Key Press
// Make sure DOM is loaded
document.addEventListener('DOMContentLoaded', function(){
// The Barley Icon Element
var barleybar = document.getElementById('barley-bar');
// Hide By Default
@timwco
timwco / bookmarklet.js
Created November 20, 2014 03:02
Github Repo to Github Pages Website - JavaScript Regex - Bookmarklet
javascript:(function()%7Bvar s%3Dlocation.href%3Bvar r%3D/%5E((http%5Bs%5D%3F%7Cftp):%5C/)%3F%5C/%3F(%5B%5E:%5C/%5Cs%5D%2B)((%5C/%5Cw%2B)*%5C/)(%5B%5Cw%5C-%5C.%5D%2B%5B%5E%23%3F%5Cs%5D%2B)(.*)%3F(%23%5B%5Cw%5C-%5D%2B)%3F%24/g%3Blocation.href%3Ds.replace(r,"http:/%245.github.io/%246")%3B%7D)()%3B
@timwco
timwco / index.html
Last active August 29, 2015 14:21
Calculator Exercise
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
<style type="text/css">
.container { width: 300px; margin: 15px auto;}
</style>
</head>
<body>
@timwco
timwco / prework.md
Created May 24, 2015 22:33
Pre Work

Welcome

Below is part of the information that we usually send out a few weeks befor class starts. Let me know if you have any questions.

Your Workstation

Other than your brain, the most important tool you will use is your workstation. Making sure it is properly set up is extremely important. This is the reason we do the install party. Here are some things you'll need to make sure you have.

  • Macbook Air or Pro running the latest OSX
  • Clean up your machine. Those of you who have not started with a new machine, take some time to clean up your desktop and even your file system if possible.
@timwco
timwco / HTTP Authenticate
Created February 13, 2011 03:20
Authenticate HTTP Request
before_filter :httpauth
private
def httpauth
authenticate_or_request_with_http_basic do |user, password|
user == 'userName' && password == 'crazyLongPassword1234'
end
end
@timwco
timwco / gist:830155
Created February 16, 2011 20:43
Facebook XML - Like Pull
$xml_string = 'http://domain.com/sitemap.xml';
//load the xml string using simplexml
$xml = simplexml_load_file($xml_string);
//loop through the each node of user
$results = array();
foreach($xml->url as $url){
@timwco
timwco / gist:831960
Created February 17, 2011 15:50
Wordpress - Custom Post Loop
<?php $loop = new WP_Query( array( 'post_type' => 'custom_post_type_name', 'posts_per_page' => 100 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="post">
<?php the_post_thumbnail(); ?>
<div class="postInfo">
<h3 class="lgr"><?php the_title() ?></h3>
<a href="<?php the_permalink() ?>">Read More</a>
</div>
</div>
<?php endwhile; ?>
@timwco
timwco / roundedNumber.php
Created March 21, 2011 20:13
Wordpress - Get # of Posts and Round to Nearest Hundred
<?php
function get_rounded_number_of_posts() {
$count_posts = wp_count_posts();
$numposts = $count_posts->publish;
if (strlen($numposts)<3) {
$numposts = $numposts;
} else {
$numposts=substr($numposts, 0, strlen($numposts)-2) . "00";
}
return $numposts;
@timwco
timwco / gist:1008959
Created June 5, 2011 13:27
Wordpress Apply to All Sub Pages
<?php
if ( is_page('about-us') || '3' == $post->post_parent ) {
// Do Something SPECIFIC Here
} else {
// Handle Everything Else Here
}
?>