Skip to content

Instantly share code, notes, and snippets.

@a5ync
a5ync / server.py
Last active January 31, 2025 18:18
Static file server with automatic decompression for *.html.gz files.
import http.server
import os
import gzip
import argparse
# Default Constants
DEFAULT_PORT = 8123
DEFAULT_BASE_DIR = "./snapshot"
DEFAULT_ROUTE = "/snapshot-fast"
@a5ync
a5ync / ptime.py
Created March 25, 2024 22:24
Python time converter
#!/usr/bin/python3
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
import sys
def convert_timestamp(input_timestamp):
# Determine if the timestamp is in milliseconds or seconds based on its length
# Assuming it's in milliseconds if it's greater than 10 digits (a common convention)
if len(input_timestamp) > 10:
timestamp_seconds = int(input_timestamp) / 1000
@a5ync
a5ync / playwright-test.ts
Created November 16, 2023 05:59
Playwright awaiter, it uses querySelector to check if DOM object has been populated with the content
import { chromium } from "playwright";
(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
await page.goto('http://localhost:3000');
const selector = 'div#my-div';
const timeout = 5;
const desiredData = page.locator(selector);
@a5ync
a5ync / signed_url.py
Created December 1, 2022 07:16
s3 signed url without sdk (python3)
#!/usr/bin/env python
import base64, hmac, os, hashlib, sys, time, urllib.parse
TWENTY_YEARS_IN_SECONDS = 60 * 60 * 24 * 365 * 20
aws_access_key_id = 'AAA'
aws_secret_access_key = 'BBB'
aws_region='us-west-2'
bucket = 'bucket_name'
key='another-test.md'
@a5ync
a5ync / new-tabs.py
Created November 27, 2022 19:41
iTerm2 automate tab creation
#!/usr/bin/env python3.7
import iterm2
# This script was created with the "basic" environment which does not support adding dependencies
# with pip.
async def main(connection):
# Your code goes here. Here's a bit of example code that adds a tab to the current window:
@a5ync
a5ync / decompress-git.py
Created January 29, 2022 22:54
Decompress git objects
import zlib
import sys
print sys.argv
if len(sys.argv) > 1:
compressed_content = open(sys.argv[1], 'rb').read()
decompressed = zlib.decompress(compressed_content)
print decompressed
else:
print 'input file not provided'
@a5ync
a5ync / mac-util.md
Created November 19, 2021 21:32
mac utilities

Fix ssd volume not mounting properly

pkill -f fsck
@a5ync
a5ync / README.md
Created August 1, 2021 02:19 — forked from ps-przemekaugustyn/README.md
Elasticsearch cheatsheet
GET _search
{
  "query": {
    "match_all": {}
  }
}

GET /_template
GET /_template/template_1
@a5ync
a5ync / env
Created July 31, 2021 06:20 — forked from paugustyn-cbsi/env
Configure iterm2 to switch profiles for ssh connections (badge and profile)
aws-dev=ssh -i ~/.ssh/aws-dev [email protected]
aws-ent=ssh -i ~/.ssh/aws-ent [email protected]
aws-prod=ssh -i ~/.ssh/aws-prod [email protected]
@a5ync
a5ync / form1.cs
Last active April 28, 2021 21:41
Formatowanie textu
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;