Skip to content

Instantly share code, notes, and snippets.

@darwis059
darwis059 / proxy.pac
Last active March 4, 2025 07:18
proxy.pac
function FindProxyForURL(url, host) {
// our local URLs from the domains below example.com don't need a proxy:
// if (shExpMatch(host, "*.reddit.com")) {
// return "DIRECT";
// }
// URLs within this network are accessed through
// port 8080 on fastproxy.example.com:
if (dnsDomainIs(host, ".reddit.com") || dnsDomainIs(host, ".redditspace.com")) {
return "SOCKS5 127.0.0.1:8082";
@darwis059
darwis059 / iptables_tproxy_example.sh
Created June 25, 2024 00:34 — forked from superstes/iptables_tproxy_example.sh
IPTables TPROXY - proxy input and output
#!/bin/bash
# target: squid-openssl 4.13 with listener "http_port 127.0.0.1:3129 tproxy"
# see also:
# https://docs.kernel.org/networking/tproxy.html
# https://blog.cloudflare.com/mmproxy-creative-way-of-preserving-client-ips-in-spectrum/
# https://latest.gost.run/en/tutorials/redirect/#forwarding-chain_1
# you might need to enable some iptables/nftables kernel modules:
@darwis059
darwis059 / 00_destructuring.md
Created November 25, 2022 07:49 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@darwis059
darwis059 / titleUrlMarkdownClip.js
Created August 10, 2021 13:59 — forked from idelem/titleUrlMarkdownClip.js
Bookmarklet to copy current page title and url in Markdown format to clipboard, like [title](url) - Usual for posting links to resources in README.md files
javascript:(function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
@darwis059
darwis059 / MainActivity.java
Created April 14, 2021 02:44 — forked from simlegate/MainActivity.java
something should android do when screen on and screen off .
package com.simlegate.saveresource;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
@darwis059
darwis059 / check_connection
Created March 23, 2021 00:43 — forked from gardner/check_connection
OpenWrt cron job to check the connection and, if there is no connection, reboot the Huawei E3272 modem using the hilink api.
#!/bin/ash
# OpenWrt cron job to check the connection and, if there is no connection,
# reboot the Huawei E3272 modem using the hilink api. This script is optimized
# for busybox and written in ash.
# Put this script in /bin/check_connection and then: chmod +x /bin/check_connection
# Then: crontab -e
# */15 * * * * /bin/check_connection > /tmp/reboot_con.log 2>&1
f="/tmp/reboot_lock"
if [ ! -f "$f" ]; then
@darwis059
darwis059 / protips.js
Created February 25, 2021 08:51 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@darwis059
darwis059 / bling.js
Created February 25, 2021 08:23 — forked from paulirish/bling.js
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;

Live stream Xiaomi Ants Smart Camera via FFMPEG

This assumes you have a Xiaomi Ants Smart Camera that still has the open RTSP enabled. I think newer firmware might remove this capability. If you Google enough you can find instructions on how to downgrade.

FFMPEG

FFMPEG is where most of the magic happens. I use OSX and as such am a fan of using Homebrew to install free software. Here is my ffmpeg install command:

brew install ffmpeg --with-faac --with-fdk-aac --with-ffplay --with-fontconfig --with-freetype --with-frei0r --with-libass --with-libbluray --with-libcaca --with-libquvi --with-libsoxr --with-libssh --with-libvidstab --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools --with-webp --with-x265

@darwis059
darwis059 / myweechat.md
Created January 30, 2021 16:03 — forked from researcx/myweechat.md
My always up-to-date WeeChat configuration (requires weechat 2.3-dev (weechat-devel) or higher)

idea and some snippets taken from pascalpoitras' weechat config

Enable mouse

/mouse enable

Set up encrypted data

/secure passphrase <pass>
/secure set relaypass <pass>
/secure set bitlbeepass <pass>
/secure set bncaddrport