Skip to content

Instantly share code, notes, and snippets.

@ruckus
ruckus / gist:46971c704ee428c6f180
Created July 7, 2014 00:13
Implementing item_based_expense_line_detail
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 January 25, 2020 14:27
Example controller for a SOAP Endpoint for Quickbooks Web Connector (QWC)
# QBD Integration
gem "wash_out", "0.9.0"
gem 'qbxml', '~> 0.1.5'
@ruckus
ruckus / Summary.md
Last active December 28, 2015 03:49

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 November 3, 2013 22:15
Monitor PG slave lag
-- 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 September 6, 2013 14:50
mod_rewrite rule to block a bare POST /
# Block POSTS to /
RewriteBase /
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^$ - [F]
@ruckus
ruckus / gist:5819398
Created June 20, 2013 00:36
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
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 '';
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 June 5, 2013 23:26
Postgres statistics queries
** 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 December 14, 2015 19:19
RecommendationsController example beforeFilter usage
<?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)) {
@ruckus
ruckus / gist:4055780
Created November 11, 2012 18:23
Redis config
# 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