Skip to content

Instantly share code, notes, and snippets.

View gicrisf's full-sized avatar

Giovanni Crisalfi gicrisf

View GitHub Profile
@gicrisf
gicrisf / promises-puppeteer.js
Last active July 19, 2024 18:11
Run puppeteer with only promises in a clean way
var puppeteer = require("puppeteer");
(() => {
let browser;
let page;
puppeteer
// pass `{ headless: false }` if you want to see the browser
.launch()
.then(it =>
@gicrisf
gicrisf / alpine-commands.md
Created December 24, 2020 19:45
Useful Alpine commands

Alpine frequent commands

Installing a package (let's show how to install python):

apk add python3 py3-pip

Specific version of a package (python or others).

@gicrisf
gicrisf / una-favola-kulekov.md
Created December 24, 2020 14:36
Un aforisma dell'autore bulgaro Ivan Kulekov

Una favola

Un uomo scrisse una favola.
La gente si stupì del suo coraggio civile.
Il sindaco della città in persona si congratulò con lui.
Il favolista ringraziò il sindaco per aver creato in città le condizioni grazie alle quali scrivere favole è espressione di coraggio civile.

@gicrisf
gicrisf / dialog_error.rs
Created November 13, 2020 16:20
Minimal setup for a gtk::MessageDialog
// Make a transient parent if you can't pass a real toplevel window
let transient = gtk::Window::new(gtk::WindowType::Popup);
transient.set_position(gtk::WindowPosition::Center);
// Make Message Dialog with your favorite settings
let dialog = gtk::MessageDialog::new(
Some(&transient), // toplevel window is preferred, but the point is that he wants a window
gtk::DialogFlags::MODAL, // https://gtk-rs.org/docs/gtk/struct.DialogFlags.html
gtk::MessageType::Error, // https://gtk-rs.org/docs/gtk/enum.MessageType.html
gtk::ButtonsType::Ok, // https://gtk-rs.org/docs/gtk/enum.ButtonsType.html
@gicrisf
gicrisf / notebook_tab_btn.rs
Created November 11, 2020 19:06
Add a simple button as tab of a GTK notebook without an associated content is very simple: just leave blank the child!
let window: gtk::Window = gtk::Window::new(gtk::WindowType::Toplevel);
let notebook = gtk::Notebook::new();
// Useful as "add child" button like in a classic browser
// Get image for your button
let add_image = gtk::Image::from_icon_name(Some("list-add"), gtk::IconSize::Button);
// Make button
let button = gtk::Button::new();
button.set_relief(gtk::ReliefStyle::None); // Relief can be "Normal"/"None"
@gicrisf
gicrisf / zwit_entry_update.rs
Created November 8, 2020 00:01
Connect entry change signal to a function with Gtk-rs
// This example is part of the Zwitterio GTK-rs examples series
extern crate gio;
extern crate gtk;
use gio::prelude::*;
use gtk::prelude::*;
use std::env::args;