Skip to content

Instantly share code, notes, and snippets.

@jnewc
jnewc / gist:0e8ee1e33e3bd40d6af619c3081f0d40
Created November 28, 2024 19:17
Make the YouTube progress bar red again (TamperMonkey UserScript)
// ==UserScript==
// @name Make the YouTube progress bar red again
// @namespace http://tampermonkey.net/
// @version 2024-11-24
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant GM_addStyle
// ==/UserScript==
@jnewc
jnewc / yolo.swift
Created August 15, 2020 17:15
More natural (fight me) OptionSet syntax for Swift
func |<T>(_ first: T, _ second: T) -> T where T: OptionSet {
return first.union(second)
}
@jnewc
jnewc / file.c
Created April 14, 2020 16:37
LEDTime.ino
#include <Time.h>
#include <TimeLib.h>
#include <NeoPixelBus.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
int dividerLEDs[] = { 4, 11 };
int dividerLEDsCount = 2;
@jnewc
jnewc / fix-sourcetree-git-secrets.sh
Last active August 26, 2020 16:44 — forked from Neo23x0/fix-sourcetree-git-secrets.sh
SourceTree git-secrets
#!/bin/bash
#
# THIS WORKS WITH GIT INSTALLED VIA BREW
#
# Fixes error:
# git: 'secrets' is not a git command. See 'git --help'.
#
# More information: https://qiita.com/yamaryu0508/items/d959dc32442b08b8a0a4
brew install git
@jnewc
jnewc / NotesApp.swift
Last active December 18, 2024 13:41
A notes app written in <100 lines of swift using SwiftUI
import SwiftUI
let dateFormatter = DateFormatter()
struct NoteItem: Codable, Hashable, Identifiable {
let id: Int
let text: String
var date = Date()
var dateText: String {
dateFormatter.dateFormat = "MMM d yyyy, h:mm a"
@jnewc
jnewc / swiftver.md
Created June 23, 2018 13:05
swiftver

swiftver - Swift versioning scheme

Currently Swift modules are mostly consumed using semantic versioning (i.e. using SPM or Cocoapods).

This scheme is a revised version of semantic versioning that links the major version of the latest Swift toolchain that the

Scheme

MAJOR - Incremented when the project is updated to a new Swift language version. e.g. For Swift 4, this would be '4'.

@jnewc
jnewc / ConditionalExecutionOperators.swift
Last active June 28, 2017 19:47
Conditional Execution Operators
/// Conditional execution operators
///
/// For a given argument:
/// * if the argument is truthy (i.e. true or non-nil), execute closure
/// * if the argument is falsy (i.e. false or nil), do not execute the closure
infix operator => : NilCoalescingPrecedence
public func =>(state: Bool, closure: @autoclosure () -> ()) {
if state { closure() }
@jnewc
jnewc / Logger.swift
Last active February 22, 2017 20:25
Class-based logger as a protocol extension
import Foundation
import Rainbow
public enum LogLevel: UInt {
case none = 0b0000
case debug = 0b0001
case info = 0b0011
case warn = 0b0111
case error = 0b1111
}
@jnewc
jnewc / NilRejectionExample.swift
Last active February 8, 2017 21:48
Nil-rejection operator example
infix operator !! : NilCoalescingPrecedence
func !!<UnwrappedType: Any, ErrorType: Error>(lhs: Optional<UnwrappedType>, rhs: ErrorType) throws -> UnwrappedType {
guard let unwrappedValue = lhs else {
throw rhs
}
return unwrappedValue
}
@jnewc
jnewc / i2c_test.c
Last active September 30, 2024 02:49
i2c analog stick driver
/*
* i2c_test.c
*/
#include <linux/slab.h> /* kzalloc */
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* KERN_INFO */
#include <linux/timer.h> /* timer_list */
#include <linux/workqueue.h> /* schedule_work */