Skip to content

Instantly share code, notes, and snippets.

@DzenBotas
DzenBotas / token-generator.js
Created September 17, 2020 11:13 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@DzenBotas
DzenBotas / custom.js
Created September 14, 2020 18:07 — forked from Damiloju/custom.js
import { extend } from "vee-validate"; //import extend function from vee-validate
extend("password", {
message:
"{_field_} must be at least 8 characters, contain One Uppercase, One lowercase, One Special character i.e (! @ # $ % ^ & *), One number.",
validate: value => {
const strong_password = new RegExp(
"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})"
); // regex to check our strong password
@DzenBotas
DzenBotas / user.ts
Created September 8, 2020 21:11 — forked from jgololicic/user.ts
Mongoose, Typescript, Pre hook, hash password, compare passwords
import * as mongoose from 'mongoose';
import {Schema} from 'mongoose';
const bcrypt = require('bcrypt-nodejs');
const userSchema = new Schema({
local: {
username: String,
email: {type: String, unique: true, index: true, sparse: true, lowercase: true, trim: true},
password: String,
@DzenBotas
DzenBotas / gpg2qrcodes.sh
Created September 1, 2020 08:06 — forked from joostrijneveld/gpg2qrcodes.sh
Producing printable QR codes for persistent storage of GPG private keys
# Heavily depends on:
# libqrencode (fukuchi.org/works/qrencode/)
# paperkey (jabberwocky.com/software/paperkey/)
# zbar (zbar.sourceforge.net)
# Producing the QR codes:
# Split over 4 codes to ensure the data per image is not too large.
gpg --export-secret-key KEYIDGOESHERE | paperkey --output-type raw | base64 > temp
split temp -n 4 IMG
for f in IMG*; do cat $f | qrencode -o $f.png; done
@DzenBotas
DzenBotas / generate-ssh-key.sh
Created May 7, 2020 21:52 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@DzenBotas
DzenBotas / remove-billing.php
Created April 6, 2020 12:32 — forked from jgalea/remove-billing.php
Remove billing details from WooCommerce checkout.
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
@DzenBotas
DzenBotas / docker_wordpress.md
Created January 11, 2020 12:06 — forked from bradtraversy/docker_wordpress.md
Docker Compose FIle For Wordpress, MySQL & phpmyadmin

Wordpress & Docker

This file will setup Wordpress, MySQL & PHPMyAdmin with a single command. Add the code below to a file called "docker-compose.yaml" and run the command

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes
@DzenBotas
DzenBotas / ID.js
Created August 5, 2018 18:24
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`