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 typing import Optional | |
| from pydantic import AnyUrl | |
| from pydantic_xml import BaseXmlModel, RootXmlModel, element | |
| class Tags(RootXmlModel, tag="tags"): # type: ignore | |
| root: list[str] = element(tag="tag") | |
| class Notes(BaseXmlModel, tag="notes"): |
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
| // <progress id="progress"></progress> | |
| async function go() { | |
| await pyodide.runPythonAsync(`r = np.random.randn(10000000); 'hi'`) | |
| document.querySelector('#progress').value=30 | |
| await pyodide.runPythonAsync(`r = np.random.randn(10000000); 'hi'`) | |
| document.querySelector('#progress').value=60 | |
| await pyodide.runPythonAsync(`r = np.random.randn(10000000); 'hi'`) | |
| document.querySelector('#progress').value=90 | |
| return 5 |
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
| * Creating virtualenv isolated environment... | |
| * Installing packages in isolated environment... (cython, setuptools, wheel) | |
| * Installing packages in isolated environment... (cython, pythran) | |
| * Getting dependencies for wheel... | |
| Error compiling Cython file: | |
| ------------------------------------------------------------ | |
| ... | |
| from libc.stdlib cimport free | |
| from libc.stdlib cimport malloc |
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
| package: | |
| name: pomegranate | |
| version: 0.14.8 | |
| source: | |
| url: https://files.pythonhosted.org/packages/f8/29/0e3433b4657ea582e2d4c12dc3f27ba0fe1d9b45eebedfb475ed16d3d193/pomegranate-0.14.8.tar.gz | |
| sha256: 2296651290482dd53204ffaaaea267ceee057ce1b3ef1f9d9793febe66d6693d | |
| test: | |
| imports: | |
| - pomegranate | |
| about: |
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
| autocmd FileType python setlocal completeopt-=preview | |
| let g:jedi#max_doc_height=5 | |
| let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>" | |
| let g:SuperTabDefaultCompletionType = "context" |
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 numpy as np | |
| def p(i, w, p_prime): | |
| def summand(w, i, j, p_prime): | |
| return (w[i][j] + w[j][i])/(p_prime[i] + p_prime[j]) | |
| def denom(i, w, p_prime): | |
| return sum(summand(w, i, j, p_prime) for j in range(len(w.T)) if j != i) | |
| return np.nansum(w[i])/denom(i, w, p_prime) | |
| def bt(w, n): |
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 PyPDF2 import PdfFileReader, PdfFileWriter | |
| def extract_pages(in_fp, pages, out_fp): | |
| """Extract a list of pages from a pdf into a new pdf.""" | |
| pdf = PdfFileReader(input_fp) | |
| pdf_writer = PdfFileWriter() | |
| for p in pages: | |
| pdf_writer.addPage(pdf.getPage(p - 1)) # PyPDF2 starts at 0... |
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
| # In .inputrc: | |
| ## arrow up | |
| "\e[A":history-search-backward | |
| ## arrow down | |
| "\e[B":history-search-forward | |
| # In .bashrc: | |
| shopt -s histappend | |
| PROMPT_COMMAND="history -a;$PROMPT_COMMAND" |
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
| """ Connect via ssh to a remote jupyter kernel | |
| 1. Start a jupyter kernel on the remote machine: | |
| `(remote)$ jupyter kernel` | |
| 2. Note the kernel connection file location and copy to local machine (can use globbing if you escape, e.g. "\*"): | |
| `(local)$ scp remote-user@remote-host:<conn-file.json> .` | |
| 3. Use this script to quickly forward the appropriate ports over SSH: | |
| `(local)$ for port in $(python qt_connect.py <conn-file.json>); do ssh -f -N -L $port\:localhost:$port pi@192.168.1.90; done` | |
| 4. Open a local qtconsole instance specifying a connection to the remote | |
| kernel: | |
| `(local)$ jupyter qtconsole --existing <conn-file.json>` |
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
| """First check environment variables for a password, if not then use `getpass`. | |
| You might set the environment variable ahead of time with (from a shell):: | |
| read -s secret | |
| export secret | |
| """ | |
| import os, getpass |
NewerOlder