Skip to content

Instantly share code, notes, and snippets.

import { Controller } from "@hotwired/stimulus";
export default class ApplyCssController extends Controller {
static targets = ["element"];
static values = {
selector: String,
onConnect: { type: Boolean, default: false },
};
#!/bin/bash
# Generate a `:something-wow:` Slack emoji
# With thanks to https://gist.github.com/briancain/2efe69b8870be01bafde829d3933b2d3
set -euo pipefail
if [ $# -eq 0 ]; then
echo "Usage: $0 input.png"
exit 1
@percysnoodle
percysnoodle / SGBtvOSMotionEffect.m
Last active September 11, 2015 16:58
First attempt at a tvOS motion effect suitable for focusable objects
//
// SGBtvOSMotionEffect.m
//
// Created by Simon Booth on 11/09/2015.
// Copyright © 2015 agbooth.com. All rights reserved.
//
#import "SGBtvOSMotionEffect.h"
@implementation SGBtvOSMotionEffect
@implementation DTMutableCoreTextLayoutFrame
{
NSUInteger _numberOfDrawingOperationsInParallel;
NSConditionLock *_lock;
}
- (void)_incDrawingOperations
{
[_lock lock];
_numberOfDrawingOperationsInParallel++;
@percysnoodle
percysnoodle / windowsWithKeyWindow
Created August 12, 2013 08:51
windowsWithKeyWindow with main window
- (NSArray *)windowsWithKeyWindow
{
NSMutableArray *windows = self.windows.mutableCopy;
UIWindow *keyWindow = self.keyWindow;
if ([windows containsObject:keyWindow]) {
[windows removeObject:keyWindow];
}
[windows insertObject:keyWindow atIndex:0];
@percysnoodle
percysnoodle / gist:5705334
Created June 4, 2013 11:45
Algorithm to match up grid lines. The maximum value for the left axis starts off in a double called maximumLeft and the value for the right starts off in maximumRight. At the end, they have been increased so that they can be used to produce matching ranges.
NSInteger numberOfIntervals;
double leftPowerOfTen = pow(10, floor(log10(maximumLeft)));
double leftMultipleOfPowerOfTen = maximumLeft / leftPowerOfTen;
// round the maximum left up to something nice
if (leftMultipleOfPowerOfTen < 1.25)
{
maximumLeft = leftPowerOfTen * 1.25;
numberOfIntervals = 5;