Skip to content

Instantly share code, notes, and snippets.

@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 August 28, 2024 06:07
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):
@meyt
meyt / google-chrome.desktop
Last active April 28, 2024 13:58
Google chrome fix for XFCE (~/.local/share/applications/google-chrome.desktop)
[Desktop Entry]
Version=1.1
Type=Application
Name=Google Chrome
GenericName=Web Browser
Comment=Access the Internet
Icon=google-chrome
Exec=/usr/bin/google-chrome-stable --force-device-scale-factor=1 --password-store=gnome-libsecret %U
Actions=new-window;new-private-window;
MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;
@meyt
meyt / output.json
Last active April 23, 2024 21:25
Scrape CS2 commands documentation
[
[
"_record",
"cmd",
[
"norecord",
"release"
],
"Record a demo incrementally.\n"
],
@meyt
meyt / 01_cs2run.sh
Last active April 26, 2024 01:38
cs2 setup
#!/bin/bash
SRCDS_TOKEN="..."
CS2_RCON_PORT=1002
CS2_PORT=27015
CS2_RCONPW="changeme"
CS2_PW="changeme"
CS2_MAXPLAYERS=10
CS2_ADDITIONAL_ARGS=""
CS2_GAMEALIAS="competitive" # competitive, wingman, casual, deathmatch, custom
CS2_MAPGROUP="mg_active"