Skip to content

Instantly share code, notes, and snippets.

@joefearnley
joefearnley / GoogleMap.js
Created February 16, 2010 23:55
GoogleMap constructor
var GoogleMap = (function() {
var instance = null;
function Constructor() {
var mapOpts = getDefaultMapOpts();
var map = new google.maps.Map(document.getElementById("map"), mapOpts);
this.getMap = function() {
return map;
}
}
@joefearnley
joefearnley / PackAscii.cs
Created July 21, 2011 17:30
Convert string to packed ascii byte array
/// <summary>
/// Convert a string to packed ascii byte array
/// </summary>
/// <param name="toBePacked">ascii string to be packed</param>
/// <returns>packed ascii byte array</returns>
public static byte[] PackAscii(string toBePacked)
{
// convert the ascii to a byte array
byte[] ascii = System.Text.Encoding.ASCII.GetBytes(toBePacked.PadRight(8, ' '));
List<byte> packedAscii = new List<byte>();
@joefearnley
joefearnley / gist:1097750
Created July 21, 2011 17:51
Hex string from packed ascii
byte[] packedAscii = PackAscii("JOEY");
for (int i = 0; i < packedAscii.Length; i++)
{
requestData += packedAscii[i].ToString("X").PadLeft(2, '0');
}
"\e[1;5D": backward-word
"\e[1;5C": forward-word
@joefearnley
joefearnley / pdd.cson
Created April 3, 2014 13:57
pre dump die - PHP snippet for Atom editor ported from vim
'.source.php':
'Formatted var_dump':
'prefix': 'pdd'
'body': 'echo \'<pre>\';\nvar_dump($1);\ndie();$0'
@joefearnley
joefearnley / config.json
Created April 8, 2014 19:31
boostrap-config-2
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 60%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#0ebeef",
"@brand-success": "#5cb85c",
"@brand-info": "#5bc0de",
@joefearnley
joefearnley / custom_post_type.php
Last active August 29, 2015 14:02
Create WordPress Custom Post Type
<?php
add_action( 'init', 'create_product_post_type' );
function create_product_post_type() {
register_post_type( 'product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
@joefearnley
joefearnley / filter_search.php
Last active May 29, 2017 12:19
Filter WordPress Search
<?php
function filter_search($query) {
if ( $query->is_search ) {
$query->set('post_type', array( 'post', 'product' ) );
}
return $query;
}
add_filter('pre_get_posts', 'filter_search');
@joefearnley
joefearnley / gist:69dc719882fae816f7e4
Created June 23, 2014 15:48
Add jQuery to WordPress Theme
<?php
if ( !is_admin() ) {
add_action( 'wp_enqueue_scripts', 'si_jquery_enqueue', 10 );
}
@joefearnley
joefearnley / gist:4fee82916c13bf3e98dc
Created June 23, 2014 15:49
Add jQuery to WordPress Theme
<?php
function si_jquery_enqueue() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '3.1.1', true );
}