Skip to content

Instantly share code, notes, and snippets.

View pmint93's full-sized avatar
Working from anywhere

Thanh Pham Minh pmint93

Working from anywhere
View GitHub Profile
# Author: pmint93
# Exercise: https://www.facebook.com/groups/718037468264021/permalink/765003373567430/
class Greeter
def self.hello(file = '')
yield if defined? yield
eval open(file).read if File.exist? file
end
end
def run
n = 1_000
id = User.first.id
display_name = User.only(:display_name).find(id).display_name
Benchmark.bm(50) do |x|
x.report('User.find(id).display_name') do
n.times{ User.find(id).display_name }
end
@pmint93
pmint93 / rmq_queue_cleaner.js
Last active August 29, 2015 14:24
Delete rabbitMQ queues by name matching
// Author: pmint93
function run(virtual_host, mask, auth){
var trs = $('.updatable table.list tbody tr');
var queues = trs.each(function(i, v){
var name = $(v).find('td').eq(1).text();
console.log(name);
if(name.match(mask)){
$.ajax({
method: 'GET',
@pmint93
pmint93 / fontbox.vn.downloader.temp.js
Created September 19, 2015 02:56
Fontbox.vn Temporary Downloader fix
//Buy Form
jQuery.fn.fontbox_buy_form = function(variables){
var z_this_form = jQuery(this);
var a_check_all = jQuery('#buy_check_all');
var b_check_box_child_class = '.buy-check-box';
var c_check_box_class = '.check-box';
var d_total_price = 0;
var e_total_price_obj = jQuery('#buy_total_price');
var f_total_check_box_child = jQuery(b_check_box_child_class).size();
var g_download_iframe = jQuery('#buy_download_iframe');

Make IP phone call

METHOD: SOAP
URL: http://remote_host/TPCDialOut2/services/CallCenter?wsdl
PARAMS:
  agent_code: <Staff email>
@pmint93
pmint93 / encrypt_openssl.md
Created January 5, 2018 04:28 — forked from dreikanter/encrypt_openssl.md
File encryption using OpenSSL

Symmetic encryption

For symmetic encryption, you can use the following:

To encrypt:

openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt

To decrypt:

@pmint93
pmint93 / rabbitmq-autocluster_k8s_persistent.bash
Last active March 23, 2019 03:14
Deploy rabbitmq-autocluster on k8s with persistent storage
#!/bin/bash
set -eo pipefail
export KUBE_NAMESPACE=test
export REPLICA_COUNT=3
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1beta1
kind: StatefulSet
@pmint93
pmint93 / self-signed-certificate-with-custom-ca.md
Created April 11, 2019 09:15 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@pmint93
pmint93 / k8s-dhcp-renew
Last active January 20, 2026 04:56
Renew DHCP through DaemonSet (example for eth1 interface)
apiVersion: apps/v1
kind: DaemonSet
metadata:
annotations:
labels:
app: dhcp-renew
name: dhcp-renew
namespace: kube-system
spec:
selector:
@pmint93
pmint93 / k8s-ip-monitor-ds.yaml
Created December 31, 2022 03:39
Monitor ip stack on K8s nodes from DaemonSet, for debugging purpose
apiVersion: apps/v1
kind: DaemonSet
metadata:
annotations:
labels:
app: ip-monitor
name: ip-monitor
namespace: kube-system
spec:
selector: