Skip to content

Instantly share code, notes, and snippets.

View tuus-amicus's full-sized avatar
🎯
Sublimating

Dee tuus-amicus

🎯
Sublimating
View GitHub Profile
@tuus-amicus
tuus-amicus / fn-toogle.applescript
Created April 15, 2023 15:08
Toogle F1,F2,F... keys from/to standard functional keys. Supported <=13.x<= MacOS Keyboard UI preferences.
set sysvers to system version of (system info)
set venturaOS to "13.1"
considering numeric strings
set isNewInterface to (sysvers is greater than or equal to venturaOS)
end considering
if isNewInterface then
open location "x-apple.systempreferences:com.apple.Keyboard-Settings.extension"
tell application "System Events" to tell process "System Settings"
@tuus-amicus
tuus-amicus / cisco_connect_adfs.applescript
Last active April 8, 2022 14:50
Autofill credentials for ADFS cisco client connection. Allows to login with cisco only by 1 click for mac users.
-- Dmitry Terekhov <dimitry.terekhov@gmail.com>
-- 07/06/2021
set username to "login"
set keychainRecordName to "keychain_record_name"
set serverUri to "vpn.company.ru"
on getPassword(keychainItemName)
local password
set password to do shell script ("/usr/bin/security 2>&1 >/dev/null find-generic-password -gl " & quoted form of keychainItemName & " | cut -c 11-99 | sed 's/\"//g'")
@tuus-amicus
tuus-amicus / collections.kt
Created April 16, 2020 12:35 — forked from bastman/collections.kt
kotlin: How to join 2 collections by a foreign key predicate
data class Off(val id: Int, val offName: String)
data class Prop(val id: Int, val propName: String, val offId: Int)
data class Joined(val off: Off, val props: List<Prop>)
fun main(args: Array<String>) {
val offs: List<Off> = listOf(
Off(id = 1, offName = "Off A"),
Off(id = 2, offName = "Off B")
)
val props: List<Prop> = listOf(
@tuus-amicus
tuus-amicus / flatMap.java
Created February 8, 2020 17:05
java stream vs vavr
/**
Since the introduction of the Optional monadic container, lists may contain not only raw values but wrapped ones into Optional or Option in cases where Vavr is used.
The Java Collections Stream API requires us to filter out empty values via isPresent() and extract them from the wrapper through get(). Not to mention the stream() and collect() boilerplate.
flatMap makes it less verbose. It takes every present value from a given Optional and maps it to a 1-element stream of String. But instead of returning a stream of 1-element streams the result is flattened into one stream containing all the elements. Finally the map() operation can be performed.
Vavr takes it one step further, as usual ;) In this case flatMap extracts the value from the Option wrapper and if the value is not null it is passed further resulting in one list.
**/
// instead of
public java.util.List<String> legacyFlatMap1(java.util.List<Optional<String>> args) {
return args
.stream()
@tuus-amicus
tuus-amicus / instructions.md
Created January 11, 2020 12:58
Using BFG Repo Cleaner tool to remove sensitive files from your git repo

BFG Repo Cleaner is a tool that allows you to remove sensitive files from your git repo history. BFG assumes that the last commit in your HEAD branch is clean, and thus protects the last commit from being touched by the tool. All other commits in your HEAD branch will be wiped of the sensitive file. It should be noted that the tool provides an option to not touch the last commit of other branches in addition to your HEAD branch. This is explained below in step 4.B

For branches other than the HEAD branch, all commits will be wiped of the sensitive file including the last commit, if no other branches are specified to have their last commit protected.

  1. Download BFG using the following command in terminal: brew install bfg

  2. Clone a fresh copy of your repo, using the --mirror flag.

    git clone --mirror git://example.com/some-big-repo.git

@tuus-amicus
tuus-amicus / submodule-pull.sh
Created November 11, 2019 11:47 — forked from stephenparish/submodule-pull.sh
Update submodules in a git repository to the latest, but exclude one..
git submodule foreach '[ "$path" == "submodule-to-exclude" ] || git pull origin master'
@tuus-amicus
tuus-amicus / testing-tools.png
Last active July 29, 2019 07:40
Service virtualization and API mocking tools for microservices
testing-tools.png

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@tuus-amicus
tuus-amicus / m3u8.md
Last active December 16, 2020 08:49 — forked from primaryobjects/m3u8.md
How to download m3u8 and ts video movie streams.

m3u8 Downloading

  1. Open Chrome Developer tools and click the Network tab.
  2. Navigate to the page with the video and get it to start playing.
  3. Filter the list of files to "m3u8".
  4. Find master.m3u8 or index.m3u8 and click on it.
  5. Save the file to disk and look inside it.
  6. If the file contains a single m3u8 master url, copy that one instead.
  7. Run the program m3u8x.
  8. Paste the same m3u8 url in both textboxes (URL and Quality URL) and click "Headers" and set the referral url and user-agent from the request as found in Chrome.