Skip to content

Instantly share code, notes, and snippets.

View DimaRU's full-sized avatar
🏠

Dmitriy Borovikov DimaRU

🏠
  • Lúnaturco, Dor Daedeloth
View GitHub Profile
$DOCC_BRANCH="docc"
git switch --orphan $DOCC_BRANCH
mkdir docs
touch docs/.nojekyll
git commit --allow-empty -m "docc initial commit"
git push -u origin $DOCC_BRANCH
@DimaRU
DimaRU / 00-docker-shorewall.md
Created January 5, 2024 17:06 — forked from lukasnellen/00-docker-shorewall.md
setup shorewall for docker networking beyond the default bridge network, e.g., for docker-compose

Docker(-compose) with shorewall

The shorewall documentation explains in http://shorewall.org/Docker.html how to configure shorewall for use with docker. The problem with the configuration is that it only allows connections from the host to the main bridge docker0. Connections to other networks on dynamically created bridges, with names starting by default with br-, is blocked. Instead of the recommended contents of /etc/shorewall/interfaces, use wild-card interface names as follows:

#ZONE	INTERFACE	OPTIONS
#dock	docker0		bridge     # disabled default recommendation
dock 	docker0		physical=docker+,routeback=1
dock 	br		physical=br-+,routeback=1
@DimaRU
DimaRU / UnsafePointer Converter.swift
Created November 19, 2023 17:30 — forked from codelynx/UnsafePointer Converter.swift
[swift] Unsafe Pointer conversion
//
// Swift UnsafePointer converter
// Kaz Yoshikawa
//
// These code demonstrates how to convert swift pointers to the other forms of pointers.
//
// Source:
// Swift の Array やら ArraySlice やらポインタの変換まとめ
// https://qiita.com/Satachito/items/4c39c9b06304e4d86660
//
func loadWebArchive(named name: String, into webView: WKWebView) {
let fileURL = self.webArchiveDirectoryURL.appendingPathComponent("\(name).webarchive")
do {
let archiveData = try Data(contentsOf: fileURL)
webView.load(archiveData, mimeType: "application/x-webarchive", characterEncodingName: "", baseURL: fileURL)
print("Web archive loaded from: \(fileURL.path)")
} catch {
print("Error loading web archive: \(error.localizedDescription)")
}
@DimaRU
DimaRU / example-clean.sh
Created May 8, 2022 08:58
Testing PackageBuildInfoExample
#!/bin/bash
set -x
git clone https://github.com/DimaRU/PackageBuildInfoExample
cd PackageBuildInfoExample
swift run
touch a
swift package clean
swift run
git add a
swift package clean
@DimaRU
DimaRU / Setup GCC and CLANG Toolchains.md
Created May 28, 2021 08:17 — forked from bhaskarvk/Setup GCC and CLANG Toolchains.md
Proper GCC (vers. 5/6/7) & LLVM/CLANG (vers. 4/5) Toolchain Setup on Ubuntu/Linux Mint

This approach uses update-alternatives to manage GCC and LLVM/CLANG C/C++ compiler toolchains. Although tested on Linux Mint 18.3, this approach should work on any Debian based distro or for that matter any Linux distro with update-alternatives support, provided the packages are installed correctly.

There are 3 files

  • gcc-alternatives.sh installs GCC versions 5/6/7 and sets up alternatives for gcc/g++/cpp/gfortran.
  • llvm-clang-alternatives.sh installs LLVM and CLANG versions 4/5 and sets up alternatives for various LLVM and CLANG programs including clang and clang++.
  • cc-alternatives.sh sets up alternatives for the cc, cxx, and the ld commands. This script can be used to change systemwide default compiler/linker combination to either GCC or CLANG.

Once these scripts are run you can change the system GCC/CLANG versions by running sudo update-alternatives --config gcc|clang. To change the default compiler/linker combo used by t

@DimaRU
DimaRU / Makefile
Created January 15, 2021 14:53
Универсальный Makefile для плагина VSCode Easy C++ Projects
CC := clang
CFLAGS := -Wall -Wextra -g
BIN := bin
SRC := src
INCLUDE := include
LIB := lib
LFLAGS :=
LIBRARIES :=
@DimaRU
DimaRU / Brewfile
Last active January 14, 2021 17:05
School21 environment prepare
# Powerful, clean, object-oriented scripting language
brew "ruby"
# Terminal-based visual file manager
brew "midnight-commander"
# Internet file retriever
brew "wget"
# VSCode
cask "visual-studio-code"
cask "tunnelblick"
cask "iterm2"
@DimaRU
DimaRU / doubletostring.swift
Created December 26, 2020 09:46
Round double (swift)
extension Double {
func rounded(toPlaces places:Int) -> String {
let divisor = pow(10.0, Double(places))
var returnValue = "\((self * divisor).rounded() / divisor)"
if(returnValue.split(separator: ".")[1].count == 1 && places > 1) {
returnValue += "0"
}
return returnValue
}
}
@DimaRU
DimaRU / 1_SFSymbols.scpt
Created July 28, 2020 09:03 — forked from diamantidis/1_SFSymbols.scpt
How to use AppleScript to generate an enum for the SF Symbols
activate application "SF Symbols"
tell application "System Events"
tell process "SF Symbols"
-- Click the “list” radio button.
click radio button 2 of radio group 1 of group 3 of toolbar 1 of window 0
tell outline 1 of scroll area 1 of splitter group 1 of window 0
select (row 1 where value of static text 1 of UI element 1 starts with "All")