Skip to content

Instantly share code, notes, and snippets.

View themactep's full-sized avatar

Paul Philippov themactep

View GitHub Profile
@themactep
themactep / chopchop.rb
Last active March 3, 2024 10:09
Firmware spitter
#!/bin/ruby
# frozen_string_literal: true
#
# Firmware spitter
# Paul Philippov <[email protected]>
#
# 2022-11-16: Initial version
# 2023-04-16: Support for dd older than v9.0
# Use the last found mtdparts
# 2024-03-02: Extract an arbitrary range of addresses
@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
#
#
@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
#!/bin/sh
#
# ANSI color codes
# Paul Philippov, themactep.com
#
for k in {1..9}; do
for i in {0..9}; do
echo -en " \e[1;${k}${i}m$(printf "%02s" "${k}${i}")\e[0m"
done
echo
#!/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 / swirl.rb
Created November 22, 2012 09:28
Outward spiral matrix builder
#!/usr/bin/env ruby
#
# Outward spiral matrix builder
# 2012, Paul Philippov <[email protected]>
#
def show_usage
puts 'Usage: $0 <number>'
exit
end
@themactep
themactep / formtocookie.js
Last active July 24, 2017 15:30
How to save form to cookies, restore form from cookies. Requires jQuery and jQuery Cookie plugin.
/*
* Save Form To Cookie
* (cc) Paul Philippov, [email protected]
*
* This is rather a proof of concept than a production-ready solution.
* It does not handle all kinds of fields.
* You might want to extend it to suit your needs.
*
* Requirements:
*
<pre>
<%= "<em>text</em>".class %>
<%= raw("<em>text</em>").class %>
<%= "<em>text</em>" %>
<%= raw("<em>text</em>") %>
<%= ["<em>text</em>"].join %>
<%= [raw("<em>text</em>")].join %>
<?php
// php equivalent of ruby one-liner
// "строка текста!".chars.to_a.last
function u_str_split($string, $split_length=1)
{
preg_match_all('`.`u', $string, $arr);
$arr = array_chunk($arr[0], $split_length);
$arr = array_map('implode', $arr);
return $arr;
#
# a request to http://lastfm-api-ext.appspot.com/2.0/
# with outtype=js sometimes gives me an error like this:
#
Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 507, in __call__
handler.get(*groups)
File "/base/data/home/apps/lastfm-api-ext/1.178/main.py", line 60, in get
result = packages[package](params)[method]()