Skip to content

Instantly share code, notes, and snippets.

View tesfabpel's full-sized avatar

Fabrizio Pelosi tesfabpel

  • CostaSoft
View GitHub Profile
@tesfabpel
tesfabpel / .zshrc
Created July 27, 2023 13:12
My zshrc
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '~/.zshrc'
autoload -Uz compinit
@tesfabpel
tesfabpel / rs-gui-framework-design.rs
Last active February 18, 2023 10:41
Rust GUI framework design
mod core {
use generational_arena::{Arena, Index};
use qcell::LCell;
use qcell::LCellOwner;
use queues::Queue;
use std::marker::PhantomData;
use std::rc::Rc;
#[derive(PartialEq)]
pub enum KeyCode {
@tesfabpel
tesfabpel / main.rs
Last active November 12, 2022 15:25
Portal API POC
use std::collections::HashMap;
use std::error::Error;
use zbus::{Connection, zvariant};
use zbus::zvariant::Value;
use zbus::dbus_proxy;
use async_std::stream::StreamExt;
#[dbus_proxy(
interface = "org.freedesktop.portal.FileChooser",
default_service = "org.freedesktop.portal.Desktop",
@tesfabpel
tesfabpel / test_bounds_enum_variants.rs
Created October 28, 2021 10:51 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[derive(Clone, Debug)]
pub struct Point(f32, f32);
#[derive(Clone, Debug)]
pub struct ValidBounds {
min: Point,
max: Point
}
#[derive(Clone, Debug)]
public class Foo
{
// ...
public void Bar()
{
while(BazBaz()
&& BarBar())
{
// The && under the while are
@tesfabpel
tesfabpel / gui_toolkit_oop_study.rs
Last active February 5, 2020 09:07
Simple study for a way to structure structs in Rust to replicate the need for a GUI toolkit
use std::cell::RefCell;
use std::rc::{Rc, Weak};
type RefBox<T> = RefCell<Box<T>>;
trait Control {
fn id(&self) -> &Option<String>;
fn set_id(&mut self, id: Option<String>);
fn parent(&self) -> &Option<Weak<RefBox<dyn Control>>>;
@tesfabpel
tesfabpel / blender_apply_xform.py
Created June 19, 2018 15:04
Blender script to apply a transformation matrix
import bpy
from bpy import context
import mathutils
from mathutils import Vector,Quaternion,Matrix
import math
#obj = bpy.data.objects["Cube"] # particular object by name
obj = bpy.context.scene.objects.active # active object
# setup whatever matrix
@tesfabpel
tesfabpel / lock.py
Created May 24, 2018 06:47
plasmashell lock
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
i=0
def func(obj):
global i
win.set_title("i: %d" % i)
import time
import subprocess as sp
enc = 'UTF-8'
p = sp.Popen(['dialog', '--gauge', 'hello', '6', '75', '0'], stdin=sp.PIPE)
for i in range(0, 100):
p.stdin.write(bytes(str(i)+"\n", enc))
p.stdin.flush()
<!DOCTYPE html>
<html>
<head>
<script src='js/jquery.js'></script>
<script src='js/bicubicInterpolation.js'></script> <!-- https://github.com/sukhoi1/ie-bicubic-img-interpolation-plugin -->
<script type='text/javascript'>
$(function() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');