Skip to content

Instantly share code, notes, and snippets.

View hezral's full-sized avatar
🐍
python time

hezral hezral

🐍
python time
View GitHub Profile
@danielgross
danielgross / specific_gpt.py
Created January 23, 2023 15:23
A chat interface that drives GPT-3 towards more specific answers.
"""Stream a response from the OpenAI completion API."""
import os
import re
import sys
import time
import random
import openai
openai.api_key = open(os.path.expanduser("~/.openai")).read().strip()
//
// DarkModeMasker.swift
// SwiftUI Demos
//
// Created by Morten Just on 1/22/23.
// https://twitter.com/joshguospace/status/1617101052192649216?s=12
import SwiftUI
import Charts
@thalamus
thalamus / ArchLinuxARM-M1
Last active July 22, 2025 02:58
How to boot Arch Linux ARM in QEMU (patched for M1)
/*
* This document is provided to the public domain under the
* terms of the Creative Commons CC0 public domain license
*/
How to boot Arch Linux ARM in QEMU (patched for M1)
Prerequisites:
QEMU - patched for M1 processors - patches: https://github.com/utmapp/qemu

Why

  • You have a laptop with a 13" screen and 1920x1080 resolution and a 4K external monitor.
  • You run the laptop at 1x scale.
  • You run the 4K screen at 2x scale (pixel doubled).
  • You’re running elementary OS 5.x (Hera) or elementary OS 6 (Odin)

Which means that text scale should be 1x when the 4K monitor is plugged in but it should be larger than that (at least ~1.5x) to be legible on the laptop’s screen. (Yes, the manufacturer of the laptop chose the wrong resolution for the screen. It should have been QHD (2560 × 1440) or at most QHD+ (3200×1800) so that you could run it confortably pixel doubled.)

Anyway, it’s not and you’ve already bought it (and it’s otherwise an excellent laptop) but you don’t want to change the text scale every time you plug it into and unplug it from your external monitor.

@hezral
hezral / getscreenshot.py
Created December 7, 2020 15:29 — forked from bellbind/getscreenshot.py
[python][pywebkitgtk]Get web page screenshot
#
# Get web page screenshot
#
# usage:
# xvfb-run -s "-screen 0 1024x768x24" python getschreenshot.py test.html
#
# libs:
# - pygtk: http://www.pygtk.org/
# - pywebkitgtk(python-webkit): http://code.google.com/p/pywebkitgtk/
# - PIL: http://www.pythonware.com/products/pil/
@citruz
citruz / QEMU_ON_M1.md
Last active May 3, 2025 17:10
Create Ubuntu and Windows VMs with QEMU on Apple Silicon

Running Linux and Windows on M1 with QEMU

30.11.2020: Updated with the new patchseries and instructions for Windows

02.12.2020: Added tweaks

08.12.2020: Updated with patchseries v4

31.01.2020: Updated with patchseries v6

@niw
niw / README.en.md
Last active April 3, 2026 03:38
How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

Here is easy steps to try Windows 10 on ARM or Ubuntu for ARM64 on your Apple Silicon Mac. Enjoy!

NOTE: that this is current, 10/1/2021 state.

Running Windows 10 on ARM

  1. Install Xcode from App Store or install Command Line Tools on your Mac
@cassidyjames
cassidyjames / touchegg.conf
Last active November 2, 2020 20:50
A touchégg config I am trying out for elementary OS and big trackpads
<touchégg>
<settings>
<property name="animation_delay">150</property>
<property name="action_execute_threshold">20</property>
<property name="color">909090</property>
<property name="borderColor">FFFFFF</property>
</settings>
<application name="All">
<gesture type="SWIPE" fingers="3" direction="LEFT">
<action type="CHANGE_DESKTOP">
@dperelman
dperelman / x11_watch_active_window.py
Last active January 9, 2024 16:16 — forked from ssokolow/x11_watch_active_window.py
python-xlib example which reacts to changing the active window
#!/usr/bin/env python3
# Based on code by Stephan Sokolow
# MIT-licensed
# Source: https://gist.github.com/ssokolow/e7c9aae63fb7973e4d64cff969a78ae8
"""python-xlib example which reacts to changing the active window/title.
Requires:
- Python
- python-xlib
@rbreaves
rbreaves / WaylandUbuntu19.10-AppTitle
Last active October 10, 2024 09:00
Grab wmclass name or Window Name/Title under Wayland with Gnome 3.x
# Single Command, runs 2 calls to gdbus to get the currently active Window from Gnome 3.x
# Escaped so you can copy and paste into terminal directly
gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\)[`gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\).findIndex\(a\=\>a.meta_window.has_focus\(\)===true\) | cut -d"'" -f 2`].get_meta_window\(\).get_wm_class\(\) | cut -d'"' -f 2
# Unescaped version, will not run
# Broken down into 2 commands.
# Call to Gnome to get the array location of the active Application
gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m \