Skip to content

Instantly share code, notes, and snippets.

View selfagency's full-sized avatar
👾
beep boop

daniel sieradski selfagency

👾
beep boop
View GitHub Profile
@selfagency
selfagency / launch.json
Created July 11, 2021 01:17
nuxt vscode debug config
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "client: chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
@selfagency
selfagency / find-tables-without-keys.sql
Created July 11, 2021 01:17
find all tables without primary keys
USE INFORMATION_SCHEMA;
SELECT
TABLES.table_name
FROM TABLES
LEFT JOIN KEY_COLUMN_USAGE AS c
ON (
TABLES.TABLE_NAME = c.TABLE_NAME
AND c.CONSTRAINT_SCHEMA = TABLES.TABLE_SCHEMA
AND c.constraint_name = 'PRIMARY'
)
@selfagency
selfagency / change-password-auth.sql
Created July 11, 2021 01:16
change mysql 8 to mysql 5 password auth
ALTER USER `root`@`%` IDENTIFIED WITH mysql_native_password BY [PASSWORD]
@selfagency
selfagency / find_iso_date.js
Created July 11, 2021 01:16
find iso date regex
const str = DATE_STRING
const isoDate = /(Sun\w*\.?|Mon\w*\.?|Tue\w*\.?|Wed\w*\.?|Thu\w*\.?|Fri\w*\.?|Sat\w*\.?)?\ ?(Jan\w*\.?|Feb\w*\.?|Mar\w*\.?|Apr\w*\.?|May\w*\.?|Jun\w*\.?|Jul\w*\.?|Aug\w*\.?|Sep\w*\.?|Oct\w*\.?|Nov\w*\.?|Dec\w*\.?)\ ?(\d+)?,? \ ?(\d{1,2}:\d{1,2}:?\d{2}?\ ?\w{3}\ ?)?(\d{4})/.exec(str)
@selfagency
selfagency / wp-config.php
Created July 11, 2021 01:14
fix wordpress admin redirect
<?php
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
$_SERVER['HTTPS'] = 'on';
}
@selfagency
selfagency / restart-nginx.sh
Created July 11, 2021 01:13
restart nginx
#!/usr/bin/env bash
sudo nginx -t && sudo systemctl reload nginx
@selfagency
selfagency / reverse_proxy.conf
Created July 11, 2021 01:13
nginx reverse proxy
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name selfagency.net;
# SSL
ssl_certificate /etc/letsencrypt/live/selfagency.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/selfagency.net/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/selfagency.net/chain.pem;
@selfagency
selfagency / nginx-with-certbot.sh
Created July 11, 2021 01:11
config nginx with certbot
#!/usr/bin/env bash
$DOMAIN=selfagency.dev
$EMAIL=hello@selfagency.dev
sudo sed -i -r 's/(listen .*443)/\1;#/g; s/(ssl_(certificate|certificate_key|trusted_certificate) )/#;#\1/g' /etc/nginx/sites-available/$DOMAIN.conf
sudo certbot certonly --webroot -d $DOMAIN --email $EMAIL -w /var/www/_letsencrypt -n --agree-tos --force-renewal
sudo sed -i -r 's/#?;#//g' /etc/nginx/sites-available/$DOMAIN.conf
sudo nginx -t && sudo systemctl reload nginx
<iframe src="signal.svg" onload="this.before(this.contentDocument.children[0]); this.remove();"></iframe>
@selfagency
selfagency / if-cli-else.js
Created July 11, 2021 01:09
if node app is cli, else
if (require.main === module) {
console.log('called directly');
} else {
console.log('required as a module');
}