Skip to content

Instantly share code, notes, and snippets.

View pmkhoa's full-sized avatar

Khoa Pham pmkhoa

View GitHub Profile
<?php
//This is a filter to change the default validation message that Gravity Forms generates
add_filter('gform_validation_message', 'change_validation_message', 10, 2);
function change_validation_message($message, $form)
{
return "<div class='validation_error'><strong>Oops!</strong> Looks like there’s something wrong. Please review the form above.</div>";
}
// Often forms in Gravity Forms to need to start with default values and we need to check the form in case the user hasn't entered new data and give them a validation message back
{% comment %}
To add a companion product to the cart automatically if a primary product is in cart:
1. Create a new link list under your Navigation tab.
2. In that link list, make the first link point to companion product.
3. Copy your link list handle where indicated at line 8:
{% endcomment %}
{% assign linklist = linklists['put-your-link-list-handle-here'] %}
{% comment %}
config/initializers/devise.rb :
config.mailer_sender = "mail-to-send@from.com"
config/environments/production.rb :
config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain,
// Dependacies: jQuery, ga.js (Async)
(function($){
$(window).load(function() {
if (this._gat) {
// Set trackers
tks = this._gat._getTrackers();
#!/bin/sh
#
# chkconfig: - 85 15
# Source function library.
. /etc/rc.d/init.d/functions
ROOT="app_path"
USER="user"
ENVIRONMENT="development"
# lib/capistrano/tasks/config_files.cap
#
# Capistrano task to upload configuration files outside SCM
# Jesus Burgos Macia
#
# This allows us to have server's config files isolated from development ones.
# That's useful for several reasons, but the most important is that you can
# ignore files from repository.
#
# The task will upload all files found in

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@pmkhoa
pmkhoa / watermark.rb
Last active August 29, 2015 14:08 — forked from pch/watermark.rb
class User
has_attached_file :photo,
:processors => [:watermark],
:styles => {
:medium => {
:geometry => "300x300>",
:watermark_path => "#{Rails.root}/public/images/watermark.png"
},
:thumb => "100x100>",
}
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast)
(function poll(){
$.ajax({ url: "server", success: function(data){
//Update your dashboard gauge
salesGauge.setValue(data.value);
}, dataType: "json", complete: poll, timeout: 30000 });
})();
@pmkhoa
pmkhoa / pjax.rb
Last active August 29, 2015 14:14 — forked from kazu69/pjax.rb
#encoding: UTF-8
require 'rubygems'
require 'sinatra'
require 'erb'
require 'pp'
class Sinatra::Request
def pjax?
env['HTTP_X_PJAX'] || self['_pjax']