Skip to content

Instantly share code, notes, and snippets.

View one-data-cookie's full-sized avatar

Michal Koláček one-data-cookie

View GitHub Profile
@one-data-cookie
one-data-cookie / photos-in-order.py
Last active July 24, 2024 19:56
Orders Google Photos album in the UI order
"""
Script to process a Takeout export of a Google Photos album based on HTML source code.
This is a very hacky solution to the non-existent possibility of exporting Google Photos
albums in the order set in the UI.
The code takes the folder, parses the corresponding JSON files, extracts URL IDs, finds their order
in an HTML source code file, and copies & renames the photos with a prefixed counter based on the order.
Usage:
@one-data-cookie
one-data-cookie / habits-transition.py
Created July 7, 2024 19:55
Converts data from Loop Habit Tracker (Android, CSV) to Awesome Habits (iOS, JSON)
import pandas as pd
import json
from datetime import datetime, timezone
# Function to convert date to Apple epoch time
def to_apple_epoch(date_str):
dt = datetime.strptime(date_str, "%Y-%m-%d")
apple_epoch = datetime(2001, 1, 1, tzinfo=timezone.utc)
delta = dt.replace(tzinfo=timezone.utc) - apple_epoch
return int(delta.total_seconds())
emj_data = []
for m in msg:
url = 'https://slack.com/api/reactions.get'
head = {'content-type': 'application/x-www-form-urlencoded'}
params = {
'token': 'xoxp-XXXXXXXXXXXX-XXXXXXXXXXXX-XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'channel': 'CXXXXXXXX',
'timestamp': m
}
res = rq.get(url=url, headers=head, params=params)
import requests as rq
import pandas as pd
msg_url = 'https://slack.com/api/conversations.history'
msg_headers = {'content-type': 'application/x-www-form-urlencoded'}
msg_params = {
'token': 'xoxp-XXXXXXXXXXXX-XXXXXXXXXXXX-XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'channel': 'CXXXXXXXX',
'limit': 1000
}
import requests as rq
import pandas as pd
channel_url = 'https://slack.com/api/conversations.list'
channel_headers = {'content-type': 'application/x-www-form-urlencoded'}
channel_params = {
'token': 'xoxp-XXXXXXXXXXXX-XXXXXXXXXXXX-XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'limit': 1000,
'exclude_archived': True
}
function doPost(e) {
// get the parameters
var params = e.parameter
// run if command sends request
if (params.call == "command") {
// create payload
var trigger_id = params.trigger_id