Skip to content

Instantly share code, notes, and snippets.

@pankpan
pankpan / linux-auto-login.sh
Created July 3, 2021 07:32
enable Linux console auto login script
#!/bin/sh
sed -i 's/ExecStart.*/ExecStart=-\/sbin\/agetty -a root %I \$TERM/' /usr/lib/systemd/system/getty@.service
@pankpan
pankpan / alexa-top-50-sites-dns-bench.sh
Created June 25, 2021 16:13
Measure DNS speed by query Alexa top 50 sites NS and A record
#!/bin/bash
TEMP=/tmp/alexa.html
if [ -z $1 ] ; then
echo "`basename $0` {dns}"
else
DNS=$1
[ -f $TEMP ] || curl -s https://www.alexa.com/topsites > $TEMP
T1=`date +%s.%N`
for HOST in `awk -F[\"\/] '/href=..siteinfo\// {print $4}' $TEMP`
@pankpan
pankpan / skype-get-token.sh
Last active June 1, 2021 14:11
Skype Bot API get token BASH script
#!/bin/bash
# Get skype bot token to send message, fill your CLIENT_ID and CLIENT_SECRET
CLIENT_ID=
CLIENT_SECRET=
TOKEN=`curl -sd "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=client_credentials&scope=https://api.botframework.com/.default" https://login.microsoftonline.com/common/oauth2/v2.0/token | jq -r .request_token`
echo $TOKEN
@pankpan
pankpan / skype-send-message.sh
Last active June 1, 2021 14:11
Skype Bot API send message BASH script
#!/bin/bash
# To get TOKEN, ref this gist https://gist.github.com/pankpan/ad68f50cd44c1dae9203d29964d579e5
# TO is personal uid or conversation id
TOKEN=
TO=
curl -sd '{"type":"message","text":"Test 20210601"}' -H "Authorization: Bearer $TOKEN" https://smba.trafficmanager.net/apis/v3/conversations/$TO/activities
@pankpan
pankpan / vhost.conf
Last active June 1, 2021 14:10
Multi-PHP version on the same server
<VirtualHost *:80>
DocumentRoot "/var/www/php56"
ServerName php56.local
ErrorLog "logs/php56_error_log"
CustomLog "logs/php56_access_log" combined
<FilesMatch \.php$>
setHandler "proxy:unix:/var/opt/remi/php56/run/php-fpm/www.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
@pankpan
pankpan / CentOS-Base.repo
Last active June 1, 2021 14:09
CentOS-Base.repo for CentOS 6
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
{
"settings": {
"baseUrl": "https://desktop.line-scdn.net/win/v1/real",
"lineUrl": "https://desktop.line-scdn.net/win/v1/real/light",
"fileName": "LINE.zip",
"regression": false,
"legacyUpgraderUrl": "https://desktop.line-scdn.net/win/v1/real/legacy/LineUpgrader.exe"
},
"shared": {
"baseUrl": "https://desktop.line-scdn.net/win/v1/real/shared",
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
@pankpan
pankpan / Caddyfile
Last active August 12, 2019 09:56
Caddyfile sample
https://domain1.com https://www.domain1.com {
root /var/www/html
log /var/log/caddy/access.log
errors /var/log/caddy/errors.log
tls your@email.com # auto https with let's encrypt
gzip
fastcgi / localhost:9000 php
}
https://domain2.com https://www.domain2.com {
@pankpan
pankpan / nginx.repo
Created November 21, 2017 01:47
nginx repo for CentOS
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1