Skip to content

Instantly share code, notes, and snippets.

View Albert221's full-sized avatar
💻

Albert Wolszon Albert221

💻
View GitHub Profile
@Albert221
Albert221 / map_value_stream.dart
Created July 31, 2023 09:21
MapValueStream<T, U> for RxDart
import 'package:async/async.dart';
import 'package:rxdart/rxdart.dart';
class MapValueStream<T, U> extends DelegatingStream<U>
implements ValueStream<U> {
MapValueStream(this._source, this._mapper) : super(_source.map(_mapper));
final ValueStream<T> _source;
final U Function(T) _mapper;
@Albert221
Albert221 / never_changing_value_listenable.dart
Created June 17, 2022 12:20
NeverChangingValueListenable<T> for Flutter
import 'package:flutter/foundation.dart';
class NeverChangingValueListenable<T> implements ValueListenable<T> {
const NeverChangingValueListenable(this.value);
@override
final T value;
@override
void addListener(VoidCallback listener) {}
@Albert221
Albert221 / proxy_value_listenable.dart
Last active June 17, 2022 12:26
ProxyValueListenable<T> for Flutter
import 'package:flutter/foundation.dart';
class ProxyValueListenable<T> implements ValueListenable<T> {
ProxyValueListenable(this._parent) {
_parent.addListener(_listener);
}
final _listeners = <VoidCallback>[];
ValueListenable<T> _parent;
@Albert221
Albert221 / main.dart
Created June 22, 2020 16:49
Tutorial on deploying Arbify locally and using it in your Flutter app
import 'package:arbify_hello_world/l10n/l10n.dart';
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
supportedLocales: S.delegate.supportedLocales,
localizationsDelegates: [
S.delegate,
],
@Albert221
Albert221 / JetBrains-Mono.css
Last active March 15, 2024 08:20
CSS for using JetBrains Mono on the Web. Simply copy&paste it to your stylesheet.
@font-face {
font-family: 'JetBrains Mono';
src: url('https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono/web/woff2/JetBrainsMono-Bold-Italic.woff2') format('woff2'),
url('https://cdn.jsdelivr.net/gh/JetBrains/JetBrainsMono/web/woff/JetBrainsMono-Bold-Italic.woff') format('woff');
font-weight: 700;
font-style: italic;
font-display: swap;
}
@font-face {
@Albert221
Albert221 / ToggleEthernet.ps1
Created April 15, 2020 01:06
PowerShell script to toggle (enable/disable) Ethernet net adapter
# Run as administrator - https://stackoverflow.com/a/57035712/3158312
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
exit;
}
$adapterName = 'Ethernet'
$status = Get-NetAdapter -Name $adapterName | Format-List -Property "Status" | Out-String
@Albert221
Albert221 / CONCEPT.md
Last active September 11, 2019 20:21
Contact form endpoint CONCEPT

Contact form endpoint

Do you want to have a simple, static website that the only dynamic thing is a contact form? You don't want to go serverless and/or use formspree.io, AWS Lambda or similar? I got your back.

With this Contact form endpoint all you need is a hosting with PHP (cheapest one will do) and a text editor to configure few things (or leave it with defaults).

What you also need is a basic knowledge of HTML to connect the form to the endpoint or some knowledge about XHR to take advantage of the JSON support to make your contact form work without a refresh!

Features

@Albert221
Albert221 / index.md
Created April 23, 2018 22:32
Dependency Injection Principle

Dajmy dwa scenariusze, niepodąrzający za DIP i taki z nim zgodny. Na początek klasa którą będziemy chcieli przetestować:

<?php

class Authenticator
{
    private $userRepository;

    public function __construct(UserRepository $userRepository)
<?php
$pdo = new PDO(...);
$pdo->exec('CREATE TABLE users(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) NOT NULL) ENGINE=InnoDB');
<?php
try {
$pdo = new PDO('mysql:host=localhost;port=3307;dbname=test', 'root', '', [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
]);
} catch (PDOException $e) {
echo 'Błąd przy łączeniu z bazą danych: ' . $e->getMessage();
}