Skip to content

Instantly share code, notes, and snippets.

View jwhitley's full-sized avatar
🏝️
balearic

John Whitley jwhitley

🏝️
balearic
View GitHub Profile
@gopsmith
gopsmith / DisableBigSurMonterey.sh
Last active July 2, 2024 23:31 — forked from b0gdanw/DisableBigSur.sh
Disable Big Sur and Monterey services
#!/bin/zsh
# CREDITS: Original idea and script disable.sh by pwnsdx https://gist.github.com/pwnsdx/d87b034c4c0210b988040ad2f85a68d3
# Big Sur revision by b0gdanw https://gist.github.com/b0gdanw/40d000342dd1ba4d892ad0bdf03ae6ea
# TEMPORARILY disabling (e.g. STOPPING via 'bootout') unwanted services on macOS 11 Big Sur and macOS 12 Monterey:
# This version is for a special boot that optimizes for real-time music performance and streaming video.
# Due to the read-only system volume introduced with macOS Catalina, this script can NOT be run in Recovery mode's Terminal.
# For my purposes I leave WiFi enabled, for streaming video to a local router with no internet connection.
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@joshburgess
joshburgess / newtypes-redux-api-actions.ts
Last active January 26, 2019 06:51
Using newtype-ts newtypes to dynamically generate multiple API Action types representing API request states
import { Predicate } from 'fp-ts/lib/function'
import { Prism } from 'monocle-ts'
import { Newtype, iso, prism, unsafeCoerce } from 'newtype-ts'
interface Optimistic<A extends string>
extends Newtype<
{
readonly Optimistic: unique symbol
readonly phantom: A
},
@cohenadair
cohenadair / firebase-sandbox.md
Last active September 26, 2023 05:39
Setting up development and production Firebase environments for iOS

Firebase Environments

Last updated: October 21st, 2019.

At the time of writing this gist (January 4th, 2017), I was unable to find true sandboxing to separate development and production environments for a Firebase project. The closest we can get is to create two separate Firebase projects -- one for development and one for production.

Pros

  • Complete separation and isolation of all Firebase features.
  • Freedom to experiment without risking the corruption of production data.

Cons

@alskipp
alskipp / ignoreNil.swift
Created May 6, 2016 00:04
How to ignore `nil` values using RxSwift without using❗️
// Create an `Observable` of Optional<Int>
let values: Observable<Int?> = [1, 2, .None, 3, .None, 4, 5].toObservable()
// Method 1: using a free function
// Requires passing the function to `flatMap`
func ignoreNil<A>(x: A?) -> Observable<A> {
return x.map { Observable.just($0) } ?? Observable.empty()
}
@YusukeHosonuma
YusukeHosonuma / ValidationViewController.swift
Created April 11, 2016 16:32
RxSwift - Validation sample
import UIKit
import RxSwift
import RxCocoa
let requiredUserNameLength = 5
let requiredPasswordLength = 5
let limitUserNameLength = 20
class ValidationViewController: UIViewController {
@kizzx2
kizzx2 / hammerspoon-move-resize.lua
Last active December 19, 2022 06:47
Hammerspoon script to move/resize window under cursor
-- Inspired by Linux alt-drag or Better Touch Tools move/resize functionality
function get_window_under_mouse()
-- Invoke `hs.application` because `hs.window.orderedWindows()` doesn't do it
-- and breaks itself
local _ = hs.application
local my_pos = hs.geometry.new(hs.mouse.getAbsolutePosition())
local my_screen = hs.mouse.getCurrentScreen()
@endash
endash / gist:acda517225dc9f4bc9db
Last active September 27, 2019 06:10
Photoshop style gradients in Core Graphics via use of CGShader (with thanks to @jernejstrasner, see his explanation of why your gradients might not look how your designers intended http://jernejstrasner.com/2014/01/09/smooth-gradients-ios.html) ⚠️ see comments for notes
func SineEaseInOutLinearAverage(x: Double) -> Double {
var easeInOutSine = ((cos(M_PI * x) - 1) / -2)
return (easeInOutSine + x) / 2
}
func ShadingFunctionCreate(startColor: NSColor, _ endColor: NSColor, _ slopeFunction: (Double) -> Double) -> (UnsafePointer<CGFloat>, UnsafeMutablePointer<CGFloat>) -> Void {
return { inData, outData in
let q = CGFloat(slopeFunction(Double(inData[0])))
outData[0] = startColor.redComponent + (endColor.redComponent - startColor.redComponent) * q
outData[1] = startColor.greenComponent + (endColor.greenComponent - startColor.greenComponent) * q
@robjwells
robjwells / Restart in Windows.applescript
Last active October 10, 2015 11:17
Quickly restart your Mac into Windows
set deviceID to (do shell script "diskutil list | awk '/YourBootcampPartition/ {print $NF}'")
do shell script "bless -device /dev/" & deviceID & " -legacy -setBoot -nextonly" ¬
with administrator privileges
tell application "Finder" to restart
require 'minitest/unit'
require 'celluloid'
module MiniTest
module Celluloid
class Runner < MiniTest::Unit
def _run_suites(suites, type)
futures = suites.map do |suite|
::Celluloid::Future.new { _run_suite suite, type }