Skip to content

Instantly share code, notes, and snippets.

View hamid914's full-sized avatar

Hamid Rouhani hamid914

View GitHub Profile
@dkuku
dkuku / .i3blocks.conf
Created March 13, 2019 00:44
i3blocks - toggle services like docker or redis
[docker]
command=$HOME/systemctl
interval=once
markup=pango
[redis]
command=$HOME/systemctl
interval=once
markup=pango
@mmalone
mmalone / example.sh
Created February 12, 2019 22:14
Using `step certificate` without the online step CA
# Create a root certificate and signing key.
$ step certificate create "Root CA" root.crt root.key --profile root-ca
Please enter the password to encrypt the private key:
Your certificate has been saved in root.crt.
Your private key has been saved in root.key.
# Create an intermediate certificate & signing key. This isn't
# required; we could use the root to sign directly which is
# probably fine for local dev and removes the need to bundle later.
$ step certificate create "Intermediate CA" int.crt int.key --profile intermediate-ca --ca root.crt --ca-key root.key
@mhofman
mhofman / HAProxy-transparent-web-services-routing.md
Last active April 4, 2024 01:20
Leverage HAProxy to transparently route requests to web services identified by host name.

Web Service Fronting

Multiple Web properties on a single IP address

Hosting multiple websites on a single public IP address on the standard HTTP(S) ports is relatively easy with popular web servers like Apache, Nginx and lighttpd all supporting Virtual Hosts.
For Web Services which bundle their own HTTP server, things get more complicated, unless their HTTP stack can be shared somehow. More often than not, the application's HTTP stack listens directly on a dedicated TCP port.

Hosting multiple services on a single IP then requires using a fronting server listening on the standard HTTP port, and routing to the right backend service based on the host name or the path sent by the client.
Path based routing is cumbersome, usually requiring either the service to be aware of the path prefix, or a rewrite by the HTTP fronting server of all absolute URLs in the requests and responses.
Hostname based routing is more straightforward. The fronting server can just look at the [HTTP/1.1 Host header](https://tools

@woogists
woogists / wc-add-depending-cart-total.php
Last active November 7, 2022 12:38
Add another product depending on the cart total
/**
* Add another product depending on the cart total
*/
add_action( 'template_redirect', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 2831; //replace with your product id
$found = false;
$cart_total = 30; //replace with your cart total needed to add above item
@VojtechKlos
VojtechKlos / split_silence.sh
Created October 12, 2017 14:10
Guide to split audio recording by silence with SoX and ffmpeg
# First denoise audio
## Get noise sample
ffmpeg -i input.ogg -vn -ss 00:00:00 -t 00:00:01 noise-sample.wav
## Create noise profile
sox noise-sample.wav -n noiseprof noise.prof
## Clean audio from noise
sox input.ogg clean.wav noisered noise.prof 0.21
/**
* Open https://app.snapp.ir
* Login with your credentials
* Copy and pasting this code in developer tools console
* Waiting... :)
*/
(async function () {
function sleep(ms = 0) {
return new Promise(r => setTimeout(r, ms));
}
@tayvano
tayvano / gist:6e2d456a9897f55025e25035478a3a50
Created February 19, 2017 05:29
complete list of ffmpeg flags / commands
Originall From: Posted 2015-05-29 http://ubwg.net/b/full-list-of-ffmpeg-flags-and-options
This is the complete list that’s outputted by ffmpeg when running ffmpeg -h full.
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
Getting help:
-h — print basic options
-h long — print more options
-h full — print all options (including all format and codec specific options, very long)
@jatcwang
jatcwang / gist:ae3b7019f219b8cdc6798329108c9aee
Created February 2, 2017 23:44
List of all setxkbmap configuration options (including models/layout/etc)
! model
pc101 Generic 101-key PC
pc102 Generic 102-key (Intl) PC
pc104 Generic 104-key PC
pc105 Generic 105-key (Intl) PC
dell101 Dell 101-key PC
latitude Dell Latitude series laptop
dellm65 Dell Precision M65
everex Everex STEPnote
flexpro Keytronic FlexPro
@dleonard00
dleonard00 / explode-opvn.sh
Created January 15, 2017 07:31
extract the certificate and key from an .ovpn file
#!/bin/bash
# This script will extract the certificate and key from an .ovpn file
# into their own files, which makes it possible to use them to configure
# the VPN using Ubuntu's network manager
# Usage example:
# >> ovpnconvert username.dev.ovpn
# You can keep following these instructions here:
@joselitosn
joselitosn / pysmb.py
Created March 16, 2016 13:45
Python SMB Example
from smb.SMBConnection import SMBConnection
userID = 'user'
password = 'password'
client_machine_name = 'localpcname'
server_name = 'servername'
server_ip = '0.0.0.0'
domain_name = 'domainname'