Skip to content

Instantly share code, notes, and snippets.

View themactep's full-sized avatar

Paul Philippov themactep

View GitHub Profile
@themactep
themactep / get_ip.sh
Created September 4, 2022 03:17 — forked from LozanoMatheus/get_ip.sh
Get Linux IP without any tool
#!/usr/bin/env bash
## Get the primary and secundary IPs
awk '/\|--/ && !/\.0$|\.255$/ {print $2}' /proc/net/fib_trie
## Get only the primary IPs
awk '/32 host/ { print i } {i=$2}' /proc/net/fib_trie
@themactep
themactep / ipcam-clock-set.pl
Created September 9, 2022 00:56 — forked from 667bdrm/ipcam-clock-set.pl
Simple clock synchronization for some chinese DVRs supporting CMS with json-like protocol. Includes some other API commands. Fork at https://gitlab.com/667bdrm/sofiactl
#!/usr/bin/perl
# latest release at https://gitlab.com/667bdrm/sofiactl
#
# Simple clock synchronization for some chinese HiSilicon based DVRs supporting CMS (Sofia software) with json-like protocol. Tested with:
#
# HJCCTV HJ-H4808BW (XiongMai, Hi3520, MBD6304T)
# http://www.aliexpress.com/item/Hybird-NVR-8chs-H-264DVR-8chs-onvif-2-3-Economical-DVR-8ch-Video-4-AUDIO-AND/1918734952.html
#
#
#!/bin/bash
#
# Convert deprecated apt-key keys storage to GPG keys.
# Paul Philippov <paul@themactep.com>
#
keys=$(sudo apt-key list | grep -A1 ^pub | grep "^ " | sed "s/\s*//g" | sort | uniq)
for k in $keys; do
sudo apt-key export $k | \
sudo gpg --dearmour -o /usr/share/keyrings/$k.gpg --yes &&
#!/bin/sh
# GPIO switcher
# Paul Philippov <paul@themactep.com>
PIN=$1
MODE=$2
if [ -z "$PIN" ] || [ -z "$MODE" ]; then
echo "Usage: $0 <pin#> <1|0|x>"
exit 1
#!/bin/sh
# Convert text from GB 2312 charset to Unicode, translate to English.
# cn2en.sh <file.txt>
# Paul Philippov <paul@themactep.com>
# 20200926
infile=$1
cnfile="${infile%.*}.cn.${infile##*.}"
enfile="${infile%.*}.en.${infile##*.}"
// ==UserScript==
// @name CSDN tweaker
// @namespace http://themactep.com/
// @version 0.1
// @description Show full articles
// @author paul@themactep.com
// @match https://*.blog.csdn.net/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=csdn.net
// @grant none
// ==/UserScript==
#!/bin/sh
# Compression test
# Paul Philippov <paul@themactep.com>
payload=""
name="payload"
in="${name}.txt"
[ -d ./test_data/ ] && rm -r ./test_data/
[ ! -d ./test_data/ ] && mkdir ./test_data/
#!/bin/sh
#
# Binary file padder.
# Pads binary file with 0xFF to match full size of flashing chip.
#
# Example:
# ./binpadder.sh openipc-u-boot-t10-universal.bin 8
#
# Running this command will produce a new binary file
# openipc-u-boot-t10-universal-8MB-padded.bin
@themactep
themactep / scad2png.sh
Created May 9, 2023 03:06
thumbnailer for .scad files
#!/bin/bash
# .SCAD files thumbnailer
# 2022, Paul Philippov, paul@themactep.com
OS=$(command -v openscad || command -v openscad-nightly)
$OS -o "$2.png" -D "\$fn=128" --autocenter --viewall \
--colorscheme="Tomorrow Night" -q "$1"
[ ! -f "$2.png" ] && echo "Cannot find image!" && exit 1
@themactep
themactep / stl2png.sh
Created May 9, 2023 03:06
thumbnailer for .stl files
#!/bin/bash
# .STL files thumbnailer
# 2022, Paul Philippov, paul@themactep.com
set -euo pipefail
OS=$(command -v openscad || command -v openscad-nightly)
IFS=$'\n\t'