Skip to content

Instantly share code, notes, and snippets.

View tk3369's full-sized avatar
🐢
Published! Hands on design patterns and best practices with Julia.

Tom Kwong tk3369

🐢
Published! Hands on design patterns and best practices with Julia.
View GitHub Profile
@tk3369
tk3369 / gist:392987f91a75abdd69cc2b5ff3f68e9e
Created May 14, 2021 14:39
hojbot disconnected 2021-05-14 08:27 UTC
β”Œ Error: Gateway error
β”‚ time = 2021-05-14T08:27:03.245
β”‚ conn = 20
β”‚ exception =
β”‚ IOError: stream is closed or unusable
β”‚ Stacktrace:
β”‚ [1] check_open(x::Sockets.TCPSocket)
β”‚ @ Base ./stream.jl:386
β”‚ [2] ssl_unsafe_write(ctx::MbedTLS.SSLContext, buf::Ptr{UInt8}, nbytes::UInt64)
β”‚ @ MbedT
@tk3369
tk3369 / v2v_to_matrix.jl
Created May 22, 2021 23:44
Performance of converting vector-of-vector to matrix
using BenchmarkTools
g(y) = [[y[j], 2y[j]] for j in 1:length(y)]
f8(x) = reduce(hcat, x)'
function f11(v::Vector{Vector{T}}) where T
Mat = Matrix{T}(undef, length(v), length(v[1]))
@inbounds for row in 1:length(v)
for col in 1:length(v[1])
@tk3369
tk3369 / julia-getting-started.md
Last active June 22, 2021 20:59
Getting started with Julia

Setup

  • Visit Julia home page to download pre-built binaries and access documentation
  • Install VSCode, and install Julia Language extension
  • For an interactive environment, try Pluto

Essential packages

Install these packages in your root environment:

@tk3369
tk3369 / tz.txt
Created July 10, 2021 08:05
hojbot tz command
Improve tz command
- "tz me <my-time-zone>" command to configure per-user time zone
- "tz alias add <alias> <zone-name>" command to add system aliases
- "tz alias rm <alias>" command to remove system aliases
- target time zone command "tz <date> <time> <zone1> to <zone2>,<zone3>,..."
(without zone2+, it converts to user's own time zone, or direct user to use tz me command)
Reference: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Examples:
@tk3369
tk3369 / tictactoe.txt
Last active July 10, 2021 08:20
tic-tac-toe game
TicTacToe game
> ttt start
@tk3369, ok - let's play a Tic-Tac-Toe game!
Enter your move as letter-digit. For example, `ttt b3`.
a b c
|---|---|---|
1 | | | |
|---|---|---|
2 | | | |
# Installation issue
```
Precompiling project...
βœ— SimpleDirectMediaLayer
8 dependencies successfully precompiled in 19 seconds (53 already precompiled)
1 dependency errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the package
julia> using Pkg
@tk3369
tk3369 / gist:ef17732a3ff3a233f1e16f904b374f46
Created July 24, 2021 05:16
hojbot(juliacon) crash 2021-07-24T05:12:22.270 UTC
β”Œ Info: Reconnecting
β”‚ time = 2021-07-24T05:12:12.487
β”‚ conn = 25
β”‚ resume = true
β”” zombie = true
β”Œ Error: Getting gateway URL failed
β”‚ time = 2021-07-24T05:12:22.270
β”‚ exception =
β”‚ DNSError: discordapp.com, temporary failure (EAI_AGAIN)
β”‚ Stacktrace:
@tk3369
tk3369 / gist:871af7f4a29a8edafa858d51494e515a
Created July 24, 2021 05:17
hojbot(hoj) crash 2021-07-24T05:12:41.651 UTC
β”Œ Info: Reconnecting
β”‚ time = 2021-07-24T05:12:23.746
β”‚ conn = 5
β”‚ resume = true
β”” zombie = true
β”Œ Error: Getting gateway URL failed
β”‚ time = 2021-07-24T05:12:41.651
β”‚ exception =
β”‚ DNSError: discordapp.com, temporary failure (EAI_AGAIN)
β”‚ Stacktrace:
@tk3369
tk3369 / gist:6591d09009938ae9c039362ec345a526
Last active September 3, 2021 18:26
mami-shop dev setup

Try yarn build:

➜  small-shopping-cart git:(master) yarn build
yarn run v1.22.11
$ react-scripts build
/bin/sh: react-scripts: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.