Skip to content

Instantly share code, notes, and snippets.

View eplt's full-sized avatar

Edward Tsang eplt

View GitHub Profile
@eplt
eplt / digitalocean-lamp-heic.sh
Last active August 15, 2023 15:48
Install Imagemagick with HEIC on DigitalOcean LAMP Ubuntu 20.04
#!/bin/bash
start_time="$(date -u +%s)"
sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
apt-get update
apt-get -y install build-essential autoconf libtool git-core cmake
apt-get -y build-dep imagemagick libmagickcore-dev libde265 libheif
cd /usr/src/
git clone https://github.com/strukturag/libde265.git
git clone https://github.com/strukturag/libheif.git
cd libde265/
@eplt
eplt / telegrambot.txt
Created September 21, 2020 11:10
To create a Telegram Bot
Step 1: Get a bot id and keys
Add botfather to your telegram account. Follow the interactive mode to choose the id, and you will get key (sample below, use your own key!).
https://t.me/botfather
------
Done! Congratulations on your new bot. You will find it at t.me/sample_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
Use this token to access the HTTP API:
1338113001:AALZqz4svWKBGeGehAnU1hgHUnYmpmUCpEk
Keep your token secure and store it safely, it can be used by anyone to control your bot.
╔══════╦════════════╦═══════════════╦══════════╦════════════════════════╦══════╗
║ Node ║ Zookeeper ║ Kafka ║ Orderer ║ Peer ║ Cli ║
╠══════╬════════════╬═══════════════╬══════════╬════════════════════════╬══════╣
║ 1 ║ zookeeper0 ║ kafka0 kafka1 ║ orderer0 ║ peer0.org1.example.com ║ cli0 ║
║ 2 ║ ║ ║ ║ peer1.org1.example.com ║ cli1 ║
║ 3 ║ ║ ║ ║ peer2.org1.example.com ║ cli2 ║
╚══════╩════════════╩═══════════════╩══════════╩════════════════════════╩══════╝
@eplt
eplt / ubuntu-do.txt
Last active February 16, 2024 07:51
Ubuntu Cheatsheet - Commonly used commands for Ubuntu (18.04 and 20.04) on DigitalOcean
I use Ubuntu 18.04 Droplet on DigitalOcean often, this is a cheatlist of commands that I use often.
Use my link https://m.do.co/t/b298d6966c0c (Discount code for newbies, I get some free referral credits too) to sign up and start playing.
--- Check your OS version
cat /etc/os-release
--- DigitalOcean Ubuntu 14.04 do-agent (monitoring) install
curl -L -o ./install.sh https://insights.nyc3.cdn.digitaloceanspaces.com/install.sh
sed -i '17s/https/http/' install.sh
chmod 775 install.sh
@eplt
eplt / exifupdate.txt
Last active October 6, 2021 03:21
Update EXIF for Flickr uploading
-- Before uploading photos to Flickr, I use the following command to update copyright notice of all my images with EXIFTOOL http://owl.phy.queensu.ca/~phil/exiftool/
exiftool -r -m -P -overwrite_original_in_place -artist="OnDemandWorld 点应科技" -copyright="2009-2021 OnDemandWorld" -usercomment="Copyright © 2009-2021 OnDemandWorld 点应科技 OnDemandWorld.com" <Path>
@eplt
eplt / macOS.txt
Last active September 3, 2023 08:47
macOS Cheatsheet - Commonly used commands for my macOS Setup
-- Automate your macOS a bit more, schedule Safari to open your favourite sites regularly at 7am to save a few seconds each morning.
# In terminal, type the following command which will allow you to edit current scheduled jobs with nano editor
# You might need to grant cron full disk access for this to work. https://osxdaily.com/2020/04/27/fix-cron-permissions-macos-full-disk-access/
env EDITOR=nano crontab -e
# Then copy and paste the following lines. Control-X to exit nano. The new jobs will be schedulled.
# The samples below are to open Safari at 7am each morning with the specified URL. It should placed them in new tab if that's how your safari is setup. It's good to wake up each morning saving a few seconds loading the sites you read daily. You can also use similar schedule to download files, open apps, etc. To learn more about how to specify the time, check out http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/
$ crontab -r where the -r flag removes current crontab configuration.
@eplt
eplt / pdfcoverpage.txt
Last active October 6, 2021 03:22
Extract and Combine First Page of each PDF in folder - OS X, requires GS or PDFTK
#!/bin/bash
#
echo "Start Script"
rm combined.pdf
for file in *.pdf ; do pdftk "$file" cat 1 output "${file%.pdf}-page1.pdf" ; done
pdftk *-page1.pdf cat output combined.pdf
#for file in *.pdf ; do gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="${file%.pdf}-page1.pdf" -dFirstPage=1 -dLastPage=1 "$file" ; done
#gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite -sOutputFile#"combined.pdf" *-page1.pdf
#!/bin/bash
# `autoingestion.sh` downloads Apple iOS App Store sales data. It will
# download it to the same folder the script is running from, and group
# the downloaded files into directories by report type.
#
# It will only attempt to download if new sales data should be
# available.
#
# As skipping already downloaded files depends on the filename pattern
@eplt
eplt / OSX Switch TTS Language
Last active August 29, 2015 13:57
An AppleScript to switch the Text-To-Speech voice from Daniel to Ting-Ting and vice versa. I use it because I often have to switch between English and Chinese TTS. I found this script online and modified it.
tell application "System Preferences"
activate
reveal anchor "TTS" of pane "com.apple.preference.speech"
end tell
tell application "System Events" to tell process "System Preferences"
tell pop up button 1 of tab group 1 of window 1
click
delay 0.5 -- without this the value was sometimes "Loading Voices…"
if value is "Daniel" then
click menu item "Ting-Ting" of menu 1