Skip to content

Instantly share code, notes, and snippets.

View mattiasghodsian's full-sized avatar
🏠
Working from home

mattiasghodsian

🏠
Working from home
View GitHub Profile
@the-spyke
the-spyke / pipewire.md
Last active March 9, 2024 21:23
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.

@kuznero
kuznero / install-polybar.md
Last active October 17, 2022 17:36
Install polybar on Ubuntu 18.03

Polybar for i3

Installation in Ubuntu 18.04

sudo apt-get install \
  cmake cmake-data libcairo2-dev libxcb1-dev libxcb-ewmh-dev \
  libxcb-icccm4-dev libxcb-image0-dev libxcb-randr0-dev \
  libxcb-util0-dev libxcb-xkb-dev pkg-config python-xcbgen \
  xcb-proto libxcb-xrm-dev i3-wm libasound2-dev libmpdclient-dev \
@helgatheviking
helgatheviking / shortcodes.php
Last active October 11, 2022 21:46
WooCommerce display a single product add to cart form with [add_to_cart_form]
/**
* NB: updated version available here: https://github.com/helgatheviking/add-to-cart-form-shortcode
*/
/**
* Add [add_to_cart_form] shortcode that display a single product add to cart form
* Supports id and sku attributes [add_to_cart_form id=99] or [add_to_cart_form sku=123ABC]
* Essentially a duplicate of the [product_page]
* but replacing wc_get_template_part( 'content', 'single-product' ); with woocommerce_template_single_add_to_cart()
*
@ojame
ojame / delete.js
Created June 29, 2017 05:47
Delete all movies that haven't been 'downloaded' in Radarr. Mass/bulk deleting.
// Go to Radarr and click 'settings' => 'general'.
// Open the JavaScript Console in Google Chrome (View => Developer => Javascript Console)
// Past the following in. Hit enter and away you go.
const key = document.getElementsByClassName('x-api-key')[0].value;
if (!key) {
alert('Navigate to /settings/general and run again');
}
@daveyjones
daveyjones / regenerate-thumbnails.js
Last active June 20, 2023 16:03
Insanely fast multi-core Node.js script for generating (or regenerating) custom WordPress image sizes (e.g. thumbnails) for very large media libraries
// Your server must have wp-cli installed (http://wp-cli.org/)
var async = require("async");
var exec = require("child_process").exec;
var cores = 32; // Adjust the number of cores to match your environment
var total = 0;
var finished = 0;
var q = async.queue(function(task, callback) {
@bsara
bsara / git-ssh-auth-win-setup.md
Last active March 12, 2024 02:51
Setup SSH Authentication for Git Bash on Windows

Setup SSH Authentication for Git Bash on Windows

Prepararation

  1. Create a folder at the root of your user home folder (Example: C:/Users/uname/) called .ssh.
  2. Create the following files if they do not already exist (paths begin from the root of your user home folder):
  • .ssh/config
@keeferrourke
keeferrourke / install-google-fonts.sh
Last active May 22, 2023 12:38
A bash script to install all Google Fonts, system wide, on debian based systems (ex. Ubuntu)
#!/bin/sh
# Written by: Keefer Rourke <https://krourke.org>
# Based on AUR package <https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=ttf-google-fonts-git>
# dependancies: fonts-cantarell, ttf-ubuntu-font-family, git
sudo apt-get install fonts-cantarell ttf-ubuntu-font-family git
srcdir="/tmp/google-fonts"
pkgdir="/usr/share/fonts/truetype/google-fonts"
giturl="git://github.com/google/fonts.git"
@wpscholar
wpscholar / array-insert-after.php
Created November 7, 2015 13:04
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@madeinnordeste
madeinnordeste / PHP-Remove-URL-from-string.php
Created May 3, 2014 00:56
PHP - Remove URLs from string
<?php
$string = 'Hi, visit my website: http://beto.euqueroserummacaco.com';
$string = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $string);
echo $string;
?>
@ranacseruet
ranacseruet / VideoStream.php
Last active February 19, 2024 17:10
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";