Skip to content

Instantly share code, notes, and snippets.

View diegogangl's full-sized avatar

Diego Gangl diegogangl

View GitHub Profile
@diegogangl
diegogangl / tasks.py
Last active December 15, 2021 17:27
GTG task list with Gtk4 + new core (WIP attempt)
#!/usr/bin/env python3
# Load Gtk
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk, Gio, GObject, GLib, Gdk
import re
from uuid import UUID, uuid4
from typing import Any, Optional
@diegogangl
diegogangl / treemodel.py
Last active December 15, 2021 17:26
Attempt to figure out Gtk Tree models (this is practically a working GTG sidebar now, not quite generic anymore)
#!/usr/bin/env python3
# Load Gtk
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk, Gio, GObject, GLib, Gdk
from uuid import UUID, uuid4
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow">
<property name="can_focus">False</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM)
bus.signal_subscribe(None, 'org.freedesktop.login1.Manager',
'PrepareForSleep', None, None,
Gio.DBusSignalFlags.NONE,
on_prepare_for_sleep)
def on_prepare_for_sleep(connection, sender_name, object_path,
interface_name, signal_name, parameters,
*user_data):
@diegogangl
diegogangl / GTG_master.flatpak
Last active May 5, 2020 23:22
Sort of working flatpak manifesto for gtg master
{
"app-id": "org.gnome.GTG",
"runtime": "org.gnome.Sdk",
"runtime-version": "3.36",
"sdk": "org.gnome.Sdk",
"command": "gtg",
"finish-args": [
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
@diegogangl
diegogangl / diamond_indices.py
Last active June 29, 2017 14:04
A simple function to get indices around an index "i" in a diamond shape. Returns a list of indices usable for a 2D grid in a flat list.
def get_indices_diamond(i, radius, side):
""" Get indices around i in a diamond shape """
indices = []
indices += [i + j for j in range(radius + 1)]
indices += [i - j for j in range(1, radius + 1)]
for step in range(1, radius):
indices += [i + side * step + j for j in range(radius - (step - 1))]
@diegogangl
diegogangl / rename_git.py
Created March 25, 2017 23:44
Remove dates from jekyll post files using git mv
#!/bin/python
"""
Remove dates from jekyll post files
This is a small script made to remove dates from jekyll files using
the 'git mv' command.
It expects files to be in the format YYYY-MM-DD-NAME.EXT.
@diegogangl
diegogangl / change_res.py
Created April 4, 2016 13:00
Change resolution for all scenes in Blender
import bpy
for scene in bpy.data.scene:
scene.render.resolution_x = 1920
scene.render.resolution_y = 1080
@diegogangl
diegogangl / zajalSaveFrames.rb
Created May 11, 2012 23:01
A little snippet you can put in your draw function to save every frame to your desktop (or any other path).
# Save frames to png images in Zajal 0.3.3
def saveFrames
image = grab_screen
path = '/Users/yourName/Desktop/frame_ ' + frame.to_s() + '.png'
image.save( path )
end
@diegogangl
diegogangl / zajalAnimation.rb
Created May 11, 2012 22:30
A simple animation in Zajal 0.3.3, a circle that grows and shrinks over time.
# Simple animation example
# in Zajal
sizeBase = 0
speed = 0.05
setup do
title "Simple Circle"
framerate 60
smoothing true