Skip to content

Instantly share code, notes, and snippets.

View ittus's full-sized avatar

Thang Minh Vu ittus

View GitHub Profile
## Check external IP
alias ip="curl http://checkip.amazonaws.com/"
## Git log improve
alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
## Quickly go to project
alias project="cd ~/code/project" alias study="cd ~/code/study"
@ittus
ittus / cohort.sql
Created May 11, 2021 05:59
[Medium] Cohort - 6
SELECT B.start_time, S.num_users AS total_users, B.period_number, B.num_users AS total_repeators
FROM retention_table B
LEFT JOIN cohort_size S ON B.start_time = S.start_time
WHERE B.start_time IS NOT NULL
ORDER BY 1, 3
@ittus
ittus / retention_table.sql
Created May 11, 2021 05:57
[Medium] Cohort - 5
WITH retention_table AS (
SELECT C.start_time, A.period_number, COUNT(1) AS num_users
FROM user_activities A
LEFT JOIN new_users C ON A.person_id = C.person_id
GROUP BY 1, 2
)
@ittus
ittus / cohort_size.sql
Created May 11, 2021 05:55
[Medium] Cohort - 4
WITH cohort_size AS (
SELECT start_time, COUNT(1) AS num_users
FROM new_users
GROUP BY 1
ORDER BY 1
)
@ittus
ittus / user_activities.sql
Created May 11, 2021 05:43
[Medium] Cohort - 3
WITH user_activities AS (
SELECT A.person_id, DATEDIFF('day', C.start_time, date_trunc('day', A.start)::date) AS period_number
FROM activities A
LEFT JOIN new_users C ON A.person_id = C.person_id
GROUP BY 1, 2
HAVING period_number < 10
ORDER BY 1, 2
)
@ittus
ittus / new_users.sql
Created May 11, 2021 05:38
[Medium] Cohort 2
WITH new_users AS (
SELECT person_id, date_trunc('day', MIN(start)::DATE AS start_time
ย  FROM activities
ย  GROUP BY person_id
ย  ORDER BY 1, 2
)
@ittus
ittus / activities.sql
Last active May 11, 2021 06:09
[Medium] Select activity
WITH activities AS (
SELECT start, person_id FROM histories
WHERE "start" BETWEEN '2021โ€“05โ€“22T00:00:00' AND '2021โ€“05โ€“26T23:59:59.999Z'
)
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@ittus
ittus / command.MD
Created May 28, 2020 07:57
Delete all git branch with search text

Delete all brances with fix/ in branch name

git branch | grep "fix/" | xargs git branch -D

Delete all branches except branch with fix/ in branch name

git branch | grep -v "fix/" | xargs git branch -D
@ittus
ittus / android-restore-password-keystore-jks.md
Created March 22, 2020 04:30 — forked from ptkdev/android-restore-password-keystore-jks.md
Android: Recovery lost keystore jks file or keystore password

Sign android app with new keystore file if you missing password or lost jks file.

  1. Create new keystore.jks file with comand line (not android studio build menu)

    Linux: keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks

    Windows: "C:\Program Files\Android\Android Studio\jre\bin\keytool.exe" -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore "C:\keystore_new.jks"

  2. Generate a .pem file from new keystore