Skip to content

Instantly share code, notes, and snippets.

View ruvasik's full-sized avatar
👁️‍🗨️
I'm looking for job

Vladimir Alekseev ruvasik

👁️‍🗨️
I'm looking for job
View GitHub Profile
@ruvasik
ruvasik / sequential_rename.applescript
Last active December 26, 2016 15:29
Renaming files (jpg) in the folders to sequential numbers order starting with 1 in every folder
set text item delimiters to "."
tell application "Finder"
set the_folder to choose folder
set the_subfolders to every folder in the_folder
repeat with index from 1 to the count of the_subfolders
set this_folder to item index of the_subfolders
set img_files to (every file in this_folder whose name ends with ".jpg")
repeat with indexf from 1 to (the count of img_files)
set this_file to item indexf of img_files
set file_name_count to text items of (get name of this_file)
<?php
if (ini_get('short_open_tag') == 0 && strtoupper(ini_get('short_open_tag')) != 'ON')
die('Error: short_open_tag parameter must be turned on in php.ini');
?><?
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
@ini_set('pcre.backtrack_limit', 1024*1024);
define('IP_LIMIT_DEFAULT', '#IP'.'_LIMIT_PLACEHOLDER#');
define('IP_LIMIT', '#IP_LIMIT_PLACEHOLDER#');
@ruvasik
ruvasik / docker-cleanup-resources.md
Created August 10, 2020 14:13 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ruvasik
ruvasik / radius.css
Last active May 19, 2022 20:51
Mobile devices corners display radius
/* https://css-tricks.com/snippets/css/media-queries-for-standard-devices/ */
/* ----------- iPhone 5, 5S, 5C and 5SE ----------- */
/* Portrait and Landscape */
@media only screen
and (min-device-width: 320px)
and (max-device-width: 568px)
and (-webkit-min-device-pixel-ratio: 2) {
@ruvasik
ruvasik / imagesDataUri.ts
Created October 11, 2022 19:53
JS image to/from data URI
import fs from "fs";
export const imageToDataUri = (image: string | Buffer): string | undefined => {
const extTypeMap = {
'png': 'image/png',
'jpg': 'image/jpeg',
'jpeg': 'image/jpeg',
'webp': 'image/webp'
};
@ruvasik
ruvasik / tool.js
Created January 13, 2023 07:59
NPM utility for run check/format code in folder with eslint/prettier
const execSync = require("child_process").execSync;
const fs = require("fs");
const path = process.argv[3] || 'src/';
const args = Array.prototype.slice.call( process.argv, 4 ).join(' ');
if (!fs.existsSync(path))
throw new Error(`Not found ${path}`);
switch (process.argv[2]) {
@ruvasik
ruvasik / useOnClickOutside.ts
Created January 17, 2023 14:26
React typed hook useOnClickOutside
import React from "react";
export default function useOnClickOutside(
ref: React.RefObject<HTMLElement>,
handler: (event: TouchEvent | MouseEvent) => void
) {
React.useEffect(() => {
const listener = (event: TouchEvent | MouseEvent) => {
if (!ref.current || ref.current.contains(event.target as HTMLElement)) {
return;
@ruvasik
ruvasik / RegionMap.tsx
Created April 28, 2023 10:49
SC & TS examples
export interface IMapPoint {
x: number;
y: number;
}
export interface IMapPointItem {
title?: string;
point: IMapPoint;
}
export interface IMapLineItem {
@ruvasik
ruvasik / random-fact.sh
Created November 18, 2023 10:45 — forked from jorpic/random-fact.sh
Get random fact from wikipedia
#!/bin/bash -e
API="http://en.wikipedia.org/w/api.php\
?action=query\
&prop=extracts\
&format=json\
&exsentences=2\
&explaintext=\
&exsectionformat=plain\
&rawcontinue=\
&generator=random\
@ruvasik
ruvasik / viewportUnitVariable.tsx
Created December 13, 2023 11:59
Dynamic ViewPort variable in css/sc
import React, {
RefObject,
useCallback,
useEffect,
useRef,
useState,
} from "react";
import { Portal } from "@mui/base";
import { Box } from "@mui/material";