Skip to content

Instantly share code, notes, and snippets.

@meyt
meyt / enable-pg-ext.sh
Created January 29, 2025 12:15
enable postgresql extension
#!/bin/bash
export PGPASSWORD="postgres"
DB_USER="postgres"
DB_NAME="postgres"
DB_HOST="localhost"
DB_PORT="5432"
exec_sql() {
local sql_command="$1"
@meyt
meyt / install_appimage.py
Last active February 11, 2025 17:20
AppImage installer (link to PATH, create desktop file and icons)
#!/usr/bin/env python3
#
# Requirements:
# sudo apt install -y binutils xdg-utils desktop-file-utils squashfuse
#
# Usage:
# python3 install_appimage.py app1.appimage app2.appimage ...
import os
import shutil
@meyt
meyt / ISO-639-1-language.json
Created January 4, 2025 19:04 — forked from jrnk/ISO-639-1-language.json
ISO 639-1 Alpha-2 codes of languages JSON
[
{ "code": "aa", "name": "Afar" },
{ "code": "ab", "name": "Abkhazian" },
{ "code": "ae", "name": "Avestan" },
{ "code": "af", "name": "Afrikaans" },
{ "code": "ak", "name": "Akan" },
{ "code": "am", "name": "Amharic" },
{ "code": "an", "name": "Aragonese" },
{ "code": "ar", "name": "Arabic" },
{ "code": "as", "name": "Assamese" },
@meyt
meyt / scrfix.md
Last active September 2, 2024 02:03
Custom viewport size for Linux/Xorg

Due to backpack pressure, a dark shadow appread on my laptop screen like this:

┌────────────┬┬┬┬┬┬──────┐
│ ┌─terminal─┼┼┼┼┼┼────┐ │
│ │          ││││││    │ │
│ │          ││││││    │ │
│ │          ││││││    │ │
│ │          ││││││    │ │
│ │          ││││││    │ │
@meyt
meyt / docker-cheatsheet.md
Last active October 24, 2024 21:05
Docker cheatsheet

Set proxy DNS sudo nano /etc/resolv.conf

# begzar
nameserver 185.55.226.26
nameserver 185.55.225.25

Install (on dev env)

@meyt
meyt / sqlalchemy-django.md
Last active June 21, 2024 10:48
SQLAlchemy vs Django ORM: Hybrid proprty (computed field)

Dynamic fields

sqlalchemy

class Page(Base):
    __tablename__ = 'pages'
    user_id = Column(Integer, ForeignKey('users.id'), nullable=False)

class User(Base):
@meyt
meyt / ts2iso.js
Last active June 2, 2024 03:32
Convert ISO8601 UTC string to UNIX timestamp and vice versa in Javascript
const epoch = 1970
const dayInSeconds = 86400
const hourInSeconds = 3600
const minuteInSeconds = 60
const dayInHours = 24
const toInt = v => parseInt(v)
const isLeap = v => ((v % 4 == 0) && (v % 100 != 0)) || (v % 400 == 0)
const pad = (v, n = 2) => v.toString().padStart(n, '0')
@meyt
meyt / main.go
Created May 18, 2024 11:59
Serve local files on HTTP (CORS Enabled)
package main
import (
"flag"
"log"
"net/http"
)
func main() {
port := flag.String("p", "8100", "port to serve on")
@meyt
meyt / conventionalcommits.md
Created May 11, 2024 07:32
Conventional Commit Messages
@meyt
meyt / mymodel.py
Created May 8, 2024 17:06
Automatic nested model representation for django-restframework
from django.db import models
from rest_framework import serializers
class MyModel(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):