Skip to content

Instantly share code, notes, and snippets.

Siddarth Chandrasekaran siddarth

Block or report user

Report or block siddarth

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
@siddarth
siddarth / gist:1379745
Created Nov 20, 2011 — forked from gdb/gist:1255035
Stripe PHP simple example
View gist:1379745
<?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");
@siddarth
siddarth / gist:6241382
Created Aug 15, 2013
Stripe FX: Getting the converted amount from the BalanceTransaction
View gist:6241382

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 \
View Workday summary
# 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
View gist:4263997
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
View gist:4151329
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 Nov 20, 2011
Stripe PHP simple example with amount
View gist:1379771
<?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");
View gist:1190828
#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();
View gist:1074432
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?
View scala_installation
$ 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.
View gist:406123
$ port search scala
cassandra @0.6.0 (databases)
A highly scalable, eventually consistent, distributed, structured key-value store.
dspam @3.9.0 (mail, net)
Scalable, open-source statistical anti-spam filter
mkpwd @0.7 (sysutils)
mkpwd is a scalable password generator
You can’t perform that action at this time.