Skip to content

Instantly share code, notes, and snippets.

View siddarth's full-sized avatar

Siddarth Chandrasekaran siddarth

View GitHub Profile
@siddarth
siddarth / gist:6241382
Created August 15, 2013 14:44
Stripe FX: Getting the converted amount from the BalanceTransaction

Creating a USD charge on a GBP account:

$ curl https://api.stripe.com/v1/charges \
    -u REDACTED: \
    -d amount=400 \
    -d currency=usd \
    -d card[number]=4242424242424242 \
    -d card[exp_month]=04 \
    -d card[exp_year]=16 \

-d card[cvv]=390 \

<!-- example from http://www.w3schools.com/xml/xml_tree.asp -->
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
@siddarth
siddarth / gist:1379745
Created November 20, 2011 02:53 — forked from gdb/gist:1255035
Stripe PHP simple example
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
# H/T: http://stackoverflow.com/questions/6240808/count-line-changes-with-git
git log --stat --author $(git config --get user.email) --since="$(ruby -e "print Time.now - 24*60*60")" --until="now" | awk -F',' '/files? changed/ {
files += $1
insertions += $2
deletions += $3
}
END {
print "Files Changed: " files
print "Insertions: " insertions
require 'rubygems'
require 'sinatra'
get '/anonymous' do
"<html><body><a href='data:text/html;charset=utf-8,<html><script>window.location=\"http://localhost:4567/request\";</script></html>'>Link</a></body></html>"
end
get '/request' do
request.referer.inspect
end
function find(what, current) {
var ret;
if (!current) {
current = window.top;
}
for (var i=0; i < current.frames.length;i++) {
if (current.frames[i].name == what){
return current.frames[i];
}
ret = find(what,current.frames[i]);
@siddarth
siddarth / gist:1379771
Created November 20, 2011 03:32
Stripe PHP simple example with amount
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("STRIPE_API_KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
#include <stdio.h>
#include <glob.h>
#include <unistd.h>
#include <assert.h>
#define PATH_SIZE 1024
#define FD_PATH "/proc/%d/fd/*.*"
int main(int argc, char **argv) {
int pid = getpid();
diff --git a/lib/heliotrope/message.rb b/lib/heliotrope/message.rb
index 5d6fe10..0ff640e 100644
--- a/lib/heliotrope/message.rb
+++ b/lib/heliotrope/message.rb
@@ -172,9 +172,10 @@ private
if part.multipart?
if mime_type_for(part) =~ /multipart\/alternative/
target = part.body.find { |p| mime_type_for(p).index(preferred_type) } || part.body.first
- decode_mime_parts target, preferred_type, level + 1
+ decode_mime_parts target, preferred_type, level + 1 unless target.nil?
$ sudo port install scala
---> Computing dependencies for scala
---> Fetching scala
Error: Please one of the numbered scala* ports instead.
Error: Target org.macports.fetch returned: obsolete port
Error: Status 1 encountered during processing.
Before reporting a bug, first run the command again with the -d flag to get complete output.