Skip to content

Instantly share code, notes, and snippets.

View felipenoris's full-sized avatar
💭
burnt

Felipe Noronha felipenoris

💭
burnt
  • Rio de Janeiro / Brazil
View GitHub Profile
@felipenoris
felipenoris / run_pipeline_redirect_output.jl
Last active January 26, 2023 18:27
run_pipeline_redirect_output
# https://discourse.julialang.org/t/iobuffer-becomes-not-writable-after-run/92323
function run_pipeline_redirect_output(cmd::Cmd; stdout::IO=stdout, stderr::IO=stderr)
@assert iswritable(stdout) && iswritable(stderr)
tmp_stdout = isa(stdout, IOBuffer) ? IOBuffer() : stdout
tmp_stderr = isa(stderr, IOBuffer) ? IOBuffer() : stderr
local ret

Notas Sobre Multithreading em Julia

Sobre o uso de Threads.@threads

O uso de Threads.@threads deve ser evitado.

Esta macro utiliza um scheduler estático que não funciona muito bem quando temos uma chamada à macro Threads.@threads a partir de uma função que já está rodando em modo multithread.

Só é seguro utilizar esta macro em código top-level quando há garantia de que não há outras tasks executando em modo multithread e para funções que não disparam código em modo multithread.

function create_heavy_work_tasks(parallel_jobs::Integer, secs::Integer) :: Vector{Task}
jobs = Vector{Task}()
for i in 1:parallel_jobs
push!(jobs, create_single_heavy_work_task(secs))
end
return jobs
# implements `run_notify_action(listener, val=nothing)`
abstract type AbstractEventListener end
# makes `listener` listen to notify events on `condition`
function add_listener(condition::Threads.Condition, listener::AbstractEventListener)
Threads.@spawn begin
lock(condition)
try
while true
Step 52/69 : RUN git clone https://www.github.com/coin-or/coinbrew && cd coinbrew && ./coinbrew fetch --no-prompt SYMPHONY:stable/$SYMPHONY_VER && ./coinbrew build --no-prompt SYMPHONY --prefix=/usr/local --parallel-jobs="$(nproc --all)" && ./coinbrew install SYMPHONY && cd .. && rm -rf coinbrew
---> Running in a15a898a2043
Cloning into 'coinbrew'...
warning: redirecting to https://github.com/coin-or/coinbrew.git/
Welcome to the COIN-OR fetch and build utility
For help, run script with --help.
##################################################
# nice
ccall(:setpriority, Cint, (Cint, Cint, Cint), 0, 0, 3)` to decrease priority by 3
using Distributed
function machines_vector(user::String, ips::Vector{String}, ports::Vector{I}) where {I<:Integer}
machines = Vector()
for ip in ips, port in ports
push!(machines, "$user@$ip 0.0.0.0:$port")
end
return machines
@felipenoris
felipenoris / mysql_normal_user.md
Last active October 1, 2018 18:37
How to create a mysql instance with normal user (no root)

How to create and run a MySQL instance as a normal user (no root)

On Centos7, install libaio dependency:

# yum -y install libaio

Download precompiled Compressed TAR Archive Mysql Community Server for generic linux.