Skip to content

Instantly share code, notes, and snippets.

View Pictor13's full-sized avatar
🤹‍♂️
Juggling with curiosity

Igor Pellegrini Pictor13

🤹‍♂️
Juggling with curiosity
  • BerlinOnline Stadtportal GmbH & Co. KG
  • Berlin
View GitHub Profile
@Pictor13
Pictor13 / replacement.md
Created March 19, 2024 09:45
Helm Values replacement (to only have a single one, rather than one per-environment)

FROM: helm/helm#10026 (comment)

As I have not found any easy way to use environment variables in the values.yaml have I used this line to full fill the requirements.

CI_ENVIRONMENT_SLUG=lala envsubst < charts/values.yaml| helm \
  --kubeconfig ../kubeconf-dev \
  -n mynamespace install --create-namespace -f - --dry-run myapp ./mycharts
@Pictor13
Pictor13 / amazon-search-result-filter.js
Last active November 2, 2023 00:18
Amazon - Hide unwanted search results permanently (localStorage)
/**
* Running this snippet in the browser console, when being on Amazon's result page,
* will provide a button to hide results permanently.
*
* TODO:
* - add option to insert and store also a description
* for the hidden products (for bugs, drawbacks, or other user notes)
* - support sync to cloud, in order to not loose the list when clearing
* browser cache
* - support public blacklists to share among users (practically, a rate
@Pictor13
Pictor13 / example_state-behaviour.js
Created July 28, 2023 03:24
Generic concerns separation
// benefits? disadvantages?
// state type-interface
type State = {
name: string,
age: number,
gender: string,
hobby: Array<string>
}
@Pictor13
Pictor13 / handle User & Manual click.js
Created July 26, 2023 00:55
Distinguish event triggered by User or by jQuery (+ cloneEvent & EventProxy examples)
const getCopy = obj => new Proxy(
obj,
{
get: function( target, prop, receiver ) {
let value = target[ prop ];
/*copy array*/ if ( Array.isArray( value ) ) return value.slice( 0 );
/*copy object*/ if ( typeof value === "object" && value.constructor.name === "Object" ) return Object.assign( {}, value );
/*copy primitive*/ return value;
}
}

Instructions

I want a dockerfile to bring up a container wiith php 8.0, supporting german language either in the OS and inside PHP.
The create a user"app"; the user has UID and GID configurable as APP_UID and APP_GID docker build arguments; the arguments have default value 61234.
The basic php extensions should be enabled; especially for XSLT, XML dom operations, german language support; but skip PECL packages and extensions that are unlikely to be used. In any case, don't exceed with the number of extensions installed; this is not a "production" Dockerfile! Node 14 and npm should be also present in the container.
Switch to the user "app".
Then copy into the container /app folder the composer.json, composer.lock and package.json and package-lock.json from the host machine.
Then install the compser & npm dependencies.
Try to be minimalistic in the instructions; don't repeat too many times the same command. Keep it simple!

@Pictor13
Pictor13 / HardCoreDebugLogger.php
Created January 31, 2023 07:26 — forked from lyrixx/HardCoreDebugLogger.php
Hardcore Debug Logger
<?php
const STREAM_OPEN_FOR_INCLUDE = 128;
final class HardCoreDebugLogger
{
public static function register(string $output = 'php://stdout')
{
register_tick_function(function () use ($output) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
```
#### PHP information
php -v
php -r 'phpinfo();'
#### Find user running PHP Cli on a Kubernetes deployment
k exec deploy/vergabeplattform app -- php -r '$ot=[];exec("id", $ot);var_export($ot);'
```
@Pictor13
Pictor13 / phpenv-install.md
Last active October 6, 2022 13:55 — forked from sergeyklay/phpenv-install.md
Multiple PHP versions using phpenv and php-build

Multiple PHP versions using phpenv and php-build

Install dependecies

Debian/Ubuntu users

sudo apt install \
  autoconf \
  bison \
@Pictor13
Pictor13 / TimeMachine_double_backup_README.md
Created September 15, 2022 02:19
TimeMachine: 2 backup copies, on the cloud (OneDrive) and on external hard-drive.

To trick OneDrive in backing up TimeMachine's backup, we use a SparseBundle filesystem (explorable) image/file, as it supports differential upload. The partition of the SSD (that contains the backup as a file) is symlinked inside the OneDrive folder (using fstab) so its content (the sparsebundle) gets synced AND is actually stored on the SSD partition (without taking space on the machine).

Create a TimeMachine.sparsebundle first, using Disk Utility:

  • set filesystem to Journaled HFS+ - Mac OS Extended (Journaled) (NOT Case-Sensitive)
  • choose "sparse bundle" as image-format
  • use a GUID partition map
  • give name "TimeMachineMac10" (is the mounting name, it will be used below from tmutil-setdestination!)
@Pictor13
Pictor13 / UsefulExtensions.kt
Last active January 5, 2022 20:13
Kotlin - Extension functions
// Int <--> Boolean
fun Boolean.toInt() = if (this) 1 else 0
fun Int.toBoolean() = if (this == 0) 0 else 1
// Int <--> Binary bit
fun Int.toBit() = this.mod(2).toBoolean().toInt()
fun Int.toBinaryString() = this.toString(2)
fun Int.toPaddedBinaryString() = this.toString(2).padStart(Int.SIZE_BITS, '0')
fun Int.toXaryString(baseX: Int) = this.toString(baseX)