Skip to content

Instantly share code, notes, and snippets.

View anhldbk's full-sized avatar
🌴
Calm

Anh Le (Andy) anhldbk

🌴
Calm
View GitHub Profile

LiteLLM: Bypass Cert Verifications

Overview

If you use LiteLLM to proxy requests to Ollama.ai in corporate environments, you may encounter the following error in your Python application:

httpcore.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)
@anhldbk
anhldbk / README.md
Last active March 3, 2024 16:36
TLS client & server in NodeJS

1. Overview

This is an example of using module tls in NodeJS to create a client securely connecting to a TLS server.

It is a modified version from documentation about TLS, in which:

  • The server is a simple echo one. Clients connect to it, get the same thing back if they send anything to the server.
  • The server is a TLS-based server.
  • Clients somehow get the server's public key and use it to work securely with the server

2. Preparation

@anhldbk
anhldbk / remove_mqtt_retained_msgs.md
Last active December 25, 2023 20:38
Remove MQTT retained messages using MQTT.js version 1.10.x
var mqtt    = require('mqtt');
var lodash = require('lodash');
var client  = mqtt.connect({ host: 'localhost', port: 1883 });

client.on('connect', function () {
  console.log('Connected')
  client.subscribe('presence');
});
@anhldbk
anhldbk / tor-raw.cpp
Created December 6, 2016 02:38
Working with Tor (C/C++)
// g++ -lstdc++ -Wno-write-strings fetch.cpp -o fetch
#ifdef _WIN32 // Windows
#include <winsock2.h>
#include <ws2tcpip.h>
#define MSG_NOSIGNAL 0
#else // Linux + Mac
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@anhldbk
anhldbk / get_public_ip.py
Created October 13, 2014 07:23
Get public IP with Python & Requests
import requests
r = requests.get(r'http://jsonip.com')
ip= r.json()['ip']
print 'Your IP is', ip
@anhldbk
anhldbk / Selenium.Python.InjectJS.py
Last active April 15, 2023 03:53
Inject jQuery into Selenium Driver
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://www.facebook.com/')
with open('jquery-1.9.1.min.js', 'r') as jquery_js:
jquery = jquery_js.read() #read the jquery from a file
driver.execute_script(jquery) #active the jquery lib
driver.execute_script("$('#email').text('anhld')")
@anhldbk
anhldbk / install.sh
Created January 25, 2016 01:49
Install zmq on Centos
sudo yum install -f libtool
cd autoconf-2.68
chmod +x configure
./configure
chmod +x build-aux/git-version-gen
sudo make
sudo make install
cd ..

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@anhldbk
anhldbk / binder.js
Last active August 22, 2022 13:55
Bind this for all methods in ES6 classes
'use strict';
class Binder {}
Binder.getAllMethods = function(instance, cls) {
return Object.getOwnPropertyNames(Object.getPrototypeOf(instance))
.filter(name => {
let method = instance[name];
return !(!(method instanceof Function) || method === cls);
});
@anhldbk
anhldbk / blockchain.md
Created December 29, 2016 15:57
Blockchain applications

What are non-Bitcoin applications of blockchain technology?

"In 2015 Uber, the world's largest taxi company owns no vehicles, Facebook the world's most popular media owner creates no content, Alibaba the most valuable retailer has no inventory, and Airbnb the world's largest accommodation provider owns no real estate."*

Through collaboration and value distribution, decentralized autonomous organizations (DAOs) will be just as disruptive to the above centralized business models.

Currency