Skip to content

Instantly share code, notes, and snippets.

@pankpan
pankpan / sslconf.sh
Created August 8, 2022 09:31
Apache ssl.conf modify, sslconf.sh {cert} {key} {chain}
#!/bin/bash
if [ -z $2 ] ; then
echo "`basename $0` {cert} {key} {chain}"
else
SSL_CONF=/etc/httpd/conf.d/ssl.conf
if [ -f $SSL_CONF ] ; then
if [ -f $1 ] ; then # cert
sed -i "s/^SSLCertificateFile.*/SSLCertificateFile \/etc\/httpd\/conf.d\/$1/" $SSL_CONF
fi
if [ -f $2 ] ; then # cert
104.com.tw
10film.top
1177.se
11st.co.kr
123-hd.com
163.com
1688.com
1x001.com
1xbet.cm
1xbet.com.gh
@pankpan
pankpan / log-dispatch.sh
Created December 23, 2021 13:04
log-dispatch.sh
#!/bin/sh
while read -r LINE
do
echo `date`,$LINE >> /dev/shm/`date +%Y%m%d%H%M`.log
done
@pankpan
pankpan / curltime.sh
Last active November 2, 2021 07:16
Timing With Curl
#!/bin/sh
# ref. https://susam.in/maze/timing-with-curl.html
if [ -z $1 ] ; then
echo "`basename $0` {url}"
else
curl -L -w "time_namelookup: %{time_namelookup}
time_connect: %{time_connect}
time_appconnect: %{time_appconnect}
time_pretransfer: %{time_pretransfer}
time_redirect: %{time_redirect}
@pankpan
pankpan / adsense-v2.php
Last active October 15, 2021 15:03
PHP Adsnese API v2
<?php
require __DIR__ . '/vendor/autoload.php';
function getClient()
{
$client = new Google_Client();
$client->setApplicationName('Adsense PHP Client');
$client->addScope('https://www.googleapis.com/auth/adsense.readonly');
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
@pankpan
pankpan / volley_post_data_with_header.kt
Last active August 29, 2021 06:34
Android Kotlin Volley POST data with header
// implementation 'com.android.volley:volley:1.2.1'
import com.android.volley.Response
import com.android.volley.toolbox.StringRequest
import com.android.volley.toolbox.Volley
var apiUrl="https://your-api-url.com/"
val request: StringRequest = object : StringRequest(
Method.POST, apiUrl,
Response.Listener { response ->
if (response != null) {
@pankpan
pankpan / LINE_SCALE.bat
Created July 27, 2021 14:59
LINE loader with QT_SCALE_FACTOR variable
set QT_SCALE_FACTOR=1.25
start %LOCALAPPDATA%\LINE\bin\LineLauncher.exe
@pankpan
pankpan / get-tw-ips.sh
Created July 10, 2021 15:33
Get Taiwan IPv4 Addresses from APNIC
#!/bin/sh
# netmask from http://trap.mtview.ca.us/~talby/netmask_2.4.tar.gz
netmask `curl -s http://ftp.apnic.net/stats/apnic/delegated-apnic-latest | awk -F'|' '/TW\|ipv4/ {print $4":+"($5-1)}'`
@pankpan
pankpan / kick-out-user-by-ip.sh
Last active July 5, 2021 01:23
Force kick out user by IP address for Linux
#!/bin/sh
if [ -z $1 ] ; then
echo "`basename $0` {ip}"
else
TEMP=/tmp/psauxw.tmp
ps auxw > $TEMP
for T in `w | grep -w $1 | awk '{print $2}'`
do
echo Logout $T
grep -w $T $TEMP | awk '{print $2}' | xargs kill -9
@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