Skip to content

Instantly share code, notes, and snippets.

View mukaschultze's full-sized avatar
¯\_(ツ)_/¯

Samuel Schultze mukaschultze

¯\_(ツ)_/¯
View GitHub Profile
@mukaschultze
mukaschultze / discord.sh
Created May 15, 2024 12:23
Update discord on manjaro
git clone https://gitlab.archlinux.org/archlinux/packaging/packages/discord.git /tmp/discord
cd /tmp/discord
PACMAN=yay makepkg -si --skipinteg
@mukaschultze
mukaschultze / max-line.directive.ts
Created January 22, 2024 18:53
Max line directive NativeScript
import { Directive, ElementRef, Input, OnInit, OnChanges } from '@angular/core';
import { Label } from '@nativescript/core';
@Directive({ selector: 'Label[maxLines]' })
export class LabelMaxLinesDirective implements OnInit, OnChanges {
constructor(private el: ElementRef) {}
@Input() public maxLines = 1;
public get nativeView(): Label {
@mukaschultze
mukaschultze / crypto.ts
Created November 21, 2023 18:46
NativeScript Polyfiils
import { isAndroid } from '@nativescript/core';
class TypeMismatchError extends Error {}
class QuotaExceededError extends Error {}
/**
* @param {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Uint8ClampedArray} array
*/
function getRandomValues(array) {
if (
@mukaschultze
mukaschultze / optimize.sh
Created June 15, 2023 21:05
Optimize PNG images using pngcrush
#!/bin/bash
original_total=0
final_total=0
saved_total=0
# Calculate original total size
while IFS= read -r -d '' file; do
size=$(stat -c "%s" "$file")
original_total=$((original_total + size))
@mukaschultze
mukaschultze / output.env
Created September 28, 2022 16:13
Easy macOS VM
export DEVICE_MODEL="iMacPro1,1"
export SERIAL="--GENERATED--"
export BOARD_SERIAL="--GENERATED--"
export UUID="--GENERATED--"
export MAC_ADDRESS="--GENERATED--"
export WIDTH="1920"
export HEIGHT="1080"
@mukaschultze
mukaschultze / review.ts
Created September 13, 2022 18:44
NativeScript prompt user for app review
import { Application, Device, isAndroid, Utils } from '@nativescript/core';
/**
* This method uses native APIs to request an app review from the user. There's
* no guarantee that the user will actually be prompted when this method is
* called and there's no way to know if the left a review or not. This is a
* limitation of the platform.
*
* NOTES
*
@mukaschultze
mukaschultze / pin-asterisk-versions-lockfile.js
Last active August 8, 2022 13:12
Pin yarn workspace versions
/** Yarn workspaces currently don't have a way of specifying that a workspace
* (i.e., package) should use the worktree (i.e., root package.json) version for
* a dependency. Some projects use the @* version descriptor (equivalent to
* latest version) to achieve this, although this approach works most of the
* time it can easily get the workspace and worktree versions out of sync when
* some of the packages are explicitly updated via package.json or when
* yarn.lock gets regenerated.
*
* The alternative to using the @* syntax is using the `file:` version
* descriptor, so the workspace uses the package from a given directory, in this
@mukaschultze
mukaschultze / arch.md
Last active March 6, 2022 01:50
Free Arch Linux on GCP
@mukaschultze
mukaschultze / .dockerignore
Created January 29, 2022 21:34
Unity + Mirror over WebSockets using traefik as a reverse proxy
*
!/Builds/
!nginx.conf
@mukaschultze
mukaschultze / loopback_bind.md
Last active August 29, 2023 04:57
Acessando serviços no docker sem expor as portas publicamente

Acessando serviços no docker sem expor as portas publicamente

Expondo portas apenas no loopback

Com Docker é possível configurar um container para que ele ouça conexões à uma porta apenas em um IP por meio da opção publish, no formato ip:hostPort:containerPort. Isso impede que conexões sejam feitas por outros IPs sejam aceitas.

Se configurarmos o container para ouvir apenas no IP de loopback (127.0.0.1),