Skip to content

Instantly share code, notes, and snippets.

Avatar

Jonathan Bieler jonathanBieler

View GitHub Profile
View phone_encoder.jl
#=
# Port of Peter Norvig's Common Lisp program from http://norvig.com/java-lisp.html.
#
# - Julia version: 1.6.2
# - Author: Renato Athaydes
# - Date: 2021-07-24
=#
const emptyStrings = String[]
function printTranslations(io, dict, num, digits, start=1, words=String[])
View sdl_gen.jl
using Clang
import Clang, Clang.cindex
#include("gtk_get_set_gen.jl")
extension(f::String) = splitext(f)[2]
filename(f::String) = splitext(f)[1]
include_path = "/Users/bieler/Downloads/SDL2-2.0.5/include/"
View search_and_replace.jl
using MacroTools, MLStyle, Test
subst(a) = MLStyle.@match a begin
:(sin($x)) => :(cos($x + 1))
_ => a
end
MacroTools.prewalk(subst, quote
sin(x + sin(x))
end)
View gtk_build.jl
using ApplicationBuilder, GtkREPL, Compat
cd("/Users/jbieler/.julia/dev/GtkREPL/")
builddir = "/Users/jbieler/.julia/dev/GtkREPL/builddir/GtkREPL.app/Contents/Libraries/"
r = s->joinpath("/Users/jbieler/.julia/",s)
#Gtk libs
gtk_libs = [
:libgdk,
:libgdk_pixbuf,
View cmaes.jl
module CMAES
using Optim, Distributions, Parameters
import Optim: ZerothOrderOptimizer, ZerothOrderState, initial_state, update_state!,
trace!, assess_convergence, AbstractOptimizerState, update!, value, value!, pick_best_x,
pick_best_f
struct CMA <: Optim.ZerothOrderOptimizer
λ::Int
σ::Float64
View RemoteEval.jl
module RemoteEval
@enum Messages DONE=1
function start_server()
port, server = listenany(8000)
@async begin
while true
sock = accept(server)
View bindeps_sdl.jl
using BinDeps
using Compat
@BinDeps.setup
sdl2 = library_dependency("sdl2", aliases=["sdl2-2.0"])
# package managers
if is_linux()
provides(AptGet, Dict("sdl2-2.0"=>sdl2))
View cmaes.jl
module CMAES
using Distributions
(x) = sum(x)
function init_constants(xinit,λ,w,μ)
D = length(xinit)
μ_w = 1.0 / sum(w.^2)
View ZerothOrderOptimizer.jl
module A
using Optim
import Optim: ZerothOrderOptimizer, ZerothOrderState, initial_state, update_state!, trace!, assess_convergence, AbstractOptimizerState, update!, value
struct RandomSampler <: ZerothOrderOptimizer
σ::Float64
end
RandomSampler(; σ=1e-1) = RandomSampler(σ)
View FirstOrderOptimizer.jl
module A
using Optim
import Optim: FirstOrderOptimizer, initial_state, update_state!, trace!, assess_convergence, AbstractOptimizerState, update!, value
struct MinimalGradientDescent <: FirstOrderOptimizer
η::Float64
end