Skip to content

Instantly share code, notes, and snippets.

View jtallant's full-sized avatar
:octocat:

Justin Tallant jtallant

:octocat:
View GitHub Profile
@jtallant
jtallant / .htaccess
Created October 8, 2012 10:02
Example WordPress .htaccess
# BEGIN mod headers
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
# END mod headers
# BEGIN compress text, html, javascript, css, xml:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
@jtallant
jtallant / kata2.rb
Created September 23, 2012 20:53
Kata 2
def chop(target, ordered_array)
# Wrap ordered array with an array if it has not been wrapped
ordered_array = [ordered_array, 0] if !ordered_array[0].is_a?(Array)
sub_array = ordered_array[0]
total_sliced_from_left = ordered_array[1]
# no matches found
return -1 if sub_array.empty? || sub_array.size == 1 && sub_array[0] != target
middle = sub_array.size / 2
@jtallant
jtallant / about.md
Created September 23, 2012 00:20 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@jtallant
jtallant / obfuscate.rb
Created September 22, 2012 01:44
Obfuscate words and report frequency
# If this were for purposes of cleaning out
# offensive words it would be easier to just use gsub
# but in this case we want to preserve things like "bigger"
# when searching for "big"
# also the challenge was using an array as the second argument
# where this takes an unlimited number of params. Each param passed
# after the first is a string we want to obfuscate
# Alternative solution below that allows the words param to be
@jtallant
jtallant / automatically-minify-css.php
Created September 17, 2012 02:41
Automatically minify css if it's been updated.
<?php
/**
* Automatically minifies style.css and writes output to style.min.css
*
* @author Justin Tallant
* @param boolean $minification_is_on when true ends execution of the function
* @return void
* @link http://justintallant.com/switching-between-minified-and-non-minified-css-and-js-files-in-wordpress/
*/
@jtallant
jtallant / sample.htaccess.txt
Created September 16, 2012 19:45
Enabling gzip and set expires headers
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
@jtallant
jtallant / installing-node-on-centos.md
Created September 16, 2012 02:57
Installing Node on CentOS

Installing Node on CentOS

Node requires Python 2.6+

python -V make sure that is a capital V

If you are less than 2.6 then you need to install a newer version of Python but don't worry it's easy.

First off you need to recognize yum’s dependency on Python 2.4. Simply replacing this will break your passing semblance of a package manager. We will be using this later so not breaking is the preferred path. Python versions can live in relative harmony together. Download the Python source and untar it to some directory. I use /opt or ~/source for all of my non-native additions. You can choose whatever you want.

@jtallant
jtallant / jt-related-posts.php
Created September 7, 2012 22:26
Related Posts Function for WordPress
@jtallant
jtallant / toggle-development-scripts-and-styles.php
Created September 2, 2012 19:33
Switching between minified and non-minified css and js files in WordPress
<?php
$jt_use_minified_files = true;
add_filter( 'stylesheet_uri', 'child_stylesheet_uri', 10, 2 );
function child_stylesheet_uri($stylesheet_uri, $stylesheet_dir_uri) {
global $jt_use_minified_files;
if ( true == $jt_use_minified_files ) {
@jtallant
jtallant / image-checkbox.html
Created August 31, 2012 03:21
Using an image as a checkbox
<html>
<head>
<title>Checkbox</title>
<style>
input[type=checkbox] {
display:none;
}
#car + label,