This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file ~/.config/fish/config.fish | |
# Based on clearance | |
# name: clearance | |
# --------------- | |
# Based on idan. Display the following bits on the left: | |
# - Current directory name | |
# - Git branch and dirty state (if inside a git repo) | |
function _git_branch_name | |
echo (command git symbolic-ref HEAD 2> /dev/null | sed -e 's|^refs/heads/||') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate uuid; | |
use uuid::Uuid; | |
fn main() { | |
let refs = vec![&uuid::NAMESPACE_DNS, &uuid::NAMESPACE_OID, &uuid::NAMESPACE_URL, &uuid::NAMESPACE_X500]; | |
let tags = vec!["NAMESPACE_DNS", "NAMESPACE_OID", "NAMESPACE_URL", "NAMESPACE_X500"]; | |
let pairs = refs | |
.iter() | |
.zip(tags.iter()) | |
.map(|(u,t)| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Pair<L, R> { | |
private L _left; | |
private R _right; | |
public Pair(L left, R right) { | |
this._left = left; | |
this._right = right; | |
} | |
public L left() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# julia v1.1.1 | |
import Random | |
using Distributions # v0.21.0 | |
import RandomNumbers # v1.3.0 | |
using BenchmarkTools # v0.4.2 | |
function f(µ::T, rng::Random.AbstractRNG) where {T<:Real} | |
n = 0 | |
Σx = zero(T) | |
X = Normal(µ, one(T)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sort_by_degree(g::LightGraphs.AbstractGraph) | |
vs = vertices(g) | |
degrees = (degree(g, v) for v in vs) | |
vertex_pairs = collect(zip(vs, degrees)) | |
sort!(vertex_pairs, by = p -> p[2], rev = true) | |
end | |
julia> sort_by_degree(path_graph(5)) | |
5-element Array{Tuple{Int64,Int64},1}: | |
(2, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> function setindex(x::Tuple, v, i::Integer) | |
Base.@_inline_meta | |
@boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) | |
Base._setindex(v, i, x...) | |
end | |
julia> using BenchmarkTools | |
julia> const t1 = (42, "", π) | |
(42, "", π = 3.1415926535897...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function expand_matrix(ms) | |
T = eltype(eltype(ms)) | |
m2 = Matrix{T}(undef, 0, length(first(ms))) | |
for i in eachindex(ms) | |
m2 = [m2; ms[i]'] | |
end | |
return m2 | |
end | |
function prealloc_matrix(ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Mathieu Besançon | |
[core] | |
autocrlf = true | |
[pager] | |
branch = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script assumes the Julia session is running at the root of the General repository | |
# https://github.com/JuliaRegistries/General | |
# Need these 3 installed | |
using LightGraphs, MetaGraphs, GraphPlot | |
import Pkg | |
function find_direct_deps(pkg_paths, source) | |
direct_deps = filter(pkg_paths) do pkg_path | |
deps_file = joinpath(pkg_path.path, "Deps.toml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Javis | |
nframes = 200 | |
function ground(args...) | |
background("white") # canvas background | |
sethue("black") # pen color | |
end | |
function object(p=O, color="black", radius=12) |
OlderNewer