Skip to content

Instantly share code, notes, and snippets.

View niorad's full-sized avatar
🏠
Working from home

Antonio Radovcic niorad

🏠
Working from home
View GitHub Profile
@niorad
niorad / xxx.ts
Last active January 17, 2025 15:51
xxx
import { goget } from "../_util/util.ts";
const allPatterns: string[] = goget("input.txt")[0].split(", ").sort((
a,
b,
) => a.length - b.length);
const designs: string[] = goget("input2.txt");
let possibleDesigns = 0;
let patterns: string[] = [];
const cache = {};
@niorad
niorad / Aoc24_18_1.ts
Created December 18, 2024 17:29
Aoc24_18_1
import r from "npm:raylib";
import { goget } from "../_util/util.ts";
const bytes: number[][] = goget("input.txt").map((line) => {
//const bytes: number[][] = goget('testinput.txt').map((line) => {
const str = line.split(",");
return [parseInt(str[0]), parseInt(str[1])];
});
const VISUAL = false;
@niorad
niorad / xxx.ts
Last active December 17, 2024 16:22
xxx
const ins = [2, 4, 1, 7, 7, 5, 1, 7, 4, 6, 0, 3, 5, 5, 3, 0];
// const ins = [0, 3, 5, 4, 3, 0];
const insLength = ins.length;
function doit(initialA: number = -1, compare: boolean = false) {
const output = [];
const ops = [
// ADV
(operand: number) => {
@niorad
niorad / server.go
Created May 17, 2023 08:17
Simple Golang-Server for serving Godot-Web-Exports locally (Needed for Godot 4.0)
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
fs := http.FileServer(http.Dir("./"))
@niorad
niorad / skewbacca_poc.swift
Created January 1, 2019 15:55
Swift Core Image Perspective Correction POC
import Cocoa
let context = CIContext()
let lidimg = NSImage(named: "lid")?.cgImage(forProposedRect: nil, context: nil, hints: nil)
let originalCIImage = CIImage(cgImage: lidimg!)
func perspFilter(_ input: CIImage) -> CIImage?
@niorad
niorad / iban_grouping.js
Created March 8, 2018 13:50
Automatic grouping of Iban-Numbers, supporting Backspace- and Del-Keys.
// <input type="text" id="iban">
document.getElementById('iban').addEventListener('input', function (e) {
var target = e.target, position = target.selectionEnd, length = target.value.length;
target.value = target.value.replace(/[^\dA-Za-z]/g, '').replace(/(.{4})/g, '$1 ').trim();
if(e.inputType === 'deleteContentForward') {
target.selectionEnd = position += ((target.value.charAt(position) === ' ') ? 1 : 0);
} else {
target.selectionEnd = position += ((target.value.charAt(position - 1) === ' ' && target.value.charAt(length - 1) === ' ' && length !== target.value.length) ? 1 : 0);
if(target.selectionEnd % 5 === 0) {
@niorad
niorad / history.html
Created February 15, 2018 14:20
Changing Forms with Browser History push/pop
<html>
<head>
<title>Browser-History Push/Pop</title>
</head>
<body>
<form id="myform">
<label>
@niorad
niorad / json-to-struct.go
Last active September 16, 2017 12:21
Simple JSON-to-Struct-Example in Golang
package main
import (
"encoding/json"
"fmt"
)
type Fleet struct {
Cars []Car
Countries []string
'use strict'; // avoid ambiguity and sloppy errors
/**
* Tests whether or not a given string is a Palindrome
* @param {string} stringToTest - the string to test.
*/
function isPalindrome(stringToTest) {
var start = 0,
end;
@niorad
niorad / uiViewToPhotoLibrary.swift
Created April 22, 2016 06:34
Save UIView in User's Photo-Library
UIGraphicsBeginImageContextWithOptions(myView.bounds.size, true, 0)
myUiView.drawViewHierarchyInRect(myView.bounds, afterScreenUpdates: true)
let myImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil)