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
function getMaxEatenDiscountCount_foreach(N, D, K) {
let eaten = new Set();
let eatSum = 0;
let eatCounter = 0;
D.forEach((dish) => {
if (!eaten.has(dish)) {
eatSum++;
eaten.add(dish);
eatCounter++;
}
function getMaxEatenDiscountCount_foreach(N, D, K) {
let eaten = new Set();
let eatSum = 0;
let eatCounter = 0;
D.forEach((dish) => {
if (!eaten.has(dish)) {
eatSum++;
eaten.add(dish);
eatCounter++;
}
function getMaxEatenDiscountCount_foreach(N, D, K) {
let eaten = new Set();
let eatSum = 0;
let eatCounter = 0;
D.forEach((dish) => {
if (!eaten.has(dish)) {
eatSum++;
eaten.add(dish);
eatCounter++;
}
using BenchmarkTools
function apply_filter_jl(E, wx)
Xest = 0.0 + 0.0im
@inbounds for j = 1:size(E, 2)
for i = 1:size(E, 1)
Xest += E[i, j] * wx[i, j]'
end
end
return Xest
@tk3369
tk3369 / koch.jl
Last active February 21, 2022 05:48
# Modified from @frank's code at Discord
function koch_curve!(X, Y, x1, y1, x2, y2, level)
if level == 0
push!(X, x1)
push!(X, x2)
push!(Y, y1)
push!(Y, y2)
else
Ξ”x = x2 - x1
@tk3369
tk3369 / gist:08b2a7dd7150a6330513aaf4c320b930
Created February 26, 2022 17:27
HoJBot lost connection to Discord 2022-02-24
HoJBot lost connection to Discord
β”Œ Info: Reconnecting
β”‚ time = 2022-02-24T04:58:52.571
β”‚ conn = 29
β”‚ resume = true
β”” zombie = true
β”Œ Error: Getting gateway URL failed
β”‚ time = 2022-02-24T04:59:51.869
β”‚ exception =
Hi SciML attendees,
We will use Discord as the primary chat platform during the conference.
The Humans of Julia community already has a server, so we will leverage the same server
and use a dedicated channel there (#scimlcon) for the SciML conference.
Please click on the link below to join the server:
https://discord.gg/PRqc3NehEr
For more information about the Discord platform, please visit their web site at https://discord.com/
function stream_user_input(c::Channel)
while true
line = readline()
if line == ""
put!(c, ">>bye")
break
else
put!(c, line)
end
end

Define a function such that it only executes its body once. The value from first execution is memoized at the module level.

module X

export once
let x = Ref{Any}()
    global function once(f::Function)
 isassigned(x) && return x[]
@tk3369
tk3369 / TimeZones.md
Created July 20, 2022 06:37
Time zone labels from TimeZones.jl as of 2022-07-19

The following are valid timezones that can be used for JuliaCon bot's jc command.

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui