Skip to content

Instantly share code, notes, and snippets.

Cody Caughlan ruckus

Block or report user

Report or block ruckus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ruckus
ruckus / gist:46971c704ee428c6f180
Created Jul 7, 2014
Implementing item_based_expense_line_detail
View gist:46971c704ee428c6f180
diff --git a/lib/quickbooks-ruby.rb b/lib/quickbooks-ruby.rb
index dbf6a6e..51fb518 100644
--- a/lib/quickbooks-ruby.rb
+++ b/lib/quickbooks-ruby.rb
@@ -29,6 +29,7 @@ require 'quickbooks/model/discount_line_detail'
require 'quickbooks/model/discount_override'
require 'quickbooks/model/payment_line_detail'
require 'quickbooks/model/account_based_expense_line_detail'
+require 'quickbooks/model/item_based_expense_line_detail'
require 'quickbooks/model/linked_transaction'
@ruckus
ruckus / Gemfile
Last active Dec 22, 2016
Example controller for a SOAP Endpoint for Quickbooks Web Connector (QWC)
View Gemfile
# QBD Integration
gem "wash_out", "0.9.0"
gem 'qbxml', '~> 0.1.5'
View Summary.md

Summary: if you're posting a form via Content-Type: application/x-www-form-urlencoded then the data attribute itself must be a valid URL-encoded string - it CANNOT be a hash. Angular $http will not convert it to a URL-encoded format (like jQuery does).

When you run this code your cake log will have a line like:

2013-11-12 20:08:50 Error: POST: Array
(
    [name] => scott
    [flavor] => vanilla
)
@ruckus
ruckus / gist:7295501
Created Nov 3, 2013
Monitor PG slave lag
View gist:7295501
-- SELECT * FROM streaming_slave_check()
CREATE OR REPLACE FUNCTION streaming_slave_check() RETURNS TABLE (client_hostname text, client_addr inet, byte_lag float)
LANGUAGE SQL SECURITY DEFINER
AS $$
SELECT
client_hostname,
client_addr,
sent_offset - (replay_offset - (sent_xlog - replay_xlog) * 255 * 16 ^ 6 ) AS byte_lag
FROM (
@ruckus
ruckus / gist:6464900
Created Sep 6, 2013
mod_rewrite rule to block a bare POST /
View gist:6464900
# Block POSTS to /
RewriteBase /
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^$ - [F]
@ruckus
ruckus / gist:5819398
Created Jun 20, 2013
nginx: proxy files from S3. Let's masking the URL by pass Expires timestamp as e and Signature as st. For instance the basis URL is https://yourbucket.s3.amazonaws.com/readme.txt?AWSAccessKeyId=YOURONLYACCESSKEY&Signature=sagw4gsafdhsd&Expires=3453445231 Source: https://coderwall.com/p/rlguog
View gist:5819398
location ~* ^/proxy_private_file/(.*) {
set $s3_bucket 'your_bucket.s3.amazonaws.com';
set $aws_access_key 'AWSAccessKeyId=YOUR_ONLY_ACCESS_KEY';
set $url_expires 'Expires=$arg_e';
set $url_signature 'Signature=$arg_st';
set $url_full '$1?$aws_access_key&$url_expires&$url_signature';
proxy_http_version 1.1;
proxy_set_header Host $s3_bucket;
proxy_set_header Authorization '';
View hstore_accessor.rb
module HstoreAccessor
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def hstore_accessor(hstore_attribute, *keys)
Array(keys).flatten.each do |key|
define_method("#{key}=") do |value|
send("#{hstore_attribute}=", (send(hstore_attribute) || {}).merge(key.to_s => value))
@ruckus
ruckus / statistics.sql
Created Jun 5, 2013
Postgres statistics queries
View statistics.sql
** Find commmonly accessed tables and their use of indexes:
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct;
Returns output like:
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct
----------------------+--------------+---------------+------------------------
schema_migrations | 817 | 0 | 0.00000000000000000000
user_device_photos | 349 | 0 | 0.00000000000000000000
@ruckus
ruckus / RecommendationsController.php
Last active Dec 14, 2015
RecommendationsController example beforeFilter usage
View RecommendationsController.php
<?php
class RecommendationsController extends AppController {
private $recommendation;
private $actions_that_require_a_recommendation = array('show', 'edit');
private $actions_that_require_ownership = array('show', 'edit');
function beforeFilter() {
if (in_array($this->action, $actions_that_require_a_recommendation)) {
View gist:4055780
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
You can’t perform that action at this time.