Skip to content

Instantly share code, notes, and snippets.

View vladdeSV's full-sized avatar
🕳️

Vladimirs Nordholm vladdeSV

🕳️
View GitHub Profile
@vladdeSV
vladdeSV / userscript.js
Created February 27, 2025 12:09
prettier hacker news.css
// ==UserScript==
// @name Hacker News score tagger
// @namespace http://tampermonkey.net/
// @version 2025-01-24
// @description try to take over the world!
// @author vladde
// @match https://news.ycombinator.com/*
// @icon https://news.ycombinator.com/y18.svg
// @grant none
// ==/UserScript==
@vladdeSV
vladdeSV / starxpand_model_id_names.swift
Last active September 16, 2024 08:09
StarMicronics model id to name mapping
// StarMicronics identifier to name mapping in Swift.
//
// Leave a star on this Gist if you found it helpful.
// Contributions and corrections greatly appreciated.
//
// Sources & references, latest update at 2024-09-16.
//
// - https://star-m.jp/products/s_print/sdk/starxpand/manual/en/ios-swift-api-reference/star-printer-model/index.html
// - https://github.com/star-micronics/StarXpand-SDK-iOS/blob/2fc49f245a0c8e2e460cb53383c908011e1e9d1f/StarIO10.xcframework/ios-arm64/StarIO10.framework/Modules/StarIO10.swiftmodule/arm64-apple-ios.swiftinterface#L740-L760
// - https://star-m.jp/products/s_print/sdk/starxpand/manual/en/index.html
@vladdeSV
vladdeSV / View+TopViewController.swift
Last active February 14, 2024 09:56
SwiftUI, get top view controller
//
// UIApplication+TopViewController.swift
// Ticketing & Sales
//
// Created by Vladimirs Nordholm on 2024-02-14.
//
import SwiftUI
extension UIApplication {
@vladdeSV
vladdeSV / ts-snippets.md
Last active March 9, 2023 13:38
TypeScript snippets I often find myself needing to rewrite.

TypeScript Snippets

TypeScript is great, but I often feel like there are fundamental pieces missing. This document is my go-to when I need some re-ocurring feature.

Snippets are in Pulic Domain.

array-partition

Separate array into two arrays based on filter

function partition<T>(array: T[], predicate: (element: T) => boolean): [T[], T[]] {
@vladdeSV
vladdeSV / math.gml
Last active March 27, 2022 21:08
My commonly used math-related helper functions in Game Maker Language
function map_range(a, b, c, d, value) {
return (value - a) / (b - a) * (d - c) + c
}
function normalize_arctan2_angle(angle) {
return (angle > 0) ? angle : angle + 2 * pi
}
function sin01(x) {
return 0.5 * (sin(x) + 1)
@vladdeSV
vladdeSV / created by -bf-
Last active June 17, 2024 19:47
​look at this lil' kitten! (♡ヮ♡)
_._ _,-'""`-._
(,-.`._,'( |\`-/|
`-.-' \ )-`( , o o)
`- \`_`"'-
/// Make a singleton out of any class.
/// Originally from David Simcha's "D-Specific Design Patterns" talk at DConf 2013. Code copied and modified from https://wiki.dlang.org/Low-Lock_Singleton_Pattern
module singleton;
template Singleton()
{
static typeof(this) get()
{
if (!instantiated)
{
@vladdeSV
vladdeSV / scone_demo.d
Last active November 20, 2017 20:08
whoops. how about not maxing out cpu ¯\_(ツ)_/¯
import core.thread;
import scone;
import scone.misc.ticker;
import std.math;
import std.stdio;
void main()
{
bool loop = true;
int l = 0;
/**
* Simple random checking.
*/
module slump;
import std.random : uniform;
///Returns: One out of `oneOutOf´ probability's chance of returning true
bool probabilityOf(int oneOutOf)
{
@vladdeSV
vladdeSV / flags.d
Created July 9, 2016 10:19
Contains basic binary flag checking, adding and removal. #dlang
/**
* Contains basic binary flag checking, adding and removal.
*/
module flags;
auto hasFlag(E)(in E check, in E type)
{
return (check & type) == type;
}