This file contains hidden or 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 | |
| function livecheck(cask) | |
| try | |
| c = IOCapture.capture() do | |
| run(`brew livecheck --cask $cask`) | |
| end | |
| str = c.output | |
| regex = Regex(cask * ":[ ]+([^=]+)[ ]+==>[ ]+([^\n]+)") | |
| m = match(regex, str) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| [ | |
| { | |
| "id": "3dy3day.visual-markdown-table-editor", | |
| "name": "visual-markdown-table-editor", | |
| "publisher": "3dy3day", | |
| "version": "1.0.2" | |
| }, | |
| { | |
| "id": "adam-bender.commit-message-editor", | |
| "name": "commit-message-editor", |
This file contains hidden or 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 find_min_energy_map2(energy) | |
| energy = transpose(energy) | |
| row, col = size(energy) | |
| dir_arr = [-1, 0, 1] | |
| energy_map = zeros(row, col) | |
| energy_map[:, end] = energy[:, end] | |
| dirs = zeros(Int, row, col) | |
| @inbounds for c = col-1:-1:1 |
This file contains hidden or 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 compare_with_qe(result, qe_result, alat) | |
| result = map(result * alat) do vec | |
| map(v -> round(v; digits = 7), vec) | |
| end | |
| f(result) = sortperm(DataFrame(hcat(result...)', [:x, :y, :z]), [:x, :y, :z]) | |
| g(result) = result[sortperm(DataFrame(hcat(result...)', [:x, :y, :z]), [:x, :y, :z])] | |
| # result_df = sortperm(DataFrame(hcat(result...)', [:x, :y, :z]), [:x, :y, :z]) | |
| # qe_df = sortperm(DataFrame(hcat(qe_result...)', [:x, :y, :z]), [:x, :y, :z]) | |
| # result_df, qe_df | |
| symdiff(result, qe_result) |