Skip to content

Instantly share code, notes, and snippets.

@tonyin
tonyin / mysql.md
Created March 24, 2019 23:40
mysql commands

MySQL internal db on same server as use

  1. Log into mysql
  2. View existing databases
  3. Create new database
  4. Create new superuser for new database
  5. Grant all privileges to superuser for new database
  6. Flush privileges
@tonyin
tonyin / utility.py
Last active January 5, 2019 05:42
Python3 helpers
def strftime(value, format='%d %b %Y'):
return value.strftime(format)
def strptime(value, format='%Y-%m-%d'):
return datetime.datetime.strptime(value, format)
flatten = lambda l: [item for sublist in l for item in sublist]
@tonyin
tonyin / utility.html
Created December 23, 2018 18:37
Jinja2 Helpers
{# Filter out None or empty string values from list #}
{# ################################################ #}
{# Given: responses = list of object with "rating" attribute #}
{% set ratings = responses|map(attribute='rating')|select('string')|map('length')|select('gt',0)|list %}
@tonyin
tonyin / utility.js
Last active August 29, 2018 22:11
Javascript helper functions
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;")
}
function nl2br(str) {
return (str + '')
Verifying my Blockstack ID is secured with the address 19is5c1Ejamch79L1piwjy3mzarCA12jGw https://explorer.blockstack.org/address/19is5c1Ejamch79L1piwjy3mzarCA12jGw

Keybase proof

I hereby claim:

  • I am tonyin on github.
  • I am aeto (https://keybase.io/aeto) on keybase.
  • I have a public key ASCwLOwPJksgnDZ4TEWv-8ZL7RYbz721EX7g51Wyg3T5LAo

To claim this, I am signing this object: