Skip to content

Instantly share code, notes, and snippets.

View braintreeps's full-sized avatar

Braintree Open Source braintreeps

View GitHub Profile
#
# Finding active subscriptions from a set of transactions returned from a search.
#
found_transactions = Braintree::Transaction.search do |search|
search.type.is "sale"
search.source.is Braintree::Transaction::Source::Recurring
search.status.is "settled"
search.created_at.between 2.days.ago.utc.beginning_of_day, 2.days.ago.utc.end_of_day
end
@braintreeps
braintreeps / BraintreeDropDownList.vb
Created March 1, 2011 15:55
How to subclass a ASP.NET web control to render correctly for transparent redirect.
Public Partial Class WebUserControl1
Inherits System.Web.UI.WebControls.DropDownList
Public Overrides ReadOnly Property UniqueId() As String
Get
Return "credit_card__expiration_month"
End Get
End Property
End Class
@braintreeps
braintreeps / tr_javascript.aspx
Created March 1, 2011 17:21
Using javascript to change the field names for transparent redirect
<script type="text/javascript">
// we want to run this code once the browser is ready and has rendered the DOM.
// If you are using a javascript framework like jquery or prototype, you should
// change this to use the framework-specific event callback.
window.onload = function() {
// customerID, ddlCardType, etc are the names of the controls on your page
// the ClientId property will give you the id on the page, name spaced with
// the master page.
document.getElementById("<%= customerID.ClientId %>").setAttribute("name", "credit_card[number]");
document.getElementById("<%= ddlCardType.ClientId %>").setAttribute("name", "credit_card[card_type]");
@braintreeps
braintreeps / gist:1054689
Created June 29, 2011 19:27
Billing Address on Transaction Create
<h1>Payment: $<%= h @amount %></h1>
<%= form_for :transaction,
:params => @result && @result.params[:transaction],
:builder => ApplicationHelper::BraintreeFormBuilder,
:url => Braintree::TransparentRedirect.url,
:html => {:autocomplete => "off"} do |f| -%>
<% if @result && @result.errors -%>
<div style="color: red;">
diff --git a/app/assets/javascripts/application.js.coffee.erb b/app/assets/javascripts/application.js.coffee.erb
index 1754c77..29574ac 100644
--- a/app/assets/javascripts/application.js.coffee.erb
+++ b/app/assets/javascripts/application.js.coffee.erb
@@ -6,22 +6,26 @@
#
#= require jquery
#= require jquery_ujs
+#= require_self
#= require_tree .
-module(bbp).
-export([len/1]).
-export([reverse/1]).
-export([is_palindrome/1]).
-export([flatten/1]).
-export([distinct/1]).
-export([pack/1]).
len([]) -> 0;
len(L) -> inner_len(L, 0).
-module(bbp_proc).
-compile([export_all]).
% Concurent Proccess Excercises
% http://www.erlang.org/course/exercises.html
% Two-way messenger
init_two_way_messages() ->
Pid1 = spawn(fun two_way_messenger/0),
Pid2 = spawn(fun two_way_messenger/0),
curl -X POST -H "content-type: application/json" http://localhost:8098/mapred --data @-<<\EOF
{
"inputs":"login:development:users",
"query":[
{
"map":{
"language":"javascript",
"source":"function(v) {
return [1];
}
@braintreeps
braintreeps / map.R
Created February 21, 2013 16:48
This is the R code to go along with the blog post "Mapping 35 Million Credit Cards On Top of Census Data With R".
library(data.table);
library(maps);
library(maptools);
library(spatstat);
library(zipcode);
library(GISTools)
#load the zipcode dataset
data(zipcode);
@braintreeps
braintreeps / deploy.rb
Created March 22, 2013 21:35
Modification to capistrano deploy.rb file to call the install_R_packages task after code checkout.
after("deploy:update_code") do
deploy.install_R_packages
end