Skip to content

Instantly share code, notes, and snippets.

View Londeren's full-sized avatar
💭
Building a rocket 🚀

Sergey Lebedev Londeren

💭
Building a rocket 🚀
View GitHub Profile
#!/usr/bin/env node
// Raycast Script Command Template
//
// Dependency: This script requires Nodejs.
// Install Node: https://nodejs.org/en/download/
//
// Duplicate this file and remove ".template" from the filename to get started.
// See full documentation here: https://github.com/raycast/script-commands
//
@Londeren
Londeren / pluralForm.php
Last active August 17, 2022 12:54
Склоняет существительное в зависимости от числительного идущего перед ним.
<?php
/**
* Склоняет существительное в зависимости от числительного идущего перед ним.
* Пример использования:
* 1. pluralForm($n, "письмо", "письма", "писем", 'письма отсутствуют')
* 2. pluralForm($n, array("письмо", "письма", "писем", 'письма отсутствуют'));
* @param $n int|float число
* @param $normative string|array Именительный падеж слова ИЛИ массив
* @param $singular string Родительный падеж ед. число
@Londeren
Londeren / app.module.ts
Last active August 5, 2022 08:29
Angular 14 custom ViewportScroller for Router option scrollPositionRestoration
// …
@NgModule({
imports: [
AppRouterModule,
// …
],
bootstrap: [RootComponent],
providers: [
// …
@Londeren
Londeren / js-array-practice.js
Last active April 27, 2022 11:37
Javascript array map, reduce practice
// 1. Implement `reduce` via forEach. Expected api for the function:
reduce(arr, (acc, item) => acc + item, 0);
// example of implementation:
function reduce(arr, reducerCallback, initialValue) {
let result;
……forEach(…)
return result;
}
@Londeren
Londeren / ffmpeg commands
Last active April 17, 2022 14:50
ffmpeg useful commands
for filename in *.mp4; do ffmpeg -ss 12 -i "$filename" -c copy out-"$filename";done; # trim first 12 seconds
for filename in *.mp4; do printf "file '%s'\n" "$filename" >> ffmpeg_concat.txt;done;ffmpeg -f concat -i ffmpeg_concat.txt -c copy output-result.mp4; rm ffmpeg_concat.txt # concat ffmpeg
for filename in *.mp4; do ffmpeg -i "$filename" 2>&1 | grep Duration | awk '{print $2}' | tr -d , >> ffmpeg_concat.txt;done; # video duration time
ffmpeg -i video.mp4 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - > out.gif # video to gif
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a copy video-out.mp4 #optimize reduce size
const times = {
'Video 0': '00:39:13',
'Video 1': '00:29:03',
'Video 2': '00:24:02',
'Video 3': '00:31:55',
'Video 4': '00:32:26',
'Video 5': '00:42:29',
'Video 6': '00:49:11',
};
@Londeren
Londeren / antonyms.txt
Last active December 8, 2021 17:31
Synonyms/antonyms for functions and variables
bind → unbind
on → off
link → unlink
attach → detach
add → remove delete
start → stop finish
begin → end
init → destroy
set → unset
delegate → undelegate
function IS_PASSED(arRange, currentDay, immunityCount) {
const IMMUNITY_SCORE = 1;
const NO_REPORT_SCORE = 0;
const range = arRange[0];
var immunities = immunityCount;
for (var day = 0; day < currentDay; day++) {
var score = Number(range[day]);