Skip to content

Instantly share code, notes, and snippets.

View kirlf's full-sized avatar
💻
Working

Vladimir Fadeev kirlf

💻
Working
View GitHub Profile
@sergiotapia
sergiotapia / md5-example.go
Last active December 5, 2023 03:53
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@jasonrdsouza
jasonrdsouza / huffman.py
Last active June 21, 2024 14:07
Simple Huffman coding implementation
from queue import PriorityQueue
from collections import Counter
from dataclasses import dataclass, field
from typing import Any
@dataclass(order=True)
class Node:
count: int
value: Any=field(compare=False)
"""
Example of OAuth 2.0 process with web server.
API of facebook is used: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
"""
import webbrowser
import urllib2
import json
from urllib import urlencode
from urlparse import parse_qsl, urlparse
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@subfuzion
subfuzion / curl.md
Last active July 15, 2024 17:14
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@dorelljames
dorelljames / letsencrypt-guide-nginx-acme.sh.md
Last active March 16, 2024 10:34
SSL via Let's Encrypt (nginx server)

Nginx SSL via Let's Encrypt and acme.sh

This guide is intended to walk you through installation of a valid SSL on your server for your site at example.com. This example is using root user, you may need to use sudo if you encounter problems such as write permissions.

Pre-requisites

  • Install acme.sh on your server. This will create a acme.sh folder in your home directory and more importantly create an everyday cron job to check and renew certificates if needed.
  • Install nginx server (different per distibution so just make sure you have it up and running)
@iamstoick
iamstoick / import.md
Created June 14, 2017 05:03
How to import database in MySQL in Docker?

This is a simple way of importing MySQL database in Docker.

  1. In you Dockerfile you must have a shared folder. Shared folder is a directory in your host machine that is mounted to Docker instance.

  2. Put the exported sql file in the shared folder.

  3. Login to your Docker instance via docker exec -it DOCKER_CONTAINER_ID bin/bash.

  4. Login to MySQL via mysql -u USERNAME -p.

kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@wuriyanto48
wuriyanto48 / golang_reduce_map.go
Last active December 11, 2022 18:04
How to Join Map In Golang (Map Union)
package main
import (
"fmt"
)
type Item struct{
Id int
Name string
Qty int
@inkrement
inkrement / clickhousedump
Created August 19, 2017 14:26
dump all clickhouse databases and tables
#!/bin/bash
OUTDIR=.
while read -r db ; do
while read -r table ; do
if [ "$db" == "system" ]; then
echo "skip system db"
continue 2;