Skip to content

Instantly share code, notes, and snippets.

View drakkein's full-sized avatar
🦆
quack

drakkein

🦆
quack
  • Poland
View GitHub Profile
@drakkein
drakkein / Hyprlock_brightness_control.md
Last active June 16, 2024 13:28
Brightness control script for hypridle

Brightness control script used for hypridle

Basic usage:

./brightnesscontrol.sh 50

hypridle.conf

general {
    lock_cmd = pidof hyprlock || hyprlock
 before_sleep_cmd = loginctl lock-session
// We are using multiplication by 31 to ensure better uniqueness
// 31 * p === (p << 5) - p
// This trick is taken from this book https://www.amazon.com/Effective-Java-3rd-Joshua-Bloch/dp/0134685997
const hashCode = (str: string) => [...str].reduce((p, c) => c.charCodeAt(0) + ((p << 5) - p), 0);
export const generateColor = (str: string) => {
const hash = hashCode(str);
const color = (hash & 0x00ffffff).toString(16).toUpperCase();
@drakkein
drakkein / iframeResizer.directive.ts
Last active July 17, 2023 08:16
iframe resizer directive for Angular 4 (No CORS)
import { Directive, ElementRef, OnDestroy, OnInit, Renderer2 } from '@angular/core';
@Directive({
selector: '[iframeResize]',
})
export class IframeResizeDirective implements OnInit, OnDestroy {
private listener: () => void;
private observer: MutationObserver;
get element() {