Skip to content

Instantly share code, notes, and snippets.

@x86demon
x86demon / telegram_send.py
Created May 15, 2020 14:23
Send message to telegram from cli (for Asus rt-n66u)
import requests
import sys
def telegram_bot_sendtext(bot_message):
bot_token = '***'
bot_chatID = '***'
api_url = 'https://api.telegram.org/bot' + bot_token + '/sendMessage'
data = {'chat_id': bot_chatID, 'text': bot_message}
@x86demon
x86demon / block_sip_spammers.sh
Created May 15, 2020 14:21
Block asterisk password brute force in Asus RT-n66u
#!/bin/sh
IPS=$(cat /opt/var/log/asterisk/messages | grep -oE "failed for '([^:]*)" | grep -oE '[0-9]+\.[0-9]+\.[0-9+]+\.[0-9]+' | sort | uniq)
[ -z "$IPS" ] && exit 0
for ip in ${IPS}
do
echo "Blocking IP: ${ip}"
iptables -I INPUT -s ${ip} -j DROP
echo "iptables -I INPUT -s ${ip} -j DROP" >> /jffs/scripts/firewall-start
@x86demon
x86demon / gist:0de22a61f75c26da8807039502c65228
Created February 6, 2020 16:24
ES7 increase max shards
curl -XPUT localhost:9200/_cluster/settings -H 'Content-type: application/json' --data-binary $'{"transient":{"cluster.max_shards_per_node":20000}}'
phpspy -p 25109 -b 40960 | /usr/local/src/phpspy/stackcollapse-phpspy.pl | /usr/local/src/phpspy/vendor/flamegraph.pl > flame.svg
-- Create materialized view to store all price list prices as MD5 hash
CREATE MATERIALIZED VIEW prices AS select price_list_id, MD5(array_agg(pp.quantity::text || pp.unit_code || pp.value::text || pp.currency ORDER BY pp.quantity, pp.unit_code, pp.value::text, pp.currency)::text) as pmd5 FROM oro_price_product pp GROUP BY price_list_id;
-- Add index for md5 to improve performance
CREATE INDEX pmd5_idx ON prices(pmd5);
-- SELECT base price list, number of duplicated price lists and concatenated ids of duplicates
select p1.price_list_id, COUNT(p2.price_list_id), array_agg(p2.price_list_id ORDER BY p2.price_list_id) from prices p1 INNER JOIN prices p2 on p1.pmd5 = p2.pmd5 AND p1.price_list_id <> p2.price_list_id WHERE p1.price_list_id = (SELECT MIN(price_list_id) FROM prices WHERE p1.pmd5 = pmd5) GROUP BY p1.price_list_id ORDER BY p1.price_list_id;
-- SELECT overall number of unique price lists
SELECT COUNT(DISTINCT pmd5) from prices;
-- DROP VIEW
DROP MATERIALIZED VIEW prices;
@x86demon
x86demon / oro_db
Last active June 24, 2024 19:58
Small script for dump/restore database
#!/bin/bash
APP_CONSOLE="bin/console"
CONFIG_DIR="config"
ENV=""
if [[ $2 == 'test' ]]
then
ENV='_test'
fi
#!/bin/bash
currentDir=${PWD##*/}
repoDir=$(basename $(dirname $(dirname $(readlink -f .))))
APP_HOST=$currentDir.$repoDir.loc
APP_CONSOLE="app/console"
INDEX="app_dev.php"
if [[ ! -f ${APP_CONSOLE} ]]
then
@x86demon
x86demon / category.csv
Last active July 14, 2017 16:49
OroNeo Review
code label-en_US parent
master Master catalog
cat_11 Category 1.1 master
cat_111 Category 1.1.1 cat_11
cat_12 Category 1.2 master
@x86demon
x86demon / apache.conf
Created July 7, 2017 08:40
WSS clank
<VirtualHost *:8080>
ServerName %HTTP_HOSTNAME%
SSLEngine on
SSLCertificateFile "%HTTP_SSL_CRT%"
SSLCertificateKeyFile "%HTTP_SSL_KEY%"
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule .* ws://%WS_TARGET_IP%:8080%{REQUEST_URI} [P,L]
ProxyPreserveHost On
[ 0.000000] Booting Linux on physical CPU 0x500
[ 0.000000] Linux version 4.12.0-rc6-The-Twelve-MyyQi+ (gamer@tachibana) (gcc version 5.4.0 (Gentoo 5.4.0 p1.0, pie-0.6.5) ) #3 SMP PREEMPT Tue Jun 20 03:38:14 UTC 2017
[ 0.000000] CPU: ARMv7 Processor [410fc0d1] revision 1 (ARMv7), cr=10c5387d
[ 0.000000] CPU: div instructions available: patching division code
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: Rockchip RK3288 Tinker Board
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] On node 0 totalpages: 524288
[ 0.000000] free_area_init_node: node 0, pgdat c13e1800, node_mem_map eeff9000
[ 0.000000] Normal zone: 1536 pages used for memmap