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 {
@askz
askz / cli-mysql-to-innodb.php
Created April 5, 2017 16:29
Convert MyISAM to InnoDB - shell script
<?php
/*
* Use this version if you are NOT a Pantheon customer.
*/
$db = array();
/*
* Change these to match your database connection information
*/
$db['host'] = "localhost";
### 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 / add-user.sh
Last active July 4, 2018 02:59 — forked from floudet/ssh-chroot-jail.sh
Chroot Jail for SSH/SFTP Access toolkit
#!/bin/bash
# add "prisoner" in the jail you created before !!
# USAGE : ./add-user.sh <username> <password> <type>
# Type 1 : sftp jailed user ; Type 2 ssh jailed user
# A password will be auto-generated with pwgen (sudo apt install pwgen)
# Set your jail path wherever you want.
JAIL_PATH=/home/www/