=ROUND( A2/(1024)^(FLOOR(log(A2)/log(1024))), 2) & " " & SWITCH( FLOOR( log(A2) / log(1024) ) ,0,"Bytes",1,"KiB",2,"MiB",3,"GiB",4,"TiB")
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
| # Upsert function for pandas to_sql with postgres | |
| # https://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql/8702291#8702291 | |
| # https://www.postgresql.org/docs/devel/sql-insert.html#SQL-ON-CONFLICT | |
| import pandas as pd | |
| import sqlalchemy | |
| import uuid | |
| import os | |
| def upsert_df(df: pd.DataFrame, table_name: str, engine: sqlalchemy.engine.Engine): |
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 flask import Blueprint, redirect, url_for, session | |
| from flask_dance.contrib.google import make_google_blueprint, google | |
| from flask_dance.consumer.backend.sqla import SQLAlchemyBackend | |
| from flask_login import current_user, login_user, logout_user | |
| from flask_dance.consumer import oauth_authorized | |
| from sqlalchemy.orm.exc import NoResultFound | |
| from oauthlib.oauth2.rfc6749.errors import InvalidClientIdError | |
| from itemcatalog import app, db, user | |
| userauth = Blueprint('userauth', __name__) |
I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).
You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:
(Each row represents a "worker" in my model, and each rectangle represents a "task.")
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
| # Create a global gitignore for macOS | |
| cat https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore >> ~/.gitignore_global | |
| git config --global core.excludesfile ~/.gitignore_global | |
| # Send screenshots to a directory that isn't the desktop | |
| mkdir -p ~/Screenshots | |
| defaults write com.apple.screencapture location ~/Screenshots | |
| # Show all hidden files (like dotfiles) | |
| defaults write com.apple.finder AppleShowAllFiles YES; killall Finder; |
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
| {% extends "layout_new.html" %} | |
| {% block content_main %} | |
| <div class="content-section"> | |
| <form method="POST" action=""> | |
| {{ form.hidden_tag() }} | |
| <fieldset class="form-group"> | |
| <legend class="border-bottom mb-4">User Choices</legend> | |
| {% if form.choices.errors %} | |
| <div class="invalid-feedback"> | |
| {% for error in form.choices.errors %} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
$ wget -e robots=off -r -np 'http://example.com/folder/'
- -e robots=off causes it to ignore robots.txt for that domain
- -r makes it recursive
- -np = no parents, so it doesn't follow links up to the parent folder
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 os | |
| import time | |
| import string | |
| import pickle | |
| from operator import itemgetter | |
| from nltk.corpus import stopwords as sw | |
| from nltk.corpus import wordnet as wn | |
| from nltk import wordpunct_tokenize |
NewerOlder
