Skip to content

Instantly share code, notes, and snippets.

View pa-0's full-sized avatar

Peter Abbasi pa-0

View GitHub Profile
@pa-0
pa-0 / main.rs
Created August 25, 2025 21:18 — forked from MoAlyousef/main.rs
Compact packed expandable multiple tree
use fltk::{prelude::*, *};
static COFACTOR: utils::oncelock::Lazy<i32> = utils::oncelock::Lazy::new(|| (app::font_size() as f64 * 2.0) as i32);
fn prep_tree(t: &mut tree::Tree) {
if let Some(root) = t.next(&t.first().unwrap()) {
if root.is_open() {
let elems = root.children();
t.resize(t.x(), t.y(), t.w(), (elems + 1) * *COFACTOR);
} else {
@pa-0
pa-0 / main.rs
Created August 25, 2025 21:16 — forked from MoAlyousef/main.rs
fltk-sys example
#![feature(concat_idents)]
use fltk_sys::{fl::*, frame::*, window::*, group::*, button::{self, *}};
use std::os::raw::*;
macro_rules! fstr {
($s:literal) => {
concat!($s, "\0").as_ptr() as _
}
}
@pa-0
pa-0 / custom_dialog.rs
Created August 25, 2025 21:15 — forked from MoAlyousef/custom_dialog.rs
custom dialog using fltk-rs
use fltk::{
app, button,
enums::{Color, Font, FrameType},
frame, group, input,
prelude::*,
window,
};
fn style_button(btn: &mut button::Button) {
btn.set_color(Color::Cyan);
@pa-0
pa-0 / hover_button.rs
Created August 25, 2025 21:15 — forked from MoAlyousef/hover_button.rs
Example of Hover support for buttons, it basically requires handling the Event::Enter and Event::Leave events.
use fltk::{
app, button,
enums::{Color, Event, FrameType},
prelude::*,
window,
};
const COLOR: u32 = 0xB39DDB;
const SELECTION_COLOR: u32 = 0x9575CD;
const HOVER_COLOR: u32 = 0xD1C4E9;
@pa-0
pa-0 / resize_override.rs
Created August 25, 2025 21:02 — forked from MoAlyousef/resize_override.rs
Override FLTK's resizing defaults
#![allow(unused_variables)]
use fltk::{
app::App,
button::Button,
enums::Event,
group::Group,
prelude::{GroupExt, WidgetBase, WidgetExt, WindowExt},
window::Window,
};
@pa-0
pa-0 / popup_hack.rs
Created August 25, 2025 21:00 — forked from MoAlyousef/popup_hack.rs
A popup hack allowing to use dynamic strings, basically by creating a hidden Choice widget then getting the MenuItem using the `MenuExt::at(0)` method.
use fltk::{prelude::*, *};
fn main() {
let mut choice = menu::Choice::default();
choice.add_choice("File/New");
choice.add_choice(&format!("{}\t", "Edit/Cut"));
choice.add_choice("File/Open");
choice.add_choice(&format!("Edit/{}", "Copy"));
choice.add_choice("Other|Option");
@pa-0
pa-0 / expand_button.rs
Created August 25, 2025 20:59 — forked from MoAlyousef/expand_button.rs
Expandable button animation using fltk-rs
use fltk::{prelude::*, *};
fn main() {
let app = app::App::default();
app::set_visible_focus(false);
let mut win = window::Window::default().with_size(400, 300);
win.set_color(enums::Color::White);
let mut but = button::Button::default()
.with_size(80, 40)
.with_label("Expand!")
@pa-0
pa-0 / get-meetings.ps1
Created August 17, 2025 12:43 — forked from secretGeek/get-meetings.ps1
Get today's schedule from Outlook, using COM, and format as text for my TODO.txt file
# Get a list of meetings occurring today.
function get-meetings() {
$olFolderCalendar = 9
$ol = New-Object -ComObject Outlook.Application
$ns = $ol.GetNamespace('MAPI')
$Start = (Get-Date).ToShortDateString()
$End = (Get-Date).ToShortDateString()
$Filter = "[MessageClass]='IPM.Appointment' AND [Start] > '$Start' AND [End] < '$End'"
$appointments = $ns.GetDefaultFolder($olFolderCalendar).Items
$appointments.IncludeRecurrences = $true
@pa-0
pa-0 / trsm
Created August 11, 2025 23:03 — forked from khurshid-alam/trsm
Transmission-Shutdown-script
#!/bin/bash
#Transmission-Shutdown-Script
========
#This is the transmission shutdown script I wrote for a [askubuntu question](http://askubuntu.com/questions/202537/transmission-#shutdown-script-for-multiple-torrents) with the help of transmission RPC interface.
#**What it Does?**
@pa-0
pa-0 / transmission-daemon
Created August 11, 2025 23:00 — forked from gene1wood/transmission-daemon
transmission-daemon sysconfig file to enable binding to an interface
# /etc/sysconfig/transmission-daemon
INTERFACE=ppp0 # Set this to the interface you want the daemon to bind to
if /sbin/ifconfig $INTERFACE >>/dev/null 2>&1; then
BIND_ADDR="`/sbin/ifconfig $INTERFACE | awk '$1 == \"inet\" {print $2}' | awk -F: '{print $2}'`"
else
BIND_ADDR="127.0.0.1"
fi