Skip to content

Instantly share code, notes, and snippets.

View hostmaster's full-sized avatar
🏠
Working from home

Igor Khomyakov hostmaster

🏠
Working from home
  • Russia, Saint Petersburg
View GitHub Profile
@hostmaster
hostmaster / gcc compiler optimization for arm systems.md
Created October 24, 2018 11:40 — forked from fm4dd/gcc compiler optimization for arm systems.md
GCC compiler optimization for ARM-based systems

GCC compiler optimization for ARM-based systems

2017-03-03 fm4dd

The gcc compiler can optimize code by taking advantage of CPU specific features. Especially for ARM CPU's, this can have impact on application performance. ARM CPU's, even under the same architecture, could be implemented with different versions of floating point units (FPU). Utilizing full FPU potential improves performance of heavier operating systems such as full Linux distributions.

-mcpu, -march: Defining the CPU type and architecture

These flags can both be used to set the CPU type. Setting one or the other is sufficient.

# dict key tranformation table
_ssh_to_ansible = {
'user': 'ansible_ssh_user',
'hostname': 'ansible_ssh_host',
'identityfile': 'ansible_ssh_private_key_file',
'port': 'ansible_ssh_port'
}
# host_config = config.lookup(box_name) # dict
temp = {}
@hostmaster
hostmaster / borgbackup.sh
Created May 3, 2020 20:14 — forked from Jorijn/borgbackup.sh
This is the script I use to backup my macbook to a borgbackup repository. It should be a drop-in script and suit most users just fine, but I do recommend looking at the values and making them fit for your specific situation.
#!/bin/bash
# Setting this, so the repo does not need to be given on the commandline:
export BORG_REPO='*******'
# Setting this, so you won't be asked for your repository passphrase:
export BORG_PASSPHRASE='*******'
# some helpers and error handling:
function info () { echo -e "\n"`date` $@"\n" >&2; }
@hostmaster
hostmaster / authorized_keys.j2
Last active August 2, 2021 20:02
Purge unmanaged keys from ~/.ssh/authorized_keys , keep only listed public keys
# {{ ansible_managed }}
{% for key in pub_keys.results %}
{{ key.stdout }}
{% endfor %}
@hostmaster
hostmaster / nginx.conf
Created March 7, 2012 11:19
nginx post-action
location ^~ /attachments/download_zip/ {
proxy_pass http://mongrel;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_Forwarded_Proto $scheme;
proxy_read_timeout 120;
proxy_connect_timeout 120;
post_action @notify_zip

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

#!/bin/bash
URL=http://www.mythic-beasts.com/cgi-bin/job.pl
curl -s ${URL} |
gawk '
/Evaluate/ {
gsub (/([[:alpha:]]|[[:space:]]|[,.<>/])/,"", $0);
print $0 |& "bc";
"bc" |& getline res;
@hostmaster
hostmaster / playbook.yml
Created January 12, 2014 14:55
ansible playbook choose APT or YUM for package installation
- name: Install wget package (Debian based)
  action: apt pkg='wget' state=installed
  only_if: "'$ansible_pkg_mgr' == 'apt'"
 
- name: Install wget package (RedHat based)
  action: yum name='wget' state=installed
  only_if: "'$ansible_pkg_mgr' == 'yum'"
@hostmaster
hostmaster / registry_ls.sh
Last active April 28, 2020 10:44
get a list package versions in GitHub Package Repository
#!/bin/bash
set -eo pipefail
TOKEN=${GITHUB_TOKEN:?environment variable is empty or unset}
[ -n "$1" ] && GITHUB_REPOSITORY=$1
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:? please provide a name of a repository}
OWNER=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)
@hostmaster
hostmaster / README.md
Last active February 27, 2020 10:44
Lua script for redis_exporter
$ redis-cli -eval Redis_queue.lua