Skip to content

Instantly share code, notes, and snippets.

View yoni's full-sized avatar

Yoni Ben-Meshulam yoni

View GitHub Profile
@yoni
yoni / rbundler_build_failures.r
Last active August 29, 2015 13:56
Rbundler builds using test(fresh=TRUE) but errors out with test() and check(). See lines 1, 131 and 292 for each of the calls.
> test() # Running test within the R session causes some crazy initialization error. Search for: "Error: 2:1: unexpected input"
Testing rbundler
Loading required package: testthat
Loading rbundler
A developer can bundle a package and it's dependencies. : * installing *source* package 'nodependencies' ...
** help
No man pages found in package 'nodependencies'
*** installing help indices
** building package indices
** testing if installed package can be loaded
@yoni
yoni / gist:9175418
Created February 23, 2014 18:45
rbundler_testthat_0.8_failure
R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin10.8.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
var postVolumes = d3.map(instasound.neighborhoodStats).values().map(function(d) {return d.posts});
var postVolumeScale = d3.scale.linear()
.domain([d3.min(postVolumes), d3.max(postVolumes)])
.range(["black", "red"]);
console.log(postVolumes);
console.log(postVolumes.map(postVolumeScale));
@yoni
yoni / set_asking_prices.js
Last active January 1, 2016 08:19
On Lending Club, the aftermarket (i.e. FolioFn) trading form entry is pretty horrible. This little script allows you to set a discount amount (e.g. 90%) and apply it to all loans' asking prices.
var discount = 0.9; // set this to your own discount policy
var outstanding = document.getElementsByClassName('outstanding-principal-accrued-interest');
var askingPrices = document.getElementsByClassName('asking-price');
Array.prototype.slice.call(outstanding).forEach(
function(entry, i) {
var outstandingAmount = entry.textContent.replace(/[$]/g, "");
var askingPrice = (outstandingAmount * discount).toFixed(2);
askingPrices[i].value = askingPrice;
}
);
@yoni
yoni / convert_camel_to_snake.rb
Created August 14, 2013 02:42
Converts R filenames from camel case to snake case.
#!/usr/bin/env ruby -n
name = $_
if name != name.upcase
puts "mv #{name.chomp} #{name.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase.gsub('.r', '.R').gsub('r/','R/')}"
end
@yoni
yoni / split_lending_club_stats.sh
Created July 22, 2013 04:14
Splits the Lending Club summary file into it's parts
#!/usr/bin/env sh
LENDING_CLUB_FILE=$1
csplit -f LendingClubStats $1 '/^Loans that do not meet the current credit policy/'
@yoni
yoni / rmysql_install_error.R
Created May 10, 2013 17:21
Error installing RMySQL on OS X
R version 2.15.2 (2012-10-26) -- "Trick or Treat"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-apple-darwin9.8.0/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
@yoni
yoni / webm2mp3.sh
Created May 3, 2013 03:32
Extract MP3 audio from all WEBM videos.
find . -name "*.webm" -exec ffmpeg -i {} -vn -ac 2 -ar 44100 -ab 320k -f mp3 {}.mp3 \;
@yoni
yoni / web2mp4.sh
Created May 3, 2013 03:24
Convert all WEBM files to MP4 using ffmpeg.
find . -name "*.webm" -exec ffmpeg -i {} -qscale 0 {}.mp4 \;
@yoni
yoni / gist:3758099
Created September 20, 2012 20:18
Jenkins Template Exception
Status Code: 500
Exception: java.lang.Error: hudson.util.IOException2: Transformation failed. Groovy template didn't produce a well-formed XML:
Stacktrace:
javax.servlet.ServletException: java.lang.Error: hudson.util.IOException2: Transformation failed. Groovy template didn't produce a well-formed XML:
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:616)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)