julia> foo(x,y) = reshape(collect(Iterators.product(x,y)), :, 1)
foo (generic function with 1 method)
julia> bar(x,y) = [(i,j) for j in y for i in x]
bar (generic function with 1 method)
julia> x = rand(100); y = rand(100);
julia> @btime foo($x,$y);
# start window number from 1 | |
set -g base-index 1 | |
# rebind prefix hot-key from C-b to C-j | |
set -g prefix C-j | |
unbind-key C-b | |
bind-key C-j send-prefix | |
# use vi binding | |
setw -g mode-keys vi |
VendorID | tpep_pickup_datetime | tpep_dropoff_datetime | passenger_count | trip_distance | RatecodeID | store_and_fwd_flag | PULocationID | DOLocationID | payment_type | fare_amount | extra | mta_tax | tip_amount | tolls_amount | improvement_surcharge | total_amount | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 2018-12-01 00:28:22 | 2018-12-01 00:44:07 | 2 | 2.50 | 1 | N | 148 | 234 | 1 | 12 | 0.5 | 0.5 | 3.95 | 0 | 0.3 | 17.25 | |
1 | 2018-12-01 00:52:29 | 2018-12-01 01:11:37 | 3 | 2.30 | 1 | N | 170 | 144 | 1 | 13 | 0.5 | 0.5 | 2.85 | 0 | 0.3 | 17.15 | |
2 | 2018-12-01 00:12:52 | 2018-12-01 00:36:23 | 1 | .00 | 1 | N | 113 | 193 | 2 | 2.5 | 0.5 | 0.5 | 0 | 0 | 0.3 | 3.8 | |
1 | 2018-12-01 00:35:08 | 2018-12-01 00:43:11 | 1 | 3.90 | 1 | N | 95 | 92 | 1 | 12.5 | 0.5 | 0.5 | 2.75 | 0 | 0.3 | 16.55 | |
1 | 2018-12-01 00:21:54 | 2018-12-01 01:15:13 | 1 | 12.80 | 1 | N | 163 | 228 | 1 | 45 | 0.5 | 0.5 | 9.25 | 0 | 0.3 | 55.55 | |
1 | 2018-12-01 00:00:38 | 2018-12-01 00:29:26 | 1 | 18.80 | 1 | N | 132 | 97 | 1 | 50.5 | 0.5 | 0.5 | 10.35 | 0 | 0.3 | 62.15 | |
1 | 2018-12-01 00:59:39 | 2018-12-01 01:09:07 | 1 | 1.00 | 1 | N | 246 | 164 | 1 | 7.5 | 0.5 | 0.5 | 0.44 | 0 | 0.3 | 9.24 | |
1 | 2018-12-01 00:19:19 | 2018-12-01 00:22:19 | 1 | .30 | 1 | N | 161 | 163 | 4 | 4 | 0.5 | 0.5 | 0 | 0 | 0.3 | 5.3 |
The following is a set of problems that I organized with some friends at work in 2018.
This is an interesting one because the infinite sequence below converges to a number that relates to π. There are several ways to prove that although I like this one the most https://www.youtube.com/watch?v=d-o3eB9sfls.
1/1 + 1/4 + 1/9 + 1/16 + … = π / 6
Suppose that we have an array of bytes that comes from a binary file. For simplicity sake, let's say we have just 8 64-bit integers loaded into memory, so we should have 64 bytes in the array.
Here's how we can generate a sample byte array:
julia> x = rand(1:100, 8)
8-element Array{Int64,1}:
3
The @capture
macro from MacroTools expects one to pass the pattern directly when the macro is called. From Slack, someone asked if the pattern can be stored in a variable and then passed to the macro. I could make it work with the following "hack":
julia> code
:(foo(bar + xyz))
julia> pattern
:(phi1_(x_ + y_))
# sum worker | |
function sum_worker(source) | |
target = Channel() | |
task = @async while true | |
args = take!(source) | |
args === nothing && break | |
result = sum(args) | |
push!(target, result) | |
end | |
return (output = target, task = task) |
using DataFrames | |
using Test | |
# Tidyr match-up | |
abstract type FillStrategy end | |
struct FillMissing <: FillStrategy end | |
struct FillRight <: FillStrategy end | |
struct FillLeft <: FillStrategy end |
using TerminalUserInterfaces | |
const TUI = TerminalUserInterfaces | |
function bounce(str; delay = 0.08) | |
TUI.initialize() | |
try | |
terminal = TUI.Terminal() | |
width, height = TUI.terminal_size() | |
len = length(str) |
termcapinfo xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l | |
wall Welcome to screen | |
# See http://www.gnu.org/software/screen/manual/html_node/String-Escapes.html | |
hardstatus alwayslastline | |
# #hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}' | |
#hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]' | |
hardstatus string '%{= wr}[%{B}%S%{r}][%= %{= wr}%?%-Lw%?%{b}(%{B}%n*%f%t%?(%u)%?%{b})%{b}%?%+Lw%?%?%= %{r}][%{B} %Y-%m-%d %c %{r}]' |