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 mapat!(f, array, indices...) # Map function `f` at specific indices of an array | |
area = view(array, indices...) | |
map!(f, area, area) | |
return array | |
end |
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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use File::Copy; # to copy the original file to backup (if overwrite option set) | |
use Getopt::Std; # to get the switches/options/flags | |
# get the options | |
my %options=(); | |
getopts("wos", \%options); |
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 IOCapture | |
export livecheck, bump_cask_pr | |
function livecheck(cask) | |
try | |
c = IOCapture.capture() do | |
run(`brew livecheck --cask $cask`) | |
end | |
str = c.output |
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
#!/usr/bin/env python | |
try: | |
from IPython import get_ipython | |
IPYTHON = get_ipython() | |
IPYTHON.run_line_magic('load_ext', 'autoreload') | |
IPYTHON.run_line_magic('autoreload', '2') | |
except ModuleNotFoundError: | |
pass | |
try: |
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 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
module ToggleableAsserts | |
export @toggled_assert, toggle | |
assert_toggle() = true | |
macro toggled_assert(cond, text=nothing) | |
if text==nothing | |
assert_stmt = esc(:(@assert $cond)) | |
else |
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 IOCapture | |
c = IOCapture.capture() do | |
run(`tmutil listlocalsnapshots /`) | |
end | |
const REGEX = r"com\.apple\.TimeMachine\.(\d+-\d+-\d+-\d+)\.local" | |
map(split(c.output, "\n", keepempty=false)) do line | |
m = match(REGEX, line) | |
if m !== nothing | |
version = m[1] |
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 Crystallography | |
using QuantumESPRESSO.Inputs.PWscf | |
using QuantumESPRESSO.Outputs.PWscf | |
press = [-10 -5 0 10 20 40 60 70 80 90] | |
e = map(sort(press |> vec)) do p | |
str = read(joinpath("p=$p.0", "SelfConsistentField.out"), String) | |
parse_electrons_energies(str, :converged).ε |> only | |
end |> vec | |
v = map(sort(press |> vec)) do p |
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
https://discourse.julialang.org/t/combining-two-arrays-with-alternating-elements/15498/3 | |
# Interleave 2 vectors `a` & `b` to get a new vector | |
collect(Iterators.flatten(zip(a, b))) |
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
[ | |
{ | |
"identifier": { | |
"id": "vscode.bat" | |
}, | |
"pinned": false, | |
"preRelease": false, | |
"version": "1.0.0" | |
}, | |
{ |