Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Buchea joshbuchea

View GitHub Profile
View swift-detect-color-scheme.swift
// https://stackoverflow.com/a/57280180/1492782
@Environment(\.colorScheme) var colorScheme: ColorScheme
var body: some View {
Button(action: {
foo()
}) {
Image(colorScheme == .light ? "lightImage" : "darkImage")
}
}
@joshbuchea
joshbuchea / swift-extend-color-init-support-hex.swift
Last active Oct 20, 2020
Swift: Extend Color.init to support hex colors
View swift-extend-color-init-support-hex.swift
// From SO answer: https://stackoverflow.com/a/56874327/1492782
extension Color {
init(hex: String) {
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var int: UInt64 = 0
Scanner(string: hex).scanHexInt64(&int)
let a, r, g, b: UInt64
switch hex.count {
case 3: // RGB (12-bit)
(a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
@joshbuchea
joshbuchea / microdata_resume_cv.html
Created Jun 14, 2020 — forked from danielantelo/microdata_resume_cv.html
HTML5 Microdata Resume (Curriculum) Template
View microdata_resume_cv.html
<!DOCTYPE html>
<html>
<head>
<!-- Meta conf -->
<meta charset="UTF-8">
<!-- Meta info -->
<title>HTML5 Microdata Resume (CV) Template</title>
<meta name="description" content="An example of how to layout a semantic html5 page for a curriculum vitae/resume">
<meta name="keywords" content="template, html, semantic, microdata, resume, cv, curriculum, vitae">
</head>
View linkedin-unfollow-everyone.js
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button.is-following') || [];
}
async function unfollowAll() {
const buttons = getAllButtons();
View ios.settings.schemes.md

Settings URL schemes:

Note: < i=OS 5.1 use prefs:. > 5.1 use app-settings:

  • app-settings:root=General&path=About
  • app-settings:root=General&path=ACCESSIBILITY
  • app-settings:root=AIRPLANE_MODE
  • app-settings:root=General&path=AUTOLOCK
  • app-settings:root=General&path=USAGE/CELLULAR_USAGE
  • app-settings:root=Brightness
View cloudSettings
{"lastUpload":"2020-04-01T03:33:25.122Z","extensionVersion":"v3.4.3"}
@joshbuchea
joshbuchea / mac-setup.sh
Created Aug 8, 2019 — forked from matteocrippa/mac-setup.sh
a script to quick setup my dev Mac
View mac-setup.sh
#!/usr/bin/env bash
echo "Install XCode first"
xcode-select --install
# Setup directories
mkdir ~/Projects
mkdir ~/Projects/Repositories
mkdir ~/Projects/Material
@joshbuchea
joshbuchea / slugify.js
Created Aug 22, 2018 — forked from hagemann/slugify.js
Slugify makes a string URI-friendly
View slugify.js
function slugify(string) {
const a = 'àáäâãåèéëêìíïîòóöôùúüûñçßÿœæŕśńṕẃǵǹḿǘẍźḧ·/_,:;'
const b = 'aaaaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@joshbuchea
joshbuchea / react-example-bare-minimum.html
Last active Jun 27, 2018
React Example: Bare Minimum
View react-example-bare-minimum.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>React Example: Bare Minimum</title>
<link rel="icon" href="https://reactjs.org/favicon.ico" />
</head>
<body>
@joshbuchea
joshbuchea / suckData.js
Created Jan 22, 2018 — forked from Frondor/suckData.js
HTML table data to JSON
View suckData.js
/*
* THIS IS NOT A PLUGIN
* ~ but a personal snippet
*
* Sometimes when prototyping my designs, I like to get dummy data pretty fast.
* I use this snippet to extract that data from working (aka "real life") tables from other HTML tables I find on the net.
* So I'll need that same data but inside an object.
*
* This script assumes by default the table has the following structure:
* <table>
You can’t perform that action at this time.