Skip to content

Instantly share code, notes, and snippets.

View mjhea0's full-sized avatar

Michael Herman mjhea0

View GitHub Profile
@luke14free
luke14free / sample_usage.py
Last active October 26, 2016 18:36
Simple type checked objects in Python
#!/usr/bin/env python
from type_checked_entities import entity_factory
Giraffe = entity_factory( # let's define what is a giraffe!
"giraffe",
name=str, # my name is a string
age=float, # my age is an int
eats=object, # I eat pretty much everything.
)
@m3nu
m3nu / md2pdf.py
Last active November 21, 2016 18:34
md2pdf - Command line Markdown to PDF converter with support for CSS stylesheets and custom fonts
#!/usr/bin/env python
import os
import sys
from markdown2 import markdown
from xhtml2pdf import pisa
"""
## Inspired by
@nepsilon
nepsilon / search-bash-zsh-history.md
Last active February 19, 2017 13:48
Searching bash or zsh history — First published in fullweb.io issue #55

Searching bash or zsh history

More often than not, you already typed yesterday the commands you’re about to use today. Wouldn’t it be handy to be able to retrieve the long command instead of typing them yet another time?

Hit Ctrl+R, you’ll see:

(reverse-i-search)`':
@nepsilon
nepsilon / crontab-send-html-emails.md
Last active February 19, 2017 13:52
Make crontab send you HTML emails — First published in fullweb.io issue #57

Make crontab send you HTML emails

Any output (to stdout and stderr) generated by a crontab task will be sent to you by email. This is great to generate system reports or be alerted when something goes wrong.

By default crontab (and the MTA it relies on) will use a text/plain MIME type. But you can make crontab tells the mail sender to use another MIME type, like text/html.

Open crontab with crontab -e, and add this line:

@nepsilon
nepsilon / how-to-find-the-pid-of-a-process-using-a-given-port.md
Created December 27, 2016 02:54
How to find the PID of a process using a given port? — First published in fullweb.io issue #80

How to find the PID of a process using a given port?

Sometimes you have a process you lost the PID, and would like to kill it.

You can use top (or better htop) to search for your process name and press k to kill it. But this isn’t optimal when you aren’t sure of its name. A better alternative is to search by the port opened, for example port 80:

sudo lsof -i :80
@gosseti
gosseti / form.html
Last active February 21, 2017 18:28
A credit card form using jQuery.payment
<form accept-charset="UTF-8" action="/payment" class="cardInfo" method="post">
<fieldset class="cardInfo__cardDetails">
<div class="form-row cardInfo__cc-num">
<label for="cc-num"><abbr title="required">*</abbr><span>Card Number</span></label>
<div class="cc-num__wrap">
<!-- using type="tel" because type="number" doesn’t pass HTML5 form validation with jQuery.payment formatting -->
<input id="cc-num" type="tel" class="paymentInput cc-num" placeholder="•••• •••• •••• ••••" autocompletetype="cc-number" required="required">
<span class="card" aria-hidden="true"></span>
@blalab
blalab / gist:d8ccd9c83f025197fac8c2a2d680c58e
Last active March 13, 2017 23:24
Logging config for Flask + Tornado
{
"version": 1,
"disable_existing_loggers": false,
"formatters": {
"simple": {
"format": "%(asctime)s - %(levelname)s - %(module)s - %(message)s"
},
"debug": {
"format": "%(asctime)s - %(levelname)s - %(pathname)s:%(lineno)s:%(funcName)s - %(message)s"
}

async/await

will change your life




By CJ R.

Lead Instructor @ Galvanize

@andywer
andywer / package.json
Last active July 15, 2017 11:41
Leakage async: Real world test
{
"scripts": {
"test": "mocha"
},
"engines": {
"node": ">= 7.0"
},
"devDependencies": {
"leakage": "./path/to/local/leakage/branch/feature/async-support",
"mocha": "^3.2.0",
@nepsilon
nepsilon / understanding-http-status-codes.md
Created November 22, 2016 03:55
Understanding HTTP’s status codes — First published in fullweb.io issue #75

Understanding HTTP’s status codes

Following our series on HTTP, here is a quick note on HTTP status code, sent with the HTTP response. They are organized in 5 categories:

1xx Informational, ex:

  • 100 Continue used when doing a multi-part file upload
  • 101 Switching Protocol used when switching from HTTP to WebSocket

2xx Success, ex: