Skip to content

Instantly share code, notes, and snippets.

View staticfloat's full-sized avatar

Elliot Saba staticfloat

View GitHub Profile
#!/usr/bin/env julia
function use_or_import(pkg)
quote
try
using $(pkg)
catch
import Pkg
Pkg.add($("$(pkg)"))
using $(pkg)
# This file is machine-generated - editing it directly is not advised
[[ArgTools]]
git-tree-sha1 = "3ca019a0a4a469dbade0869856794ad783ef3574"
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.0.1"
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@staticfloat
staticfloat / i_have_too_much_disk_space.jl
Last active April 24, 2020 08:07
Example script to download the latest version of all packages and their attendant artifacts (ignoring compatibility constraints)
empty!(Base.DEPOT_PATH)
push!(Base.DEPOT_PATH, joinpath(@__DIR__, "depot"))
using Pkg
Pkg.update()
registry_dir = joinpath(@__DIR__, "depot", "registries", "General")
regdict = Pkg.Types.read_registry(joinpath(registry_dir, "Registry.toml"))["packages"]
ctx = Pkg.Types.Context()
all_pkgspecs = Pkg.Types.PackageSpec[]
2020-04-02T18:53:08Z I! Starting Telegraf 1.10.4
2020-04-02T18:53:08Z I! Using config file: /etc/telegraf/telegraf.conf
2020-04-02T18:53:08Z I! Loaded inputs: cpu disk mem docker temp diskio kernel processes swap system net sensors
2020-04-02T18:53:08Z I! Loaded aggregators:
2020-04-02T18:53:08Z I! Loaded processors:
2020-04-02T18:53:08Z I! Loaded outputs: influxdb
2020-04-02T18:53:08Z I! Tags enabled: host=firefly1 project=julia
2020-04-02T18:53:08Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"firefly1", Flush Interval:1m0s
2020-04-02T18:53:10Z E! [inputs.sensors]: Error in plugin: failed to run command /usr/bin/sensors -A -u: exit status 1 - No sensors found!
Make sure you loaded all the kernel drivers you need.
@staticfloat
staticfloat / pkg_df.jl
Created March 27, 2020 23:50
Determine package disk usage
using Pkg, Pkg.Artifacts, Printf
function readdir_empty(path::String)
if !isdir(path)
return String[]
end
return readdir(path)
end
function list_artifacts(depots::Vector = Pkg.depots())
@staticfloat
staticfloat / rewrite_imports.py
Created March 25, 2020 08:38
PE file import rewriter
import pefile, shutil, os, struct
from optparse import OptionParser
# Example usage: rewrite_imports.py --rewrite libfoo.dll:lib/libfoo.dll --rewrite libbar.dll:../share/artifacts/1a2b3c/bin/libbar-1.dll usr/bin/julia.exe
parser = OptionParser(usage="usage: %prog [--rewrite FROM:TO]... file")
parser.add_option("--rewrite", dest="rewrites",
action="append", help="Rewrite an import library FROM to TO", metavar="FROM:TO")
options, args = parser.parse_args()
if len(args) != 1:
@staticfloat
staticfloat / artifact_download_debug.jl
Last active March 10, 2020 22:02
Julia 1.3+ Artifact error debugging script
# Adapt this script to debug why artifact installation might be failing
using Pkg, Pkg.Artifacts, Pkg.BinaryPlatforms, Pkg.PlatformEngines
# Initialize Pkg code
probe_platform_engines!(; verbose=true)
# Change these to whatever you need them to be, to debug your artifacts code
artifacts_toml_url = "https://raw.githubusercontent.com/JuliaBinaryWrappers/HELICS_jll.jl/master/Artifacts.toml"
artifact_name = "HELICS"
#!/bin/bash
# Helper to jump to julia package source
function jlj()
{
if [[ $# != 1 ]]; then
echo "Usage: jlj <package name>" >&2
return
fi
#!/bin/bash
set -e
set -x
if [[ -z "$MACOS_CODESIGN_IDENTITY" ]]; then
echo "ERROR: Must export MACOS_CODESIGN_IDENTITY" > &2
exit 1
fi
# detach anything that's old