Skip to content

Instantly share code, notes, and snippets.

View mir4a's full-sized avatar
🤞

Myroslav mir4a

🤞
View GitHub Profile
@mir4a
mir4a / vk.js
Last active December 7, 2019 14:40
Quickly remove all friend from VK
// Run from console on developers tools (chrome dev tools)
// Go to friends page from your profile and open console F12 or alt+cmd+I
// Get all links from action section, this will fetch links for remove from friends and other too.
// FIXME: add filter to show only remove from friends links
var l = document.querySelectorAll('.friends_act');
// Function link takes list of links (dom elements) as argument and iterate through each of them and set them style properties
// in my case position: fixed; top: 20px; right: 40px;
@mir4a
mir4a / resize-photo.sh
Last active July 2, 2019 09:55
Resize all image files in particular directory and put them in separate directory
#!/bin/sh
while [ "$#" -gt 0 ]; do
case "$1" in
-w) width="$2"; shift 2;;
-h) height="$2"; shift 2;;
-p) filepath="$2"; shift 2;;
-m) mask="$2"; shift 2;;
--width=*) width="${1#*=}"; shift 1;;
#!/bin/sh
while [ "$#" -gt 0 ]; do
case "$1" in
-s) substr="$2"; shift 2;;
-r) replace="$2"; shift 2;;
-p) filepath="$2"; shift 2;;
--substr=*) substr="${1#*=}"; shift 1;;
--replace=*) replace="${1#*=}"; shift 1;;
@mir4a
mir4a / svg-polygon-normalizer.js
Created April 8, 2016 11:54
Normalize svg polygon coordinates relative to viewBox
// For example, if you need to "normalize" viewBox minX, minY to 0,
// like this: was viewBox="-270 265 18 32", became viewBox="0 0 18 32"
// in this case polygon points should be converted into relative to viewBox values
// <polygon points="-268.6,265.8 -268.6,270.8 -258.4,281 -268.6,291.2 -268.6,296.2 -253.4,281" />
// This function will convert those point, it accepts two 3 params: points string, minX and minY
// Use example:
// var normalizedPlygon = svgPolygonNormalizer("-268.6,265.8 -268.6,270.8 -258.4,281 -268.6,291.2 -268.6,296.2 -253.4,281", -270, 265);
// console.log(normalizedPlygon);
// > '1.40,0.80 1.40,5.80 11.60,16.00 1.40,26.20 1.40,31.20 16.60,16.00'
const fs = require('fs');
const path = require('path');
function printToHTMLColorMap() {
const header = `
<!doctype html>
<html>
<head>
<title>16 lime colors</title>
@mir4a
mir4a / getAllColors.js
Created March 24, 2016 13:09
get colors (hex, rgb, rgba) from predefined directory. Work on Node 5.9
const fs = require('fs');
const path = require('path');
const dirToParse = 'app/assets/stylesheets/nv';
const skipFile = 'app/assets/stylesheets/nv/shared/colors.scss'
const colorRegexp = /(#[A-Z\d]{3}\b|#[A-Z\d]{6}\b)|(rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?([, \.\d]+)?\))/gi;
const variableMap = new Map();
const process = require('process');
const args = processArguments(process.argv);
var colorMap = new Map();
var fileCounter = 0;
@mir4a
mir4a / check_ie.js
Last active March 20, 2016 21:09
Check IE version
//<editor-fold desc="Проверка версии IE">
function getInternetExplorerVersion()
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
@mir4a
mir4a / FRSHBKS.js
Created February 4, 2016 17:15
Simple bookmarklet which is prints to console list of tasks was done from Freshbooks report (Time Sheets Detailed).
javascript:
var fr_pat = /#gh-(\S+): /g;
var fr_str = '';
$('.report tr').each(function(i,el) {
$td = $(el).find('.text_wrap').eq(3);fr_str += $td.text().replace(fr_pat, '- ') + '\n';
});
console.log(fr_str);
@mir4a
mir4a / export_groups_to_png.js
Last active February 1, 2016 17:48
Action for exporting every group items under first level of parent layer named icons. Tested on Adobe Illustrator CS5
// reference http://graphicdesign.stackexchange.com/a/26044/18833
function exportFileToPNG(dest, artBoardIndex)
{
var exportOptions = new ExportOptionsPNG24(); // or ExportOptionsPNG24
var type = ExportType.PNG24; // or ExportType.PNG24
var file = new File(dest + ".png");
exportOptions.artBoardClipping = true;
exportOptions.antiAliasing = true;
#search for bg images at stylesheets
url\(\/assets\/([a-z \/ \. _]+)\)
#replace it with image-url rails function
image-url('$1')