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
| license: mit |
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 | |
| DOWNLOAD_DIR="${HOME}/Downloads" | |
| FIREFOX_DIR="/usr/lib/firefox_dev" | |
| DESKTOPFILE="${HOME}/.local/share/applications/firefox_dev.desktop" | |
| URL="https://download.mozilla.org/?product=firefox-devedition-latest-ssl&os=linux64&lang=en-US" | |
| REDIR_URL=$(curl --head --silent "${URL}" --write-out "%{redirect_url}") | |
| FILENAME=$(basename "${REDIR_URL}") | |
| FILENAME_PATH="${DOWNLOAD_DIR}/${FILENAME}" | |
| echo $FILENAME_PATH | |
| curl --location "${URL}" --output "${FILENAME_PATH}" |
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
| # Use compiler extension to change SELECT FOR UPDATE with SKIP LOCKED, supported since MySQL 8. | |
| # As of SQLAlchemy v1.2 SKIP LOCKED is only compiled for Oracle and PostgreSQL backends. | |
| # ref: | |
| # https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html | |
| # https://docs.sqlalchemy.org/en/latest/core/selectable.html#sqlalchemy.sql.expression.Select.with_for_update | |
| from sqlalchemy.ext.compiler import compiles | |
| from sqlalchemy.sql.expression import Select | |
| from sqlalchemy.sql.selectable import ForUpdateArg |
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
| # forgot to redirect output to log: | |
| strace -f -p <pid> -e write 2>&1 | tee /tmp/log.txt |
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
| def iterate_rainbow(file): | |
| import mmap | |
| import contextlib | |
| import csv | |
| from io import StringIO | |
| encoding = 'utf-8' | |
| csv_opts = {'delimiter': ';', 'quoting': csv.QUOTE_MINIMAL, 'quotechar': '"'} | |
| with open(file, 'r+b') as fd: | |
| with contextlib.closing(mmap.mmap(fd.fileno(), 0, access=mmap.ACCESS_WRITE)) as mm: |
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 geoalchemy2 import Geography, Geometry | |
| from sqlalchemy import cast | |
| ... | |
| class Node(db.Model): | |
| .... | |
| def get_area(self, type_key): | |
| try: | |
| return Area.query.filter(Area.type_key == type_key).filter( | |
| cast(Area.polygon, Geometry).ST_Contains( | |
| cast(self.point, Geometry))).first() or None |
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
| make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' |
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
| for n in $(tail -n +3 primes1.txt); do [ ! -z "${n##*[!0-9]*}" ] && echo $n; done |
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
| <?php | |
| echo "php version: ".phpversion()."\n"; | |
| echo "\ncall named function:\n---\n"; | |
| function named() { | |
| try{ | |
| echo "try\n";return true; | |
| } finally { | |
| echo "finally\n";return false; | |
| } |
NewerOlder