Skip to content

Instantly share code, notes, and snippets.

@wonderbeyond
wonderbeyond / set-apt-proxy.md
Last active May 6, 2024 09:11
[ubuntu][socks5][proxy] Set proxy for apt

Writing an apt proxy conf file /etc/apt/apt.conf.d/proxy.conf as below.

Acquire::http::Proxy "socks5h://127.0.0.1:1080";
Acquire::https::Proxy "socks5h://127.0.0.1:1080";
Acquire::socks::Proxy "socks5h://127.0.0.1:1080";

And the proxy settings will be applied the next time we run apt.

@dmmeteo
dmmeteo / 1.srp.py
Last active April 27, 2024 05:48
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@bartman
bartman / watch-cgroup-memory-usage
Last active November 17, 2021 15:19
watch-cgroup-memory-usage
#!/bin/bash
#
# watch cgroup 'browsers' memory activity
#
# best served with ...
#
# https://gist.github.com/jakewarren/477ecd1149abe908cbd5cf7a7c9abaa3
self=$0
SUDO=
{
"red": {
"50": "#ffebee",
"100": "#ffcdd2",
"300": "#e57373",
"500": "#f44336",
"700": "#d32f2f",
"800": "#c62828",
"900": "#b71c1c"
},
@mkjaer
mkjaer / create-unattended-iso.sh
Created May 28, 2018 09:17
Create unattended Ubuntu ISO
#!/bin/bash
cd $(dirname "${0}")
UBUNTU_VERSION=${UBUNTU_VERSION:=16.04.3}
INSTALL_HOSTNAME=${INSTALL_HOSTNAME:=ubuntu}
USERNAME=${USERNAME:=username}
PASSWORD=${PASSWORD:=password}
SEED_FILE=${SEED_FILE:=lvm.seed}
TIMEZONE=${TIMEZONE:=$(cat /etc/timezone)}
@dideler
dideler / bot.rb
Last active April 17, 2024 08:40
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@jesugmz
jesugmz / Python-docstring-restructuredtext-style.rst
Last active April 24, 2024 14:34
Python docstring reStructuredText style

Python docstring reStructuredText style

Python Signatures

Signatures of functions, methods and class constructors can be given like they would be written in Python.

@openscript
openscript / README.md
Last active April 11, 2019 10:48
This bash script can be used to encrypt secrets for a Travis CI configuration (`.travis.yml`) with the project specific public key.

Usage

  • Download script travis-encrypt.sh
  • Make it executable chmod +x travis-encrypt.sh
  • Run the script with ./travis-encrypt.sh -r username/repositoryname -e example
    • It will return something like O+woVD9K+PeFrcyu5GCjKSFvfcSPwDW0kyDYEQnNbwt/iSkqjpl2OPA9W//KEKEB9UUSZD+XmQ3Ij0gnvJnOowcWY5sSeJlVEVTrSer0kW6uWpa/uWzDHCBz2YhBnI6u9SfYfMkhDl22pcaCEwaUkmK2gjcVo+v0bS8vAQFz0Na5/WiKj0GkSX50iIGgfaXheuC8KgIC25T0h+czpap7vb13OlblMnClfyTH9+TmAwTlcV7ljXpv1QY+K72L8jK1/CQVZ8quBYrBwwxO2V6cpXRMMCIw4m4lqxUyN4FBGnq7cJ7BWLzeqSMpFBoP+ZxAqS5yem8KLh1VkEo7PVjCkZE6M+2meFf2VJEVUs/KJY9xnH3eDzipWkwXon2qVpCkT7FDEzGFs/DapYsSo7eCO6pUYYhcpaYpWeYV9DSSV0QcrOeZp664iJMHWPSmrs/lESbbHpKWsM/AFVB9X75q/OB+QU0tQxpReZmKw3ZHbDVMlmlwhP8VSiQ05LV2W6gYzADGiUiL6n1X8teeHEVDSZnD7nrxMD/FchnWI5La3tZeFovRMf6hH3NItW+QZaGaGNftJrP488J/F2hCycPJk3+YrxbBCGHE2X379QbkMz3S0B5UiAcJKmwuTstF6X3CCurZVYIkUGGXhnmalPtVpEqxeTiLw5RU6C9z2qSwhhw=
  • Use the encrypted secret in your .travis.yml according to https://docs.travis-ci.com/user/encryption-keys/#Usage
@keiya
keiya / README.md
Last active April 22, 2024 06:43
How to broadcast to Icecast2 by using ffmpeg (FLAC,Opus,Vorbis,AAC,MP3/Windows, Mac)

FFMpeg to Icecast2 Streaming Samples

Examples usage of various codecs with FFMpeg.

Samples

  • flac.sh : An Icecast Source Client
    • for Windows (Cygwin is required)
    • and macOS (brew install ffmpeg)
  • another_examples.sh : Samples
  • FFMpeg can push to Icecast2 in various formats: Opus/Vorbis/AAC/MP3
@mhf-ir
mhf-ir / sheba.js
Created November 24, 2017 09:48
iranian sheba bank validation javascript | اعتبار سنجی کد شبا با جاوا اسکریپت
function iso7064Mod97_10(iban) {
var remainder = iban,
block;
while (remainder.length > 2){
block = remainder.slice(0, 9);
remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
}
return parseInt(remainder, 10) % 97;