Skip to content

Instantly share code, notes, and snippets.

@hbouhadji
hbouhadji / main.swift
Created April 10, 2025 22:54
list windows swift (ordered)
import AppKit
import ApplicationServices
import CoreGraphics
import Foundation
// Declare the private _AXUIElementGetWindow API
@_silgen_name("_AXUIElementGetWindow")
func _AXUIElementGetWindow(_ element: AXUIElement, _ windowID: UnsafeMutablePointer<CGWindowID>)
-> AXError
import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate {
var window: NSWindow!
func applicationDidFinishLaunching(_ notification: Notification) {
// Définir l'icône de l'application
if let image = createApplicationIcon() {
NSApplication.shared.applicationIconImage = image
}
(function() {
'use strict';
class ConfigurablePanel {
constructor() {
this.position = 'right';
this.isDragging = false;
this.isResizing = false;
this.offset = { x: 0, y: 0 };
this.createPanel();
@hbouhadji
hbouhadji / vod.sh
Last active May 13, 2022 18:35
twitch vod viewer
#!/bin/bash
twitchVideoId=$(basename $1)
curl -ss --location --request GET "https://api.twitch.tv/kraken/videos/$twitchVideoId" \
--header 'Client-Id: kimne78kx3ncx6brgo4mv6wki5h1ko' \
--header 'Accept: application/vnd.twitchtv.v5+json' \
| jq -r '.animated_preview_url' \
| sed 's/\/storyboards.*/\/chunked\/index-dvr.m3u8/'
#!/bin/bash
osascript << EOF
set windowFounded to 0
set tabFounded to 0
tell application "$1"
set window_list to every window
set counter_window to 0
@hbouhadji
hbouhadji / code.ts
Created January 22, 2022 05:18
display aspect ratio by device pixels size
function _pgcd(a, b) {
if (b) {
return _pgcd(b, a % b);
} else {
return Math.abs(a);
}
}
const createRatio = (width, height, color) => {
return { ratio: width / height, width, height, color };
@hbouhadji
hbouhadji / fill.js
Last active February 12, 2021 12:58
Fill environment properties on beanstalk from .env file
// example in the body
// paste it in the chrome console
let raw = `
APP_NAME=Laravel
APP_ENV=local
`;
raw = raw.split('\n').filter(str => str.length > 0 && str[0] != '#')