Skip to content

Instantly share code, notes, and snippets.

// Website you intended to retrieve for users.
const upstream = 'api.openai.com'
// Custom pathname for the upstream website.
const upstream_path = '/'
// Website you intended to retrieve for users using mobile devices.
const upstream_mobile = upstream
// Countries and regions where you wish to suspend your service.
@afeicool
afeicool / video_sub_dl.sh
Created January 16, 2023 04:25 — forked from nickyfoto/video_sub_dl.sh
Download video and its subtitle and merge subtitle to it.
# list available subtitles
# https://superuser.com/questions/927523/how-to-download-only-subtitles-of-videos-using-youtube-dl
youtube-dl --list-subs https://www.youtube.com/watch?v=lmWh9jV_1ac
# download a particular subtitle
youtube-dl --write-sub --sub-lang zh-CN --skip-download https://www.youtube.com/watch\?v\=lmWh9jV_1ac
# download auto generated sub
youtube-dl --write-auto-sub --sub-lang zh-CN --skip-download https://www.youtube.com/watch\?v\=lmWh9jV_1ac
@afeicool
afeicool / gist:7b0ed6e44e1ce4f40087e573479a6681
Created September 29, 2022 02:48 — forked from michalbcz/gist:4170520
java - https url connection - trust any certificate
import java.net.URL;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
@afeicool
afeicool / ffmpeg.md
Created February 22, 2022 05:47 — forked from liangfu/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@afeicool
afeicool / ApiApplication.java
Created November 12, 2021 08:35 — forked from yurikilian/ApiApplication.java
Soft Delete Mongo Repository
import br.com.radharsomeluz.inventory.configuration.SoftDeletionMongoRepository;
import br.com.radharsomeluz.inventory.configuration.SoftDeletionRepositoryFactoryBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableSwagger2
@EnableMongoRepositories(
@afeicool
afeicool / remap-capslock-to-control-win10.md
Created July 15, 2021 07:39 — forked from joshschmelzle/remap-capslock-to-control-win10.md
Remap Caps Lock to Control on Windows 10

Ways to remap caps lock to control on Windows 10

These methods in this gist worked for me on my U.S. based keyboard layouts. I am unsure about other layouts. If you have problems, revert your changes; delete the registry key you created (and reboot).

Approach 1. Manually through regedit

Navigate to and create a new binary value in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout named Scancode Map.

You will enter the raw bytes like this (thanks @quapka):

@afeicool
afeicool / config-git-proxy.txt
Created April 9, 2020 08:44 — forked from bynil/config-git-proxy.txt
Use git over socks5 proxy
Port: 1080
1. Create a file /YOUR PATH/gitproxy.sh with content:
#!/bin/sh
nc -X 5 -x 127.0.0.1:1080 "$@"
2. Edit your ~/.gitconfig
# For git://
@afeicool
afeicool / Count Code lines
Created October 9, 2019 05:56 — forked from amitchhajer/Count Code lines
Count number of code lines in git repository per user
git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n
@afeicool
afeicool / ClientHttpPoolConfiguration.java
Created May 13, 2019 07:20 — forked from soverby/ClientHttpPoolConfiguration.java
RestTemplate backed by Apache HttpClient Connection Pool. Addresses RestTemplate HttpConnection exhaustion. Note this implementation is not route tunable and should be expanded when tuning by route is required. Example error: I/O error on POST request for "https://someendpoint": Timeout waiting for connection from pool; nested exception is org.a…
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ClientHttpPoolConfiguration {
@afeicool
afeicool / README.md
Created October 9, 2018 07:39 — forked from arikfr/README.md
Redash Query Export Tool

Setup

$ pip install click requests

Usage

$ python query_export.py --redash-url "https://app.redash.io/" --api-key ""