Skip to content

Instantly share code, notes, and snippets.

@megabayt
megabayt / exposePorts.ps1
Created June 11, 2024 13:03
expose ports wsl
$ports = @(22004, 3000, 3001, 3002, 3003, 8081);
$wslAddress = bash.exe -c "ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'";
if ($wslAddress -match '^(\d{1,3}\.){3}\d{1,3}$') {
Write-Host "WSL IP address: $wslAddress" -ForegroundColor Green;
Write-Host "Ports: $ports" -ForegroundColor Green;
}
else {
Write-Host "Error: Could not find WSL IP address." -ForegroundColor Red;
@megabayt
megabayt / matrixToArray.js
Last active April 27, 2022 16:27
May be useful if you need to save empty values
const m = 4;
const n = 3;
const matrix = [
[1, 2],
[3, 4, 5],
[6, 7, 8, 9],
];
const arr = [];
AVURLAsset *textURLAsset;
NSString *textUri = [_textTracks objectAtIndex:i][@"uri"];
if ([[textUri lowercaseString] hasPrefix:@"http"]) {
textURLAsset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:textUri] options:assetOptions];
} else {
textURLAsset = [AVURLAsset URLAssetWithURL:[self urlFilePath:textUri] options:nil];
}
[textURLAsset loadValuesAsynchronouslyForKeys:@[@"playable",@"tracks"] completionHandler:^{
function longestSubseq(s1, s2) {
const s1Arr = s1.split('');
const s2Arr = s2.split('');
let result = [];
while (s1Arr.length) {
const tmpResult = [];
let startIndex = 0;
s1Arr.forEach((s1Char, index) => {
#!/bin/bash
for i in {1..650}
do
if [ $(curl -LI https://virtualland.ru/rg-semenovskiy-park/flats/1-$i -o /dev/null -w '%{http_code}\n' -s) == "200" ]; then
echo "https://virtualland.ru/rg-semenovskiy-park/flats/1-$i";
fi
done
@megabayt
megabayt / temp.php
Created May 23, 2020 09:01
Временная ссылка
// Генерация временной ссылки
$this->say(
"Вот ссылка на файл ".$file->name.":\n".
URL::temporarySignedRoute(
'download',
now()->addMinutes(2),
['file' => $file->id]
).
"Ссылка будет действовать 2 минуты"
);
function search(obj, value, path = '') {
if (!obj) {
return undefined;
}
if (Array.isArray(obj)) {
let found;
obj.some((item, index) => {
found = search(item, value, `${path}[${index}]`);
return found;
});
@megabayt
megabayt / tslint.json
Created May 8, 2019 14:24
Tslint Config
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended",
"tslint-config-standard",
"tslint-config-prettier",
"tslint-config-airbnb",
"tslint-react",
"tslint-immutable"
],
@megabayt
megabayt / cloudSettings
Last active January 9, 2019 12:06
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-01-09T12:05:59.049Z","extensionVersion":"v3.2.4"}
if ($('#header .button-ugps span').hasClass('choose-city')) {
$.ajax({
url: '/index.php?route=ugps/city/get&json=Y',
type: 'GET',
dataType: 'json',
error: function() {
return console.error();
},
success: function(res) {
if (res.name !== void 0) {