Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| #!/bin/bash -eu | |
| if [ $# -ne 1 ]; then | |
| echo "specify dot file" | |
| exit 1 | |
| fi | |
| dotfile=$1 | |
| tmpfile=$(mktemp) | |
| texfile="${1}.tex" |
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
| // ==UserScript== | |
| // @name Enable MathJax | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description enable MathJax in inoreader pages | |
| // @author lan496 | |
| // @match https://www.inoreader.com/* | |
| // @grant none | |
| // ==/UserScript== |
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
| import pulp | |
| class SudokuSolver: | |
| # ref: https://pythonhosted.org/PuLP/CaseStudies/a_sudoku_problem.html | |
| def __init__(self, cell_initial): | |
| self.cell_initial = cell_initial | |
| self.rows = [i for i in range(1, 9 + 1)] | |
| self.cols = [i for i in range(1, 9 + 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
| """ | |
| refs. | |
| - https://atc001.contest.atcoder.jp/tasks/unionfind_a | |
| - https://github.com/phil-mansfield/UnionFind.jl | |
| - https://github.com/spaghetti-source/algorithm/blob/master/data_structure/union_find.cc | |
| """ | |
| mutable struct UnionFind{T <: Integer} | |
| parent:: Vector{T} # parent[root] is the negative of the size | |
| function UnionFind{T}(nodes::T) where T<:Integer |
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
| from time import sleep | |
| from joblib import Parallel, delayed | |
| from timeout_decorator import timeout, TimeoutError | |
| @timeout(10, use_signals=False) | |
| def f(n): | |
| if n == 0: | |
| sleep(42) |
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
| from pymatgen.core import Structure, DummySpecie | |
| from pymatgen.core.sites import PeriodicSite | |
| def unique_species(structure: Structure): | |
| list_species = [site.species for site in structure if not site.is_ordered] | |
| uniqued = [] | |
| for sp in list_species: | |
| flag = True | |
| for sp2 in uniqued: |
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
| from functools import lru_cache | |
| from itertools import product | |
| from scipy.special import binom | |
| def polya_counting(permutation_group, num_color): | |
| cnt = 0 | |
| for perm in permutation_group: | |
| type_of_perm = get_type_of_permutation(perm) |
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
| # Copyright (c) Pymatgen Development Team. | |
| from math import acos, sqrt | |
| import numpy as np | |
| from scipy.special import sph_harm | |
| from sympy.physics.wigner import wigner_3j | |
| from pymatgen.analysis.local_env import CrystalNN | |
| def get_neighbor_sites(structure, n, cutoff): |
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
| from itertools import product | |
| import numpy as np | |
| def enumerate_ANX(oxi_states, max_ratio=8): | |
| ret = [] | |
| for anx in product(range(1, max_ratio + 1), repeat=len(oxi_states)): | |
| if np.sum(np.array(oxi_states) * np.array(anx)) == 0: | |
| ret.append(anx) | |
| return ret |