Skip to content

Instantly share code, notes, and snippets.

@Quacky2200
Quacky2200 / test-conversion.js
Created January 9, 2017 09:58
Try to convert freedesktop-notifications from dbus-native to dbus
/*
Freedesktop.org Notifications
Copyright (c) 2015 - 2016 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@Quacky2200
Quacky2200 / gist:bba7f767df4ccf124ce8c904d91e8528
Created January 14, 2017 12:57
Spotify Web Player .desktop right-click unity menu extensions
[Desktop Action PlayPause]
Name=Play/Pause
Exec=dbus-send --type=method_call --session --dest=org.mpris.MediaPlayer2.spotifywebplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
[Desktop Action Next]
Name=Next
Exec=dbus-send --type=method_call --session --dest=org.mpris.MediaPlayer2.spotifywebplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
[Desktop Action Previous]
Name=Previous

First install with package manager apt install lirc kodi inputlirc ir-keytable

Get all input devices cat /proc/bus/input/devices

Get more information about infrared device udevadm info -a -p $(udevadm info -q path -n /dev/input/event6)

Test to see input from remote (must make sure lirc is not running and both devices set to none with dpkg-reconfigure lirc)

@Quacky2200
Quacky2200 / WebServer.cs
Last active October 18, 2018 20:44
Do you ever need a tiny C# web server in your back pocket?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Net;
using System.Diagnostics;
using System.Net.Sockets;
// Created a temporary web server as part of a payment SDK example
@Quacky2200
Quacky2200 / uptime.py
Last active November 30, 2018 01:18
Creates a log, useful for dodgy internet. Checks every minute and creates an empty lock file to stop being run more than once. Add to cron or set as a service to make it start automatically
import time
import sys
import datetime
from os.path import isfile as file_exists
from os import remove as file_delete
import os
from ping3 import ping
import signal
import sys
@Quacky2200
Quacky2200 / isValidColor.js
Created April 23, 2019 10:58
Tests if a given string matches a valid color format
/**
* isValidColor
* Tests whether a given color is in a valid format when used for CSS/form validation.
* Mostly written by copying colors and regexes (because of laziness, and it's been
* written n-times before).
*
* @author Matthew
* @copyright MIT 2019+
*/
var isValidColor = function(color) {
@Quacky2200
Quacky2200 / promises.js
Last active August 15, 2019 17:13
My own take on JavaScript promises. It was a challenge but just about got it to work. There's probably a few bugs but the tests should help for debugging and testing
Promise = function(fn) {
var value = undefined;
var stack = [];
var state = 'pending'
var triggered = false;
var error = undefined;
var id = (function (len, chars) {
len = len || 10;
chars = chars || "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var text = "";
@Quacky2200
Quacky2200 / tag.js
Last active August 29, 2019 17:12
Simple JavaScript template/view/HTML building function.
/**
* Tags by Argument
*
* Creates a HTML string from the element name, attributes and content given
* as part of the arguments provided.
*
* The name argument can be null, which will produce a standard div element.
* If the name is prefixed with a hash, and an id is not provided as an
* attribute, then the id attribute will be added. Classes can be described
* by using dot notation and will get prefixed to the class attribute. This
@Quacky2200
Quacky2200 / repermute.py
Last active February 13, 2024 18:31 — forked from mdeous/repermute.py
Generate all possible permutations of a regex (Python v3)
# -*- coding: utf-8 -*-
#
# Used like this:
#
# from repermute import ipermute
#
# for s in ipermute('[A-Z]\d'):
# print s
#
# Almost all regular expression constructs are supported except for '*'
@Quacky2200
Quacky2200 / tag.ts
Created September 29, 2019 17:51
This is a tag.js alternative written in TypeScript; most specifically for react development. You'd likely use JSX, but this is here as I was used to using pug-like strings before.
import 'core-js';
import React from 'react';
const matchAll = require('string.prototype.matchall');
interface iTagObject {
name: string,
attributes: any,
content: any
}