Skip to content

Instantly share code, notes, and snippets.

View dfmcvn's full-sized avatar
💭
kek

Dang Minh Duc dfmcvn

💭
kek
  • Hanoi, Vietnam
View GitHub Profile
@NARKOZ
NARKOZ / db_backup.sh
Created October 23, 2010 18:15
MySQL backup shell script
#!/bin/bash
# Shell script to backup MySQL database
# Set these variables
MyUSER="" # DB_USERNAME
MyPASS="" # DB_PASSWORD
MyHOST="" # DB_HOSTNAME
# Backup Dest directory
DEST="" # /home/username/backups/DB
@svyatov
svyatov / analyse_nginx_log.rb
Created November 24, 2012 00:54
nginx log parser, reports top 10 consumers ip by traffic + gives some additional info (pages, urls hits)
bytes_per_ip = Hash.new(0)
urls_per_ip = Hash.new(0)
pages_per_ip = Hash.new(0)
files_extensions_per_ip = Hash.new()
# i = 0
File.foreach ARGV.shift do |line|
# Line example: [23/Nov/2012:06:26:53 +0400] 123.123.123.123 "GET /images/socializ/google-buzz.png HTTP/1.1" 200 2283 "-" www.domain.ru "http://www.domain.ru/page.html" "Opera/9.80 (J2ME/MIDP; Opera Mini/5.1.24009/28.3126; U; ru) Presto/2.8.119 Version/11.10"
/\A\[.+?\]\s(?<ip>.+?)\s"GET (?<url>.+?)\s.+?"\s[0-9]+\s(?<bytes>[0-9]+)\s/ =~ line
bytes_per_ip[ip] += bytes.to_i
@carlosleopoldo
carlosleopoldo / delete-orphans-usermeta.sql
Last active June 16, 2023 13:23
Delete all orphans user meta in WordPress
DELETE FROM wp_usermeta
WHERE NOT EXISTS (
SELECT * FROM wp_users
WHERE wp_usermeta.user_id = wp_users.ID
)
@soheilhy
soheilhy / nginxproxy.md
Last active May 16, 2024 08:59
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@tleish
tleish / mysql_backup.sh
Last active May 28, 2024 04:55
Bash Script to backup all MySQL databases
#!/bin/bash
#==============================================================================
#TITLE: mysql_backup.sh
#DESCRIPTION: script for automating the daily mysql backups on development computer
#AUTHOR: tleish
#DATE: 2013-12-20
#VERSION: 0.4
#USAGE: ./mysql_backup.sh
#CRON:
# example cron for daily db backup @ 9:15 am
@matijagrcic
matijagrcic / Batch-convert-webp-to-png.txt
Created November 18, 2016 18:28
Batch convert webp to png
#Download dwebp (WebP decoder tool) https://developers.google.com/speed/webp/download
#Run
for %f in (*.webp) do dwebp.exe "%f" -o "%~nf.png"

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
@maitrungduc1410
maitrungduc1410 / create-vod-hls-gpu.sh
Last active June 28, 2024 04:22
Bash scripts to create VOD HLS stream with ffmpeg using GPU
#!/usr/bin/env bash
START_TIME=$SECONDS
set -e
echo "-----START GENERATING HLS STREAM-----"
# Usage create-vod-hls-gpu.sh SOURCE_FILE [OUTPUT_NAME]
[[ ! "${1}" ]] && echo "Usage: create-vod-hls.sh SOURCE_FILE [OUTPUT_NAME]" && exit 1
# comment/add lines here to control which renditions would be created
renditions=(
@KangHidro
KangHidro / banks.md
Last active June 2, 2024 05:35
Đăng ký tài khoản ngân hàng để tối ưu trải nghiệm sử dụng và các loại phí

Đăng ký tài khoản ngân hàng để tối ưu trải nghiệm sử dụng và các loại phí

Link bài viết này (để copy cho nhanh ý mà :v): http://bit.ly/optimizeBanks

  • Cách mình trình bày dưới đây chỉ mang tính chất chia sẻ kinh nghiệm nhé!
  • Tuy các giao dịch mình làm qua app, online, ít khi phải ra ngân hàng nhưng vì giờ đa số các ngân hàng đã miễn hầu hết các loại phí nên mình sẽ bàn thêm về trải nghiệm CSKH và một số tiện ích khác nữa.
  • Chắc chắn tuỳ khu vực sẽ có "chỗ this chỗ that" rồi, nên nếu bạn ưng bụng ngân hàng nào trước rồi thì cứ dùng thôi nhé!

TLDR → BÀI KHÁ DÀI, NẾU KHÔNG MUỐN ĐỌC HẾT THÌ MÌNH SẼ CHỌN NHANH COMBO CHO BẠN