Skip to content

Instantly share code, notes, and snippets.

@insidegui
insidegui / ScrollViewOffsetModifier.swift
Created July 20, 2021 20:28
A SwiftUI ViewModifier that can be used to read a ScrollView's offset and store it into a @State property of the view
struct ScrollViewOffsetPreferenceKey: PreferenceKey {
static var defaultValue: CGPoint = .zero
static func reduce(value: inout CGPoint, nextValue: () -> CGPoint) {
value = nextValue()
print("value = \(value)")
}
typealias Value = CGPoint
@bashbunni
bashbunni / .zshrc
Created January 4, 2023 16:28
CLI Pomodoro for Linux
# study stream aliases
# Requires https://github.com/caarlos0/timer to be installed. spd-say should ship with your distro
declare -A pomo_options
pomo_options["work"]="45"
pomo_options["break"]="10"
pomodoro () {
if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
val=$1
@isaqueprofeta
isaqueprofeta / siem_training.md
Last active April 19, 2024 17:51
SIEM Training
@Garconis
Garconis / check-if-child-pages-of-parent-has-certain-slug.php
Created April 22, 2021 19:39
WordPress | Check if parent page has child page of certain slug
<?php
function fs_sc_location_seo_iconbox( $atts ){
// begin output buffering
ob_start();
global $post; // if outside the loop
$slug_to_check = 'seo';
@umputun
umputun / safari-summary.sh
Last active April 19, 2024 17:49
Raycast script for Safari's page summary
#!/bin/sh
# @raycast.schemaVersion 1
# @raycast.title Summarize Safari page
# @raycast.mode fullOutput
#
# Optional parameters:
# @raycast.icon ✨
#
# @raycast.packageName Things
@balbuf
balbuf / wordpress-import-update.php
Created October 15, 2016 17:54
Force the WordPress importer to update existing posts instead of skipping them
<?php
/**
* When using the WordPress Importer, update existing
* posts instead of skipping them. Updates content according
* to the import file even if the existing post was updated
* more recently.
*
* To use, drop this file into your /mu-plugins/ folder or
* copy this code into your functions.php file.
<!doctype html>
<html>
<head>
<script>
function generateNumber() {
var number = document.getElementById("generate");
number.innerHTML = Math.floor((Math.random()* 100) + 1);
}
</script>
<style>
@the-spyke
the-spyke / pipewire.md
Last active April 19, 2024 17:51
Enable PipeWire on Ubuntu 22.04

Enable PipeWire on Ubuntu 22.04

This guide is only for original Ubuntu out-of-the-box packages. If you have added a custom PPA like pipewire-debian, you might get into conflicts.

Ubuntu 22.04 has PipeWire partially installed and enabled as it's used by browsers (WebRTC) for recoding the screeen under Wayland. We can enable remaining parts and use PipeWire for audio and Bluetooth instead of PulseAudio.

Starting from WirePlumber version 0.4.8 automatic Bluetooth profile switching (e.g. switching from A2DP to HSP/HFP when an application needs microphone access) is supported. Jammy (22.04) repos provide exactly version 0.4.8. So, we're good.

Based on Debian Wiki, but simplified for Ubuntu 22.04.

@Einstrasse
Einstrasse / bits-stdc++.h
Created December 3, 2019 14:52
bits/stdc++.h header file
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
@andrewslotin
andrewslotin / flac2alac.sh
Last active April 19, 2024 17:39 — forked from vol4ok/gist:2587886
Split .ape and .flac and convert to .m4a (ALAC) or .mp3 on MacOS X
# brew install flac ffmpeg cuetools shntool # ставим нужные пакеты
ffmpeg -i 1.ape 1.flac # конвертируем во flac, так как libmac для APE не ставится на osx
cuebreakpoints 1.cue | shnsplit -o flac 1.flac #нарезаем на треки
cuetag.sh 1.cue split-track*.flac #прописываем тэги (cuetag.sh ставится отдельно отдельно)
# конвертируем в ALAC
for f in split-track*.flac ; do
ffmpeg -i "$f" -acodec alac "${f%.flac}.m4a";
done