Skip to content

Instantly share code, notes, and snippets.

View andreasottosson's full-sized avatar
🍵

Andreas Ottosson andreasottosson

🍵
View GitHub Profile
@andreasottosson
andreasottosson / wp_rest_api_show_more_than_100_hits.php
Created October 14, 2017 16:03
Show more than 100 hits in WP REST API (Wordpress)
// Make REST API show more than 100 results
add_action( 'rest_forhandlere_query', 'forhandlere_override_per_page' );
/*
* params is the query array passed to WP_Query
*/
function forhandlere_override_per_page( $params ) {
if ( isset( $params ) AND isset( $params[ 'posts_per_page' ] ) ) {
$params[ 'posts_per_page' ] = 500;
}
return $params;
@andreasottosson
andreasottosson / check_wireguard.sh
Last active June 29, 2021 18:31
WireGuard up/down check in bash
#!/bin/bash
# Make sure WireGuard is up on server
# Check twice with 15s delay
# Send notification if WireGuard is down
TOKEN=
USER=
COUNT=0
@andreasottosson
andreasottosson / check_server.sh
Created April 8, 2021 14:40
Check if server is up or notify via Pushover
#!/bin/bash
api_token=
user_key=
server=10.0.1.3
if nc -z $server 22 2>/dev/null; then
echo "Server ✓"
else
@andreasottosson
andreasottosson / enable_key_repeat_sublime.md
Last active August 30, 2022 17:34
Enable key repeat in macOS for Sublime Text in Vim mode

How-To

Paste the command in your macOS terminal, then restart Sublime Text.

For Sublime Text 3

defaults write com.sublimetext.3 ApplePressAndHoldEnabled -bool false

For Sublime Text 4

defaults write com.sublimetext.4 ApplePressAndHoldEnabled -bool false

@andreasottosson
andreasottosson / enable_key_repeat_vscode.md
Created August 12, 2021 07:25
Enable key repeat in macOS for Visual Studio Code (VS Code) with Vim emulation

How-To

Paste this command in your macOS terminal, then restat VS Code.

defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false