Skip to content

Instantly share code, notes, and snippets.

@xErik
xErik / myvisibility.dart
Last active October 3, 2023 10:05
Calculate visibility / field of view / line of sight for tile based maps as often found in roguelike games, by Adam Milazzo.
import 'dart:math';
/// This is a port to Dart of "My algorithm" by Adam Milazzo.
///
/// It calculates visibility / field of view / line of sight for tile
/// based maps as often found in roguelike games.
///
/// The advantages of this algorithm are discussed here:
///
/// http://www.adammil.net/blog/v125_Roguelike_Vision_Algorithms.html#code
@xErik
xErik / umlaut.ahk
Created January 28, 2023 18:01
German Umlaut with Autohotkey 2
; German Umlaut for English keyboard
;
; ä = ALT + a
; Ä = SHIFT + ALT + a
;
; etc.
;
; Converted to Autohotkey V2 2023
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class Controller extends GetxController {
var items = <String>['a'].obs;
var itemCurrent = 'a'.obs;
addItem(String item) => items.add(item);
}
void main() => runApp(GetMaterialApp(home: Home()));
@xErik
xErik / gist:8037dcf5cfa4237f1126438bee770db6
Last active June 10, 2021 14:12
Game Level Calculation With Linearly Rising Level Gap
EXP LEVEL DIFF
0 1 0
10 2 10
30 3 20
60 4 30
100 5 40
150 6 50
210 7 60
280 8 70
360 9 80
@xErik
xErik / course-manager.service.ts
Last active October 27, 2019 08:06
Filter Observable AngularFire results by multiple attributes dynamically with a Form
...
getCourses(): Observable<Course[]> {
return this.db
.collection<Course>(this.path)
.valueChanges({ idField: 'id' }); // id field is nice to have, only
}
...
@xErik
xErik / child.ts
Created October 26, 2019 06:55
Angular Sub-Components with Sub-Form input / select
@Component({
selector: 'my-comp',
template: `
<div [formGroup]="group">
<input [formControlName]="'bar'" />
</div>
`
})
export class MyComponent {
@Input() group: FormGroup;

Solution with Angular 8

Console errors and warnings, be gone:

  • cannot display FACEBOOK-BLA in hidden frame
  • FB.login does not exist ...
  • HTTP is not supported, use HTTPS ...

Steps:

@xErik
xErik / components>footer>footer.component.html
Last active February 16, 2022 19:56
Angular 8 | Bootstrap 4 | Footer at bottom of viewscreen OR after long page content
// --- CALL FROM ANGULAR
import { Component, OnInit } from '@angular/core';
import { AngularFireFunctions } from '@angular/fire/functions';
@Component({
selector: 'app-functiontest'
})
export class FunctiontestComponent implements OnInit {
constructor(private func: AngularFireFunctions) { }
import functions = require('firebase-functions');
import fs = require('fs');
import os = require('os');
import path = require('path');
const admin = require('firebase-admin');
admin.initializeApp();
const bucket = admin.storage().bucket();
export const textToSpeechRequest = functions.https.onCall((data: any, context: any) => {
const destName = 'test.txt';