Skip to content

Instantly share code, notes, and snippets.

View dsl2022's full-sized avatar
🏠
Working from home

DSL dsl2022

🏠
Working from home
View GitHub Profile
@dsl2022
dsl2022 / mysql_reset.md
Last active October 24, 2021 03:00
how to reset mysql password

Update: On 8.0.15 (maybe already before that version) the PASSWORD() function does not work You have to do:

Make sure you have Stopped MySQL first (above). Run the server in safe mode with privilege bypass: sudo mysqld_safe --skip-grant-tables

UPDATE mysql.user SET authentication_string=null WHERE User='root';
FLUSH PRIVILEGES;
exit;

Then

@dsl2022
dsl2022 / 1.srp.py
Created September 12, 2021 15:21
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
β€œβ€¦You had one jobβ€β€Šβ€”β€ŠLoki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@dsl2022
dsl2022 / index.js
Created April 27, 2021 12:38
from csv to mongodb
const csv = require("csv-parser");
const fs = require("fs");
require("dotenv").config();
const { MongoClient } = require("mongodb");
const { CSV_FILE, MONGO_URI, COLLECTION_NAME, DB_NAME } = process.env;
async function mongoHandler(data) {
const client = new MongoClient(MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,

Micro-CMS v2

flag 1 Username: ' UNION SELECT '123' AS password# Password: 123

flag 2 use POST curl -i -X POST -H 'Content-Type: application/json' -d '{"title":"test","body":"test"}' http://34.94.3.143/9e7647466c/page/edit/4

@dsl2022
dsl2022 / install-docker.md
Created November 19, 2020 05:09 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@dsl2022
dsl2022 / node_nginx_ssl.md
Created November 13, 2020 05:14 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@dsl2022
dsl2022 / go-stdlib-interface-selected.md
Created November 8, 2020 05:27 — forked from asukakenji/go-stdlib-interface-selected.md
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@dsl2022
dsl2022 / _tree
Created November 5, 2020 12:26 — forked from alexedwards/_tree
.
β”œβ”€β”€ books
β”‚Β Β  β”œβ”€β”€ handlers.go
β”‚Β Β  └── models.go
β”œβ”€β”€ config
β”‚Β Β  └── db.go
└── main.go
@dsl2022
dsl2022 / gist:c9a10b12b2e3a2f90de8bc9b1a2aeff4
Created October 16, 2020 03:16 — forked from alexedwards/gist:dc3145c8e2e6d2fd6cd9
Example of working with Go's database/sql and NULL fields
CREATE TABLE books (
isbn char(14) NOT NULL,
title varchar(255),
author varchar(255),
price decimal(5,2)
);
INSERT INTO books (isbn, title, author, price) VALUES
('978-1503261969', 'Emma', 'Jayne Austen', 9.44),
('978-1514274873', 'Journal of a Soldier', NULL, 5.49),
"use strict";
var MongoClient = require("mongodb").MongoClient;
require("dotenv").config();
let atlas_connection_uri;
let cachedDb = null;
exports.handler = (event, context, callback) => {
var uri = process.env["MONGODB_ATLAS_CLUSTER_URI"];