Skip to content

Instantly share code, notes, and snippets.

@ypchen
ypchen / checkHostALive.bash
Created November 3, 2017 05:40
Check if the given host (e.g., ptt.cc) is alive by using ping or nc
#!/bin/bash
# toTelegram.bash is at https://gist.github.com/ypchen/66714ab493a645ac059fc7bd72aa4884
#checkCommandPrefix='ping -c 1 -w 10'
#checkCommandSuffix=''
checkCommandPrefix='nc -z -w 10 -v'
checkCommandSuffix='22'
hostToCheck="ptt.cc" ; sleepSec=20 ; successValue=0 ; while true ; do date ; ip=`nslookup ${hostToCheck} | grep "Address" | tail -n 1 | cut -f 2 -d ' ' | tr -d '\n'` ; echo "Check ${hostToCheck} [${ip}] by using \"${checkCommandPrefix} ${ip} ${checkCommandSuffix}\"" ; ${checkCommandPrefix} ${ip} ${checkCommandSuffix} &> /dev/null ; if [ $? -eq $successValue ]; then break ; fi ; echo Sleep for ${sleepSec} seconds ; sleep ${sleepSec} ; done ; toTelegram.bash "${hostToCheck} is alive." &> /dev/null
@ypchen
ypchen / gist:a1a231baec95c0cc91c0fef8686c5d9a
Created September 4, 2017 05:02
Watching names of files and directories & sending a Telegram message
# Usage: copy & paste in the bash cli
# toTelegram.bash is at https://gist.github.com/ypchen/66714ab493a645ac059fc7bd72aa4884
# Watch directly
WATCH_WORDS="WORDS_TO_WATCH"
SLEEP_SECS=120
while true; do
if [ "`ls | grep \"${WATCH_WORDS}\"`" == "" ]; then
echo Current watch result: `ls | grep "${WATCH_WORDS}"`
echo Keep watching... sleep for ${SLEEP_SECS} seconds
#!/bin/bash
if [ -z "${1}" ]; then
echo "${0}" "(URL-encoded)message"
exit 1
fi
execute-gist.bash ff36d174f2412f75a3384b7d5aa97b1e "${1}"
@ypchen
ypchen / execute-gist.bash
Last active June 25, 2017 14:59
Execute a gist (with the specified gist hash)
#!/bin/bash
if [ -z "${1}" ]; then
echo "${0}" gist_hash [args... ]
fi
FILE_HASH="${1}"
shift
# default
@ypchen
ypchen / message-to-Telegram.bash
Last active March 6, 2022 09:07
Send a message to Telegram
#!/bin/bash
# default
if [ -z ${CURL+x} ]; then
CURL="/usr/bin/curl"
fi
if [ -z ${ECHO+x} ]; then
ECHO="/usr/bin/echo"
fi
if [ -z ${CUT+x} ]; then
@ypchen
ypchen / hdp-ims_v0.0.3.py
Last active May 24, 2017 12:32
Auto-update for plugin.video.hdp_ims
def my_gist_hash ():
return '23e0c39ed3db348baaeef0829023d921'
def my_version ():
return '0.0.3-gist'
@ypchen
ypchen / hdp-ims_v0.0.2.py
Last active May 24, 2017 12:31
Auto-update for plugin.video.hdp_ims
def my_gist_hash ():
return '777febfcc310e7b1857d3f08433d3af4'
def my_version ():
return '0.0.2-gist'
@ypchen
ypchen / hdp-ims_v0.0.1.py
Last active May 24, 2017 12:30
Auto-update for plugin.video.hdp_ims
def my_gist_hash ():
return 'fe629efa7e8a60ff648896306f1318ce'
def my_version ():
return '0.0.1-gist'
@ypchen
ypchen / RPI3-LibreELEC-TVChannels.strm
Last active March 28, 2017 11:47
TVChannels.strm
#EXTM3U
#EXTINF:0,TVBS 綜合台
http://210.201.54.102:1935/live/tvbs_sp.sdp/playlist.m3u8|User-Agent=iPad
#EXTINF:0,TVBS 新聞台
http://61.222.191.61/live/ch27/playlist.m3u8
#EXTINF:0,八大第一台
http://61.216.131.1/live/ch23/playlist.m3u8
#EXTINF:0,八大綜合台
http://61.216.131.1/live/ch25/playlist.m3u8
#EXTINF:0,壹電視新聞台
<?xml version="1.0" encoding="UTF-8"?>
<!-- For kodi (v17 / v18) -->
<!-- 2019-0424 -->
<!-- ### custom keymaps for 'ID 1d57:ad02 Xenta SE340D PC Remote Control' ### -->
<!-- https://discourse.osmc.tv/t/ir-remote-using-cheap-usb-pc-remote-with-osmc/18695 -->
<!-- A: 389185; B: 389265; C: 389266; D: 389156; TAB: 61449; WIN: 2159104; ESC: 61647 -->
<!-- v18 - [WWW], [WIN] do not work on Raspberry PI 3 -->
<!-- [WWW], [ABCD], [MY PC], [DESKTOP] do not work on QNAP -->
<keymap>
<global>