Skip to content

Instantly share code, notes, and snippets.

@dca-b
dca-b / session_time.sql
Last active April 2, 2025 18:28
ClickHouse; session_time; user_online
SELECT user_id,
session_id,
min(action_time) AS session_start,
max(action_time) AS session_end,
dateDiff('second', session_start, session_end) AS duration_sec
FROM (
SELECT user_id,
action_time,
sum(session_gap) OVER (PARTITION BY user_id ORDER BY action_time) AS session_id
FROM (
################################################################################
# Important commands
################################################################################
# Copy folder/file over SSH
rsync -avz /home/domains/a.com -e "ssh -p 2012" [email protected]:/home/domains/ # --exclude logs/ --exclude cache/cache/ --exclude '*.log'
# Start screen after su to another user
su - someuser
script /dev/null
screen
@dca-b
dca-b / noti.bash
Last active January 9, 2023 03:51
Pushbullet, .bashrc, command ; noti
noti() {
curl -s -u o.MQHVomYWwYUx0jVBof2d2jL6yQPSACWBt727: -X POST https://api.pushbullet.com/v2/pushes -H 'Content-Type: application/json' --data-binary '{"type": "note", "title": "Note Title", "body": "Note Body"}' > /dev/null
}