Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am docapotamus on github.
  • I am docapotamus (https://keybase.io/docapotamus) on keybase.
  • I have a public key ASA1xy2FMb6q_6Qp8HyCn6HadLHgpgMayb8krdfzgB9wlAo

To claim this, I am signing this object:

@docapotamus
docapotamus / index.html
Created August 14, 2017 07:47
Bootstrap center brand
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
joe@XXXXXX:~$ curl -I https://pjuu.com/
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 07 Mar 2017 16:05:54 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 4525
Connection: keep-alive
Vary: Accept-Encoding
Set-Cookie: session=4e8bf10d360e4b129bdb1319ad3ab15c; Secure; HttpOnly; Path=/
Strict-Transport-Security: max-age=31536000
@docapotamus
docapotamus / error.py
Created January 9, 2017 18:48
FileField fails validation when empty (Flask-WTF 0.14)
# Work successfully in my tests
resp = self.client.post(
url_for('posts.post'),
data={
'body': 'Test',
'upload': '',
},
follow_redirects=True
)
>>> def func1():
... for i in xrange(10):
... yield i
...
>>> def func2():
... for i in func1():
... print i
...
>>> func1()
<generator object func1 at 0x7feb54159960>
@docapotamus
docapotamus / walker.go
Created July 2, 2016 16:33
Directory tree generator
package main
import (
"fmt"
"os"
"path/filepath"
"sort"
"strings"
)
@docapotamus
docapotamus / pjuu_uuid.py
Last active April 7, 2017 20:00
Handling UUID v1mc in Python
# UUID v1mc Python
import random
from uuid import uuid1
random_node = random.randrange(0, 1<<48L) | 0x010000000000L
print uuid1(random_node).hex
# Covert hex encoded UUID back to a UUID
from uuid import UUID
PJUU_SETTINGS=/pjuu/conf/settings.py WEB_CONCURRENCY=`nproc` gunicorn -b 127.0.0.1:8000 -D -k gevent pjuu.wsgi
@docapotamus
docapotamus / swappiness.md
Last active November 13, 2024 07:52
Setting swappiness on Debian

Swappiness controls the tendancy the kernel wishes to swap.

Even with free memory the kernel may swap.

100 means aggressively swap 0 means wait until the last minute to swap

To check current swappiness cat /proc/sys/vm/swappiness

@docapotamus
docapotamus / pjuu.service
Last active December 15, 2015 08:59
Pjuu systemd script
[Unit]
Description=Pjuu
After=network.target
[Service]
PIDFile=/run/pjuu/pid
User=pjuu
Group=pjuu
WorkingDirectory=/pjuu/app
ExecStart=/pjuu/venv/bin/gunicorn --pid /run/pjuu/pid wsgi:application