Skip to content

Instantly share code, notes, and snippets.

View colinkiama's full-sized avatar
Very busy. Should be back to normal late May

Colin Kiama colinkiama

Very busy. Should be back to normal late May
View GitHub Profile
@colinkiama
colinkiama / FuzzySearch.vala
Created December 20, 2023 00:36
Vala Fuzzy Name Search - Inspired By Sublime Text
// Credit to: @treagod
const int SEQUENTIAL_BONUS = 15; // bonus for adjacent matches
const int SEPARATOR_BONUS = 30; // bonus if match occurs after a separator
const int CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower
const int FIRST_LETTER_BONUS = 15; // bonus if the first letter is matched
const int LEADING_LETTER_PENALTY = -5; // penalty applied for every letter in str before the first match
const int MAX_LEADING_LETTER_PENALTY = -15; // maximum penalty for leading letters
const int UNMATCHED_LETTER_PENALTY = -1;
@colinkiama
colinkiama / Helpers.vala
Last active July 19, 2023 17:47
enum_to_nick() - Method for easily converting any enum into a string value in Vala e.g "HTTP.POST" to "POST"
public class Helpers {
public static string enum_to_nick (int @value, Type enum_type) {
var enum_class = (EnumClass) enum_type.class_ref ();
if (enum_class == null) {
return "%i".printf (@value);
}
unowned var enum_value = enum_class.get_value (@value);
@colinkiama
colinkiama / canvasBoard.html
Last active May 6, 2023 14:28
Useful code for drawing front-end of four-in-a-row game with HTML5 Canvas API
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Canvas Tutorial</title>
<script>
function draw() {
const canvas = document.getElementById("tutorial");
if (canvas.getContext) {
@colinkiama
colinkiama / Notes.txt
Last active November 5, 2022 15:37
elementary Spreadsheet App Multiselection Notes
So it's possible to make each individual cell render by simply changing the cell.selected property to true.
The issue now is that the Sheet widget' cell selection logic is is written only for selecting one shell. There's no concept of multiple cell selection at all.
To remedy this, two major steps need to be taken:
- Completely rewrite the Sheet widget (start from scratch) in a multi-selction-first way (Use a collection to store selected ranges by default etc)
- Add a drag event that draws a selection area over time. As the mouse moves, update the selected cells based on the selected cells area.
- The selected cells should be re-evaluated based on whenever one or cells get removed from the selection area
- You will need to take into account that columns and rows can be resized so you'll need to keep track of the size of the next row cells and column cells before deciding to select/deselect them.
@colinkiama
colinkiama / win10_binary_fission.md
Last active August 19, 2022 13:00 — forked from dragon788/win10_binary_fission.md
Making the Windows 10 "chubby" install.wim compatible with a FAT32 USB so a UEFI bootable USB can be created from Linux/macOS/ChromeOS

MAGIC aka Making Anything Gruelingly "Impossible" Coherent

Whatever operating system you are using to create the USB, you will need to have a Windows 10 ISO, either from Microsoft or your system manufacturer and have a USB drive 8GB or larger (or one with at least 5GB of free space and using the FAT32 filesystem, but using a fresh and empty one is best).

TL;DR

#macOS/Linux
# First try the `bootiso` program, it has options for splitting the WIM for you!
# https://jsamr.github.io/bootiso/
# You need to already have 7zip aka `p7zip` on macOS and Linux, and `wimlib` macOS via `brew` or `wimtools` on Linux
@colinkiama
colinkiama / Rotation.cs
Last active December 23, 2020 11:51
UWP endless rotation animation with Windows.UI.Composition
Vector3 centerPoint = new Vector3((float)(element.ActualWidth * 0.5),
(float)(element.ActualHeight * 0.5), 0);
Visual logoDropShadowVisual = ElementCompositionPreview.GetElementVisual(element);
Compositor compositor = logoDropShadowVisual.Compositor;
ScalarKeyFrameAnimation animation = compositor.CreateScalarKeyFrameAnimation();
// Ensures that visual rotates at a consistent rate.
LinearEasingFunction easing = compositor.CreateLinearEasingFunction();
@colinkiama
colinkiama / INavigationService.cs
Created December 21, 2020 02:19
A UWP NavigationService designed for MVVM applications
using System;
using System.Collections.Generic;
using System.Text;
namespace UWPFastTrackTemplate.Services
{
public interface INavigationService
{
bool Navigate<TViewModel>();
bool GoBack();
@colinkiama
colinkiama / App.svelte
Created November 25, 2020 12:39
Parallax emoji confetti example
<script>
import { onMount } from 'svelte';
let characters = ['🥳', '🎉', '✨'];
let confetti = new Array(100).fill()
.map((_, i) => {
return {
character: characters[i % characters.length],
x: Math.random() * 100,
@colinkiama
colinkiama / package.json
Created November 23, 2020 17:51
Working Svelte Laravel Mix Extension Config
{
"name": "svelte-mix",
"version": "1.0.0",
"description": "Svelte mix",
"main": "index.js",
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
@colinkiama
colinkiama / LightweightTextBoxStyle.xaml
Created May 4, 2020 02:59
UWP TextBox style that's lightweight (No borders, no background. Just text
<Style TargetType="TextBox" x:Key="LightweightTextBoxStyle">
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
<Setter Property="Foreground" Value="{ThemeResource TextControlForeground}" />
<Setter Property="Background" Value="{ThemeResource TextControlBackground}" />
<Setter Property="BorderBrush" Value="{ThemeResource TextControlBorderBrush}" />
<Setter Property="SelectionHighlightColor" Value="{ThemeResource TextControlSelectionHighlightColor}" />
<Setter Property="BorderThickness" Value="{ThemeResource TextControlBorderThemeThickness}" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSi