Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Betz joshbetz

View GitHub Profile
@joshbetz
joshbetz / Webview.swift
Created Feb 12, 2020
A simple SwiftUI Webview
View Webview.swift
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
Webview(url: URL(string: "https://google.com")!)
}
}
struct Webview: UIViewRepresentable {
@joshbetz
joshbetz / Webview.swift
Last active Sep 6, 2020
SwiftUI Webview with a Progress Bar
View Webview.swift
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
Webview(url: URL(string: "https://google.com")!)
}
}
struct Webview: UIViewControllerRepresentable {
@joshbetz
joshbetz / index.js
Last active Jan 23, 2020
Node cluster example
View index.js
#!/usr/bin/env node
/**
* External dependencies
*/
const cluster = require( 'cluster' )
const WORKERS = process.env.WORKERS || require( 'os' ).cpus().length
const SHUTDOWN_TIMEOUT = process.env.SHUTDOWN_TIMEOUT || 5000
View keybase.md

Keybase proof

I hereby claim:

  • I am joshbetz on github.
  • I am jshbz (https://keybase.io/jshbz) on keybase.
  • I have a public key ASC3ZnCwYkE2PkipsnuFJrQQQygBUN6PqyyYU5souaM9Wwo

To claim this, I am signing this object:

View get_wpcom_token.sh
#!/bin/bash
client_id=$1
client_secret=$2
redirect_uri=$3
if [[ -z $client_id || -z $client_secret || -z $redirect_uri ]]; then
echo "Usage: $0 <client_id> <client_secret> <redirect_uri>"
exit 1
fi
@joshbetz
joshbetz / wp-user-activity-forever.php
Created Apr 30, 2017
Don't allow users to delete or edit their activity
View wp-user-activity-forever.php
<?php
// https://wordpress.org/plugins/wp-user-activity/
/**
* Don't allow users to delete or edit their activity.
*
* If the site has been hacked, make it hard for attackers
* to cover their steps.
*/
View jetpack_lossy_compression.php
<?php
/**
* Plugin Name: Photon Lossy Compression
* Plugin URI: https://josh.blog/2015/01/lossy-compression-with-photon
* Description: Lossy compression of images using the Jetpack Photon CDN.
* Version: 1.0.0
* Author: Josh Betz
* Author URI: https://josh.blog
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
View visual mode keep selections
" make < > shifts keep selection
vnoremap < <gv
vnoremap > >gv
View relative line numbers
" relative line numbers
set relativenumber
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
View track
#!/bin/bash
trap stop SIGINT SIGHUP
usage() {
track=`basename $0`
echo "usage: $track <time> <name> [--quiet]"
}
# Validate usage
You can’t perform that action at this time.