Skip to content

Instantly share code, notes, and snippets.

View hiphamster's full-sized avatar

Alex Yelluas hiphamster

View GitHub Profile
@hiphamster
hiphamster / tidy.conf
Created November 7, 2018 05:42 — forked from paultreny/tidy.conf
The config file I use for tidy-html5. $ tidy -config <path/to/tidy.conf> input.html > output.html
// paulcode.com
// tidy-html5 config file (mine's named "tidy.conf")
// tidy documentation is here: http://tidy.sourceforge.net/#docs
// tidy-html5 documentation here: http://w3c.github.io/tidy-html5/quickref.html#drop-empty-elements
join-classes: no
logical-emphasis: no
drop-empty-elements: no
anchor-as-name: no
doctype: auto

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@hiphamster
hiphamster / update-alternatives_port-select.md
Last active June 19, 2019 20:42
Setup vi / vim alternatives on mac and linux

Linux

Debian-based systems i.e. Ubuntu have update-alternatives, a system that maintains symbolic links to default commands

From the man page:

EXAMPLES
       There are several packages which provide a text editor compatible with vi, for example nvi and vim. 
 Which one is used is controlled by the link group vi, which includes links for the program itself 
@hiphamster
hiphamster / gist:c848783f4392a4799675ebd0d00a962d
Created August 6, 2019 00:08
Installing mysqlclient with pip
Installing mysqlclient with pip needs to know about openssl
/opt/local is where macports are installed
LDFLAGS="-L/opt/local/lib" CPPFLAGS="-I/opt/local/include/openssl" pip install mysqlclient
@hiphamster
hiphamster / gist:c352c9b264ecc920f0592aec5d412269
Created August 7, 2019 00:04 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@hiphamster
hiphamster / flask_binary.py
Created August 30, 2019 05:41 — forked from Miserlou/flask_binary.py
Flask serving binary data example
import io
from flask import Flask, send_file
app = Flask(__name__)
@app.route('/logo.jpg')
def logo():
"""Serves the logo image."""
with open("logo.jpg", 'rb') as bites: