Skip to content

Instantly share code, notes, and snippets.

@chrissearle
chrissearle / 1-initialization.swift
Created August 25, 2023 13:55
Flurry integration
let sb = FlurrySessionBuilder()
.build(logLevel: FlurryLogLevel.all)
.build(crashReportingEnabled: true)
.build(appVersion: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String)
.build(iapReportingEnabled: true)
Flurry.startSession(apiKey: EnvConfig.flurryApiKey, sessionBuilder: sb)
@chrissearle
chrissearle / Example.vue
Last active June 30, 2023 08:44
DaisyUI close menu on vue route change
<script setup lang="ts">
import { useRoute } from 'vue-router'
import { watch, ref } from 'vue'
const route = useRoute()
const submenu1 = ref<HTMLElement | null>(null)
const closeMenu = (element: HTMLElement | null) => {
if (element && element.hasAttribute('open')) {
@chrissearle
chrissearle / colima-start
Last active August 18, 2023 14:26
Colima mac - auto-start
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
function shutdown() {
colima stop
exit 0
}
trap shutdown SIGTERM
<html>
<head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js"
@chrissearle
chrissearle / how-to-start-colima-automatically-on-macos.md
Created March 15, 2023 17:01 — forked from fardjad/how-to-start-colima-automatically-on-macos.md
[How to start Colima automatically on macOS] Instructions for starting Colima automatically on macOS similar to Docker Desktop #macos #colima #docker

Steps

  1. Allow colima start to run without password:
cat <<-EOF | sudo tee /private/etc/sudoers.d/colima
%admin ALL=NOPASSWD: /bin/rm -rf /var/run/docker.sock
%admin ALL=NOPASSWD: /bin/ln -s $HOME/.colima/docker.sock /var/run/docker.sock
EOF
@chrissearle
chrissearle / Controller.kt
Last active January 5, 2022 13:37
Kotlin coroutine spring boot MVC - Controller vs DSL
@RestController
class Controller(val service: SomeService) {
@GetMapping("/something")
fun all() = service.all()
@PostMapping("/something")
suspend fun save(@RequestBody something: CreateDTO) = service.create(something)
@PutMapping("/something/{id}")
suspend fun update(@PathVariable id: Long, @RequestBody updates: UpdateDTO) = service.update(id, updates)
@chrissearle
chrissearle / Convert.java
Created November 25, 2021 08:43
Convert png to rgb565
public class Convert {
public static void main(String[] args) {
String pngFile = args[0];
String datFile = args[1];
try {
BufferedImage image = ImageIO.read(new File(pngFile));
try (
LittleEndianDataOutputStream outputStream = new LittleEndianDataOutputStream(new FileOutputStream(datFile))
@chrissearle
chrissearle / Convert.java
Last active November 23, 2021 07:22
Convert PNG To RGB565 For Adafruit_GFX TFT
/**
* Could't get adafruit's image reader working on Teensy 4.1 - doesn't seem to be compatible with
* Teensy's version of the SD card library
*
* But - the TFT object has this method:
*
* void Adafruit_GFX::drawRGBBitmap(
* int16_t x,
* int16_t y,
* uint16_t * bitmap,
@chrissearle
chrissearle / zip_directories_to_xcassets.zsh
Created October 20, 2021 20:52
Create xcassets from three directories of PNG images - 1x, 2x and 3x
#!/bin/zsh
# Assumes you start with three directories of images in png format with the same name - 1x, 2x and 3x
# Call with four params
# zip_directories_to_xcassets.zsh name_of_asset_file directory_of_1x_pngs directory_of_2x_pngs directory_of_3x_pngs
ASSETS_DIR=$1.xcassets
D1=$2
D2=$3
D3=$4