Skip to content

Instantly share code, notes, and snippets.

View tiagomatos's full-sized avatar

Tiago Matos tiagomatos

View GitHub Profile
@tiagomatos
tiagomatos / memmory.rb
Created March 18, 2016 17:41
method to output Linux memory use by server thread in an array
def self.memmory(app_name, url)
pid, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$PROCESS_ID}"`.strip.split.map(&:to_i)
size_in_mb = size / 1024.0
{ pid: pid, app: app_name, size: size_in_mb, url: url, server_time: Time.now }
end
@tiagomatos
tiagomatos / gist:11379118
Created April 28, 2014 17:49
Log Jumpseller notifications in PHP
<?
$body = file_get_contents('php://input');
#$data = json_decode($body, true); #decode JSON string.
file_put_contents("jumpseller_posts.txt", date("Y-m-d H:i:s")."\n".$body, FILE_APPEND);
?>
countries:
PT: Portugal
IE: Ireland
GB: UK
CA: Canada
US: United States
AF: Afghanistan
AL: Albania
DZ: Algeria
AS: American Samoa
@tiagomatos
tiagomatos / client_create_invoice_with_tax
Created October 26, 2012 23:33
InvoceXpress Client Create Invoce does not accept item tax.
require 'uri'
require 'net/https'
require 'ostruct'
require 'rubygems'
require 'yaml'
invoicexpressyml ||= YAML.load_file("config/invoicexpress.yml")
invoicexpresscfg = invoicexpressyml["development"]
host = [invoicexpresscfg["screen_name"], invoicexpresscfg["host"]].join(".")
api_key = invoicexpresscfg["api_key"]