Skip to content

Instantly share code, notes, and snippets.

View albertpak's full-sized avatar

Albert Pak albertpak

View GitHub Profile
$("#frmButtons\\:btnExportWord").click(function (e) {
//track the event
_gaq.push(['_trackEvent', 'Decode', 'Decode copying', 'Export to Word']);
var button = $(this);
//create a delay and call the same click
if (button.data('tracked') != 'true') {
e.preventDefault(); //consume event if not tracked yet
setTimeout( function(){
button.data('tracked', 'true');
jQuery(window).ready(slideshowResize);
jQuery(window).resize(slideshowResize);
//function to resize and center images and slideshow
function slideshowResize() {
//SET CUSTOM VARIABLES
//set ratio value by dividing the images width by it height
//* I usually round this to 2 decmials
var imageRatio = "1.75";
//set containerName equal to the div containing the image or slideshow function will use this div to set height and width so use 100% width or height for responsive demensions
# Avoid annoying ActionController::UnknownHttpMethod exceptions like:
#
# ActionController::UnknownHttpMethod) "CONNECT, accepted HTTP methods are get, head, put, post, delete, and options"
#
# Install this file in app/metal and these requests will receive a 405
# "Method Not Allowed" status and will be logged under `info'.
class IgnoreUnknownHttpMethod
def self.call(env)
[
if ActionController::Request::HTTP_METHODS.include?(env["REQUEST_METHOD"].downcase)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>jeditable + bootstrap datepicker custom type demo</title>
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://raw.github.com/eternicode/bootstrap-datepicker/master/css/datepicker.css">
</head>
<body>
<?php
function display_dynamic_pricing_table(){
global $post;
# see line 42 of woocommerce_pricing_by_product.class.php
$pricing_rule_sets = get_option('_a_category_pricing_rules', array());
$found = false;
if(count($pricing_rule_sets)){
global $woocommerce_pricing;
foreach ($pricing_rule_sets as $pricing_rule_set) {
<?php
date_default_timezone_set('Europe/London'); // Set this to your local timezone - http://www.php.net/manual/en/timezones.php
/**
* The root directory where the repos live.
*
* @var string
*/
$root_dir = '/your/root/dir/';
<?php
//a simple script to check user agents to detemine device type and or redirect
//==============================================
//get userangent string
$userAgentraw = $_SERVER['HTTP_USER_AGENT'];
//convert to lowercase to make search strings simplier
$userAgent = strtolower ( $userAgentraw );

Date

Year

%Y - Year with century (can be negative, 4 digits at least) -0001, 0000, 1995, 2009, 14292, etc.

  • %C - year / 100 (round down. 20 in 2009)
  • %y - year % 100 (00..99)

Sublime Text 2 – Useful Shortcuts (Ubuntu)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command palette
Ctrl+` python console
Ctrl+N new file

Editing

@albertpak
albertpak / gist:8894205
Last active August 29, 2015 13:56 — forked from teejayvanslyke/gist:2569284
Simply paste this snippet into your document ready block to get started, then on any links you'd like to track, simply provide the data-mixpanel-tracker attribute: Specify custom properties in JSON using the data-mixpanel-properties attribute: <a href="/moon" data-mixpanel-tracker="he chose to go to the moon" data-mixpanel-properties="{agency: '…
$('a[data-mixpanel-tracker]').click ->
setTimeout (=> window.location.href = $(@).attr('href')), 300
tracker = $(@).attr('data-mixpanel-tracker')
properties = JSON.parse($(@).attr('data-mixpanel-properties') || '{}')
mixpanel.track tracker, properties
return false