Skip to content

Instantly share code, notes, and snippets.

View mackankowski's full-sized avatar
🤖
teaching machines

Maciej Kankowski mackankowski

🤖
teaching machines
View GitHub Profile
@mackankowski
mackankowski / # Network layer in Swift - callAPI.swift
Last active September 6, 2021 17:09
Network layer in Swift (using Combine)
import Combine
import UIKit
struct Agent {
struct Response<T> {
let value: T
let response: URLResponse
}
func run<T: Decodable>(_ url: URL, _ decoder: JSONDecoder = JSONDecoder()) -> AnyPublisher<Response<T>, Error> {
@mackankowski
mackankowski / # Wordpress - local set up and migration - README.md
Last active October 2, 2023 18:36
Wordpress - local set up and migration
<!-- paste it inside <head/> tag in the index.html file -->
<meta property="og:title" content="Your company slogan" />
<meta property="og:description" content="Your company – and why it's the best!"/>
<!--
- only absolute paths are supported for Twitter - starting with https:// or http://
- read more: https://stackoverflow.com/questions/9858577/open-graph-can-resolve-relative-url
- recommended image size: 1200 × 627px
-->
@mackankowski
mackankowski / # Network layer in React - useFetch.ts
Last active September 7, 2021 07:14
Network layer in React - using axios
import { useCallback, useContext } from "react";
import axios, { AxiosError, AxiosResponse } from "axios";
import { UserContext } from "modules/AuthManager/userContext";
export const useFetch = () => {
const { removeToken, token } = useContext(UserContext);
const getResponse = useCallback(
(
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE",
@mackankowski
mackankowski / # Debug React component's props changes (performance analysis) - arePropsEqualDebug.ts
Last active June 30, 2022 11:29
Debug React component's props changes (performance analysis)
/* eslint-disable no-console */
// goal: debug props changes (performance analysis)
// alternative for https://github.com/welldone-software/why-did-you-render
// usage: memo(someComponent, arePropsEqualDebug(someComponent.name)
// read more: https://reactjs.org/docs/react-api.html#reactmemo
// tip: use console.count() for getting a number of renders
function areEqualShallow(a: any, b: any) {
for(var key in a) {
@mackankowski
mackankowski / # User Notification Center (iOS, Swift) - AppDelegate.swift
Last active February 8, 2022 15:48
User Notification Center (iOS, Swift)
import HealthKit
import UserNotifications
import Combine
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
unc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ask the user for notification permissions
@mackankowski
mackankowski / # Docker network issues when using Rancher Desktop on Mac with Apple Silicon ARM-based processor (M1 chip) - readme.md
Last active January 19, 2024 04:16
Docker network issues when using Rancher Desktop on Mac with Apple Silicon ARM-based processor (M1 chip)

Docker network issues when using Rancher Desktop on Mac with Apple Silicon ARM-based processor (M1 chip)

When pulling image (e.g. docker run hello-world) or signing to the Docker Hub (docker login) the following error occurs:

Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io.

To fix the issue, change DNS server adress for the linux virtual machine instance: lime-vm

Automatic way (recommended)

@mackankowski
mackankowski / # How to create a bootable Windows 7, 8 ,10, 11 installer USB on MacOS - readme.md
Last active September 1, 2024 12:03
How to create a bootable Windows 7, 8, 10, 11 installer USB on macOS

How to create a bootable Windows 7, 8, 10, 11 installer USB on macOS

Run in Terminal:

  1. brew install wimlib - run, if wimlib is not installed yet (required for splitting large files)
  2. To identify target USB device, run: diskutil list
  3. Format USB drive: diskutil eraseDisk MS-DOS "$WIN_USB_NAME" MBR /dev/$DISK where $WIN_USB_NAME is a new volume name (e.g. WIN) and $DISK is a target disk identificator (e.g. disk5). Alternatively, you can try GTP partititon style instead of MBR (recommended for UEFI = newer Windows distributions)
  4. To mount Windows installer image, run: hdiutil mount ~/Desktop/$WIN_INSTALLER_IMAGE.iso where $WIN_INSTALLER_IMAGE is installer image name.
  5. Copy all files to the USB drive, beside the "install" file (if it's over 4GB size): rsync -vha --exclude=sources/install.$EXT /Volumes/$WIN_INSTALLER_NAME/ /Volumes/$WIN_USB_NAME where $EXT is wim or esd, $WIN_INSTALLER_NAME is the mounted Windows installer volume name and $WIN_USB_NAME is target disk name.
@mackankowski
mackankowski / HP Printer - page edges are cut off when printing documents directly from Mac OS Finder app.md
Last active March 23, 2023 20:14
HP Printer - page edges are cut off when printing documents directly from Mac OS Finder app
  1. Open any document in Preview app (e.g. any PDF file).
  2. From system top menu, choose: File > Print...
  3. From print dialogue, choose Page Size > Manage Custom Sizes.
  4. Add new profile with the following values:
  • Width: 209,9
  • Height: 297,04
  • Margins: User Defined
  • Top, Bottom, Left, Right: 0
  1. Set profile as a default: System Settings > Printers &amp; Scanners > Default paper size
@mackankowski
mackankowski / 70mai Dash Cam - how to turn off the power-on sound.md
Last active April 3, 2024 08:01
70mai Dash Cam - how to turn off the power-on sound

Source: https://dashcamtalk.com/forum/threads/how-to-disable-power-up-sound.45398/post-559083

Connect to the dvr's wi-fi network. Launch any telnet client. For example "Mobile Telnet" (https://play.google.com/store/apps/details?id=mobiletelnet.feng.gao) ⋮ -> "Telnet Settings" -> Remote Host Name: "192.168.0.1", port: "23" (by default) ⋮ -> "Connect".... The inscription "NVTEAM login" will appear: Write "root", press "enter" Enter the command (rename the turn-on sound) and press "enter": Code: mv /mnt/app/res/voice/public/bootsound.raw /mnt/app/res/voice/public/bootsound_1.raw