Skip to content

Instantly share code, notes, and snippets.

@andreldm
andreldm / app.js
Last active November 28, 2022 22:20
Get votes count for Xfce 4.18 wallpaper contest
const PROJECT = "356";
const PROJECT_NAME = "artwork";
const ISSUE = "1";
const COOKIES = "get cookies from browser (must be logged in)";
async function getNotes() {
let page = 1;
const allNotes = [];
while (true) {
const response = await fetch(`https://gitlab.xfce.org/api/v4/projects/${PROJECT}/issues/${ISSUE}/notes?page=${page}`, { headers: { Cookie: COOKIES } });
@andreldm
andreldm / sample.c
Created July 24, 2022 10:13
Clear GtkEntry Sample
/*
* Build:
* gcc $(pkg-config --cflags gtk+-3.0) sample.c -o sample $(pkg-config --libs gtk+-3.0)
*/
#include <gtk/gtk.h>
void clear_text (GtkButton *button, gpointer data)
{
gtk_entry_set_text (GTK_ENTRY (data), "");
@andreldm
andreldm / test.py
Last active August 3, 2020 23:52
Corsair Harpoon RGB Wireless basic protocol debugging, see https://github.com/andreldm/harpoond
# Setup:
# python -m venv env
# source env/bin/activate
# pip install pyusb
#
# Execute with: sudo python test.py
# See udev rule present in (2) if you want to avoid running as root.
#
# References:
# 1. https://wiki.wireshark.org/CaptureSetup/USB
@andreldm
andreldm / Main.java
Last active May 18, 2023 11:15
Java time zones
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.TextStyle;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
@andreldm
andreldm / README.md
Last active March 25, 2020 23:48
A simple daemon implementing freedesktop.org's file manager interface.

Forked from: https://gist.github.com/PotatoesMaster/8038613

Use D-Feet to test or commands such as:

dbus-send --print-reply=literal --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:'/path/to/some/file.txt' string:''
@andreldm
andreldm / popover_sample.c
Last active June 30, 2020 00:09
GTK Popover sample
/*
* Build:
* gcc $(pkg-config --cflags gtk+-3.0) popover_sample.c -o popover_sample $(pkg-config --libs gtk+-3.0)
*/
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
@andreldm
andreldm / app.js
Created March 19, 2020 17:55
Express Proxy POC
const express = require('express');
const proxy = require('express-http-proxy');
const app = express();
app.use(express.static('static'));
app.use('/proxy', proxy((req) => req.header('X-Proxy-Target')));
app.listen(3000, () => console.log("App running at port 3000"));
@andreldm
andreldm / sample.glade
Created October 19, 2019 20:59
Headerbar linked buttons
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="window">
<property name="can_focus">False</property>
<property name="default_width">250</property>
<property name="default_height">150</property>
<child type="titlebar">
<object class="GtkHeaderBar">
@andreldm
andreldm / sample.html
Created October 8, 2019 23:54
Firefox Cantarell Issue
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
body {
font-family: system-ui, 'Open Sans', Roboto, 'Helvetica Neue', sans-serif
}
</style>
</head>
@andreldm
andreldm / sample.c
Created September 7, 2019 02:04
Non-transient dialog with minimize button (which doesn't work)
/*
* Build:
* gcc $(pkg-config --cflags gtk+-3.0) sample.c -o sample $(pkg-config --libs gtk+-3.0)
*/
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkWidget *window, *dialog;