Skip to content

Instantly share code, notes, and snippets.

View jackiect's full-sized avatar
💭
I may be slow to respond.

Jack jackiect

💭
I may be slow to respond.
View GitHub Profile
@jackiect
jackiect / json.py
Created March 18, 2021 03:24 — forked from amacneil/json.py
Safely JSON-encode objects in your Django template
from django.core.serializers.json import DjangoJSONEncoder
from django.template import Library
from json import dumps as json_dumps
register = Library()
@register.filter
def json(data):
"""
@jackiect
jackiect / Dockerfile
Last active December 25, 2020 06:08
Reverse proxy in Traefik with subdirectories.
FROM python:3.7.8-alpine
ENV PYTHONUNBUFFERED=1
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
ENV FLASK_RUN_PORT=8080
EXPOSE 8080
@jackiect
jackiect / web-servers.md
Last active November 19, 2020 10:37 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@jackiect
jackiect / django_jwt_cookie.py
Created October 28, 2020 16:03 — forked from elnygren/django_jwt_cookie.py
Teach Django to use JWT tokens inside the session cookie - plays well with django-rest-framework-jwt.
@jackiect
jackiect / docker-machine-install-docker-compose.sh
Created July 24, 2020 05:14 — forked from jan-swiecki/docker-machine-install-docker-compose.sh
Installs docker-compose inside docker-machine
#!/bin/sh
# Installs docker-compose inside docker-machine
DOCKER_COMPOSE_VERSION=1.6.0
# Download docker-compose to the permanent storage
echo 'Downloading docker-compose to the permanent VM storage...'
sudo mkdir -p /var/lib/boot2docker/bin
sudo curl -sL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` -o /var/lib/boot2docker/bin/docker-compose
@jackiect
jackiect / Makefile
Created July 7, 2020 03:57
makefile google oauth2 requests
GOOGLE_AUTH_PAGE=https://accounts.google.com/o/oauth2/auth
# GOOGLE_AUTH_PAGE_V2=https://accounts.google.com/o/oauth2/v2/auth
GOOGLE_TOKEN_API=https://oauth2.googleapis.com/token
GOOGLE_TOKEN_INFO_API=https://oauth2.googleapis.com/tokeninfo
# GOOGLE_TOKEN_INFO_API_V3=https://www.googleapis.com/oauth2/v3/tokeninfo
GOOGLE_REVOKE_API=https://oauth2.googleapis.com/revoke
GOOGLE_USERINFO_API_V3=https://www.googleapis.com/oauth2/v3/userinfo
GOOGLE_USER_PROFILE_API=https://www.googleapis.com/auth/userinfo.profile
#!/usr/bin/env bash
result='\n'
for m in $(docker-machine ls -f '{{.Name}}')
do
result=$result"Host docker-machine-$(docker-machine inspect -f '{{.Driver.MachineName}}' $m)"'\n'
result=$result" HostName $(docker-machine inspect -f '{{.Driver.IPAddress}}' $m)"'\n'
result=$result" User $(docker-machine inspect -f '{{.Driver.SSHUser}}' $m)"'\n'
result=$result" IdentityFile $(docker-machine inspect -f '{{.Driver.SSHKeyPath}}' $m)"'\n'
@jackiect
jackiect / rongyun-api.md
Last active March 26, 2020 09:28
rongyun

https://docs.rongcloud.cn/im/server/signature/#_2

curl -X POST -H "App-Key: uwd1c0sxdlx2" -H "Nonce: 14314" -H "Timestamp: 1408710653000" -H "Signature: `echo -n Y1W2MeFwwwRxa0143141408710653000|sha1sum |awk '{printf $1}'`" -d 'userId=jlk456j5&name=Ironman&portraitUri=http%3A%2F%2Fabc.com%2Fmyportrait.jpg' "https://api-cn.ronghub.com/user/getToken.json"
curl -X POST -H "App-Key: 0vnjpoad0i1uz" -H "Nonce: $(date '+%s'|tail -c 6)" -H "Timestamp: $(date '+%s')" -H "Signature: `echo -n FZ****Pwbs$(date '+%s'|tail -c 6)$(date '+%s')|sha1sum |awk '{printf $1}'`" -d 'userId=jlk456j5&name=Ironman&portraitUri=http%3A%2F%2Fabc.com%2Fmyportrait.jpg' "https://api-cn.ronghub.com/user/getToken.json"

{"code":200,"userId":"jlk456j5","token":"Vk9O2dRLPlRYXDOv4zGBEXcjTUnCGVETk65A/2iMccLZF2uk0LUN6TJLNRHJ1NzsLVRliU5BLcgGWb3oTd3OXQ=="}
#!/usr/bin/env bash
SESSION="vs@`pwd |rev |cut -f1 -d/ |rev| cut -f2 -d.`#`pwd |md5sum |cut -c1-7`"
tmux attach -d -t $SESSION || tmux new -s $SESSION