Skip to content

Instantly share code, notes, and snippets.

View braintreeps's full-sized avatar

Braintree Open Source braintreeps

View GitHub Profile
@braintreeps
braintreeps / deferred-client-blog-post-2.html
Created October 28, 2019 21:24
Deferred client blog post 2
<!-- include only the hosted fields script to the page -->
<script src="https://js.braintreegateway.com/web/3.53.0/js/hosted-fields.min.js"></script>
<script>
// pass the authorization directly into Hosted Fields
braintree.hostedFields.create({
authorization: 'client_token_or_tokenization_key'
// the rest of the Hosted Fields configuration goes here
}, function (hostedFieldsErr, hostedFieldsInstance) {
// finish by adding event listeners to trigger tokenization requests on a button click
});
@braintreeps
braintreeps / deferred-client-code-snippet-1.html
Last active October 28, 2019 21:24
Deferred Client Code Snippet 1
<!-- add both the client script and the hosted fields script to the page -->
<script src="https://js.braintreegateway.com/web/3.55.0/js/client.min.js"></script>
<script src="https://js.braintreegateway.com/web/3.55.0/js/hosted-fields.min.js"></script>
<script>
// create the client instance using a client token or tokenization key
braintree.client.create({
authorization: 'client_token_or_tokenization_key'
}, function (clientErr, clientInstance) {
// pass the client instance into the Hosted Fields create method
braintree.hostedFields.create({
mike@rbci:~$ psql -U postgres
psql (9.0.3)
Type "help" for help.
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0';
UPDATE 1
postgres=# \c template0
You are now connected to database "template0".
template0=# update pg_database set datistemplate = FALSE where datname = 'template1';
UPDATE 1
@braintreeps
braintreeps / support.rb
Created March 26, 2013 14:22
Capistrano task for automatically installing a list of R libraries during an automated deployment.
desc "install R packages"
task :install_R_packages do
R_packages = File.read("#{release_path}/R_packages.txt").lines.map { |line| line.strip }
R_package_cmd = R_packages.map do |package|
'if(!require(\"'+package+'\")){ install.packages(\"'+package+'\",lib=c(\"'+shared_path+'/R\"), repos=\"http://cran.cnr.
berkeley.edu/\"); };'
end.join(' ')
sudo "sh -c 'if [ ! -d #{shared_path}/R ]; then mkdir #{shared_path}/R; fi'"
@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
@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);
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];
}
-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),
-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).
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 .