Skip to content

Instantly share code, notes, and snippets.

View anton-chernianu's full-sized avatar
🚀
frontend

Anton anton-chernianu

🚀
frontend
View GitHub Profile
@anton-chernianu
anton-chernianu / clearInterval setInterval example
Last active March 14, 2018 15:10
clearInterval setInterval example
setTimeout(function(){
var count = 0;
var interval = setInterval(function() {
count++;
// Code
if(count >= 100) {
clearInterval(interval);
var userBlock = document.querySelectorAll('.user-row');
for(var i=0; i<=userBlock.length; i++){
var numFollowers = userBlock[i].querySelector('.num-followers').textContent;
var numFollowing = userBlock[i].querySelector('.following strong').textContent;
var followButtom = userBlock[i].querySelector('.is-not-following');
numFollowers = parseInt(numFollowers);
numFollowing = parseInt(numFollowing);
if(numFollowers<numFollowing) {
if(followButtom) {
@anton-chernianu
anton-chernianu / gist:e6e25ccc07de33eef19ad88a7adfd926
Created March 22, 2018 14:20
Javascript Check Mouse Position
window.onmousemove = logMouseMove;
function logMouseMove(event) {
let e = event || window.event;
mousePos = { x: e.clientX, y: e.clientY };
console.log(mousePos);
}
@anton-chernianu
anton-chernianu / gist:67b96b87f14337c2a4d2ff33e87deb3c
Last active August 1, 2018 07:59
DAY, MONTH, YEAR Array for Select
export default {
daysNum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],
daysString: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"],
monthRU: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
monthEng: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
yearNum: [1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 196
@anton-chernianu
anton-chernianu / javascript
Created August 16, 2018 09:53
REGEX - Range of digits / date 1900-2018
regex: [/^(190[0-9]|19[1-9][0-9]|200[0-9]|201[0-8])+$/i]
@anton-chernianu
anton-chernianu / media-query.css
Created September 2, 2018 19:47 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@anton-chernianu
anton-chernianu / 0_selector_hacks.scss
Created September 11, 2018 12:49 — forked from chriseppstein/0_selector_hacks.scss
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@anton-chernianu
anton-chernianu / base.scss
Last active September 11, 2018 13:06
SCSS media mixin
#sidebar {
float: left;
width: 300px;
@include respond-to(tablet-p) { float: none; }
@include respond-to(tablet-l) { float: none; }
@include respond-to(mobile-p) { width: 240px; }
}
const vw = (coef) => window.innerWidth * (coef/100);
const vh = (coef) => window.innerHeight * (coef/100);
@anton-chernianu
anton-chernianu / index.js
Last active December 13, 2019 15:03
JavaScript: Regex matching links without <a> and replace
function addTagToLinks(str) {
const httpRegex = "((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)"
+ "\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_"
+ "\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?"
+ "((?:(?:[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}\\.)+" // named host
+ "(?:" // plus top level domain
+ "(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
+ "|(?:biz|b[abdefghijmnorstvwyz])"
+ "|(?:cat|com|coop|c[acdfghiklmnoruvxyz])"