A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| /* | |
| Load Sinon.JS in the SpecRunner: | |
| <script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script> | |
| <script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script> | |
| <script type="text/javascript" src="sinon-1.0.0.js"></script> | |
| <script type="text/javascript" src="sinon-ie-1.0.0.js"></script> | |
| http://cjohansen.no/sinon/ | |
| */ |
| # Replace "search" with "replacement" in "input" (all text) | |
| on replace_string(input, search, replacement) | |
| set oldDelim to AppleScript's text item delimiters | |
| set AppleScript's text item delimiters to search | |
| set textItems to every text item of input | |
| set AppleScript's text item delimiters to replacement | |
| set res to textItems as string | |
| set AppleScript's text item delimiters to oldDelim | |
| return res |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
| --- | |
| #### | |
| #### THIS IS OLD AND OUTDATED | |
| #### LIKE, ANSIBLE 1.0 OLD. | |
| #### | |
| #### PROBABLY HIT UP https://docs.ansible.com MY DUDES | |
| #### | |
| #### IF IT BREAKS I'M JUST SOME GUY WITH | |
| #### A DOG, OK, SORRY | |
| #### |
| This playbook has been removed as it is now very outdated. |
| /** | |
| * ``` | |
| * Does JDK8's Optional class satisfy the Monad laws? | |
| * ================================================= | |
| * 1. Left identity: true | |
| * 2. Right identity: true | |
| * 3. Associativity: true | |
| * | |
| * Yes, it does. | |
| * ``` |
| # URI of the local (caching) HTTP proxy | |
| LOCAL_HTTP_PROXY = 'http://192.168.33.200:8123' | |
| # Configures vagrant-cachier and vagrant-proxyconf. | |
| # Should be called only on "local machine" providers. | |
| def configure_caching(config) | |
| if Vagrant.has_plugin?('vagrant-cachier') | |
| config.cache.enable_nfs = true | |
| config.cache.enable :gem | |
| config.cache.enable :npm |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| package benchmark; | |
| import org.openjdk.jmh.annotations.*; | |
| import java.lang.invoke.MethodHandle; | |
| import java.lang.invoke.MethodHandles; | |
| import java.lang.reflect.Field; | |
| import java.lang.reflect.InvocationTargetException; | |
| import java.util.concurrent.TimeUnit; |
| /** | |
| * http://stackoverflow.com/questions/1062113/fastest-way-to-write-huge-data-in-text-file-java | |
| * | |
| * I have to write huge data in text[csv] file. I used BufferedWriter to write the data and it | |
| * took around 40 secs to write 174 mb of data. Is this the fastest speed java can offer? | |
| * bufferedWriter = new BufferedWriter ( new FileWriter ( "fileName.csv" ) ); | |
| * | |
| * You might try removing the BufferedWriter and just using the FileWriter directly. On a modern system | |
| * there's a good chance you're just writing to the drive's cache memory anyway. | |
| * It takes me in the range of 4-5 seconds to write 175MB (4 million strings) -- this is on a dual-core 2.4GHz Dell |