Skip to content

Instantly share code, notes, and snippets.

View askz's full-sized avatar
🎯
Focusing

Max: askz

🎯
Focusing
View GitHub Profile
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
██████╗██╗ ██╗ ██████╗██╗ ██╗███╗ ███╗██████╗ ███████╗██████╗
██╔════╝██║ ██║██╔════╝██║ ██║████╗ ████║██╔══██╗██╔════╝██╔══██╗
██║ ██║ ██║██║ ██║ ██║██╔████╔██║██████╔╝█████╗ ██████╔╝
██║ ██║ ██║██║ ██║ ██║██║╚██╔╝██║██╔══██╗██╔══╝ ██╔══██╗
╚██████╗╚██████╔╝╚██████╗╚██████╔╝██║ ╚═╝ ██║██████╔╝███████╗██║ ██║
╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝╚═╝ ╚═╝
@askz
askz / beaudev_docker_nginx_proxy_host.sh
Created May 16, 2016 10:41 — forked from jmeyo/beaudev_docker_nginx_proxy_host.sh
Beaudev simple script to add a nginx vhost reverse proxying to a docker instance
#!/bin/bash
# add vhost reverse proxy for new docker instance for nginx and restart nginx
# use like this : do_nginx_proxy_vhost subdir.example.com http://192.168.0.20:8080
function do_nginx_proxy_vhost() {
[ -z $1 -o -z $2 ] && echo "Give host and address" && return
host=$1
address=$2
[ -f /etc/nginx/sites-available/proxy_reverse_$host ] && (echo "Updating proxy for host: $host" && sudo rm /etc/nginx/sites-enabled/proxy_reverse_$host) || echo "Creating proxy for host: $host"
2016-09-01 12:09:36,804 21461 INFO cdm-new werkzeug: 127.0.0.1 - - [01/Sep/2016 12:09:36] "GET /web/database/manager HTTP/1.1" 500 -
2016-09-01 12:09:36,811 21461 ERROR cdm-new werkzeug: Error on request:
Traceback (most recent call last):
File "/home/maxime/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/maxime/.local/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/home/maxime/Projects/agile/dev/ocb-new/openerp/service/server.py", line 291, in app
return self.app(e, s)
File "/home/maxime/Projects/agile/dev/ocb-new/openerp/service/wsgi_server.py", line 216, in application
@askz
askz / letsencrypt-renew-cron.sh
Last active January 12, 2017 15:19
Cron task for automatic renewing of +/- 30 days expiring certificates
# /etc/cron.d/letsencrypt: crontab entries for the letsencrypt package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc. Renewal will only occur if expiration
# is within 30 days.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
import Vue from 'vue'
import auth from '../../auth'
Vue.use(require('vue-full-calendar'))
window.jQuery = window.$ = require('jquery')
var self = this
export default {
data() {
return {
### Keybase proof
I hereby claim:
* I am askz on github.
* I am askz (https://keybase.io/askz) on keybase.
* I have a public key ASCNbD-Mt9XPOal6bL6ZXHe3eL4fI2oKH2ayfZE9UZ0Cswo
To claim this, I am signing this object:
#Setup UID filter limit
export UGIDLIMIT=500
#copy /etc/passwd accounts to /opt/move/passwd.mig using awk to filter out system account
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /opt/move/passwd.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /opt/move/group.mig
awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd \
@askz
askz / le-renew.sh
Created November 7, 2017 14:58
Renew Let's Encrypt certificates and put them in HAProxy ssl folder
#!/bin/bash
# Let's encrypt: renew certificates and put them in haproxy ssl folder for reloading.
# Maxime Saddok <maxime@businessagile.eu>
# put in /etc/cron.weekly/le-renew && chmod +x /etc/cron.weekly/le-renew
set -x
set -e
/opt/letsencrypt/letsencrypt-auto --standalone --standalone-supported-challenges http-01 --http-01-port 9999 renew;
______________________________________________________ test_getting_list_of_oauth2_clients_by_authorized_user[auth_scopes0] ______________________________________________________
flask_app_client = <AutoAuthFlaskClient <Flask 'app'>>
regular_user = <User(id=1, username="regular_user", email="regular_user@email.com", is_internal=False, is_admin=False, is_regular_user=True, is_active=True, )>
regular_user_oauth2_client = <app.modules.auth.models.OAuth2Client object at 0x7ff93a0b7710>, auth_scopes = ['auth:read']
@pytest.mark.parametrize('auth_scopes', (
['auth:read'],
['auth:read', 'auth:write'],
))