Skip to content

Instantly share code, notes, and snippets.

@mistic100
mistic100 / one-instance.cpp
Last active November 1, 2025 12:17
[C] Use Windows mutex to create a single instance app
#include <windows.h>
int main(int argc, char *argv[])
{
// ensure only one running instance
HANDLE hMutexHandle = CreateMutex(NULL, TRUE, L"my.mutex.name");
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
return 0;
}
@mistic100
mistic100 / Mediakeys.ahk
Last active October 31, 2025 23:46
Media keys shortcuts for AutoHotkey
; AutoHotkey Media Keys
^!Space::Send {Media_Play_Pause}
^!Left::Send {Media_Prev}
^!Right::Send {Media_Next}
^!NumpadMult::Send {Volume_Mute}
^!NumpadAdd::Send {Volume_Up}
^!NumpadSub::Send {Volume_Down}
@mistic100
mistic100 / ha_jellyfin_nowplaying.yaml
Last active October 19, 2025 14:56
[Home Assistant] Jellyfin "now playing" sensor
# Creates a binary sensor with the name and type of the currently playing item as attributes
# Replace <SERVER_ADDRESS>, <API_KEY> and <USERNAME>
- sensor:
name: "Jellyfin NowPlaying"
scan_interval: 30
command: >-
curl http://<SERVER_ADDRESS>/jellyfin/Sessions\?ApiKey\=<API_KEY> | jq '
(.[] | select(.UserName == "<USERNAME>") | select(.NowPlayingItem) | select(.PlayState.IsPaused == false)) // {}
| {
@mistic100
mistic100 / vimeo-downloader.js
Created September 15, 2018 09:01
Download video from Vimeo (chopped m4s files)
// 1. Open the browser developper console on the network tab
// 2. Start the video
// 3. In the dev tab, locate the load of the "master.json" file, copy its full URL
// 4. Run: node vimeo-downloader.js "<URL>"
// 5. Combine the m4v and m4a files with mkvmerge
const fs = require('fs');
const url = require('url');
const https = require('https');
@mistic100
mistic100 / lil-gui-jscolor.ts
Last active June 15, 2025 10:18
[JS] Use jscolor.js library inside lil-gui
import { GUI, Controller } from 'lil-gui';
import '@eastdesire/jscolor';
export class ColorController extends Controller {
private $input: HTMLInputElement;
private picker: any;
constructor(parent: GUI, object: object, property: string, alpha: boolean | 'auto' = 'auto') {
super(parent, object, property, 'color');
@mistic100
mistic100 / lil-gui-textarea.ts
Last active June 15, 2025 10:18
[JS] Add textarea support to lil-gui
import { GUI, Controller } from 'lil-gui';
export class TextController extends Controller {
private $button: HTMLButtonElement;
private $text: HTMLTextAreaElement;
constructor(parent: GUI, object: object, property: string, rows: number = 4) {
super(parent, object, property, 'textarea');
@mistic100
mistic100 / Squareicon.php
Last active June 15, 2025 10:17
[PHP] simple image hash generator
<?php
/**
* Squaricon
*
* @description: PHP image hash generator
*
* @author: Damien "Mistic" Sorel - http://strangeplanet.fr
* @license: MIT
* @version: 2.0.0
* @date: 21/05/2015
@mistic100
mistic100 / IdenticonPlus.php
Last active June 15, 2025 10:17
[PHP] implementation of Don Park Identicon algorithm with additional shapes and variations
<?php
/**
* Identicon++
*
* @description: PHP implementation of Don Park Identicon algorithm with additional shapes and variations.
*
* @author: Damien "Mistic" Sorel - http://strangeplanet.fr
* @license: MIT
* @version: 2.0.0
* @date: 21/05/2015
@mistic100
mistic100 / jQuery.amusesMoi.js
Last active June 15, 2025 10:17
[JS] Computes distance and angle between the cursor and a DOM element.
/**
* jQuery amusesMoi! 1.0
*
* Copyright 2012-2013, Damien "Mistic" Sorel
* http://www.strangeplanet.fr
*
* License:
* MIT and GPL dual licensing
*
* Depends:
@mistic100
mistic100 / jQuery.textareaLinesNumbers.css
Last active June 15, 2025 10:17
[JS] Adds line numbers to <textarea>
.textareaLinesNumbers {
position: relative;
}
.textareaLinesNumbers textarea.linesContainer {
display:block;
border:none;
position:absolute;
overflow:hidden;
text-align:right;