Skip to content

Instantly share code, notes, and snippets.

View AnatoliyLitinskiy's full-sized avatar

Anatoliy Litinskiy AnatoliyLitinskiy

View GitHub Profile
@AnatoliyLitinskiy
AnatoliyLitinskiy / monokai.md
Last active May 9, 2023 18:01 — forked from r-malon/monokai.md
Monokai colors in RGB and HEX format, taken from Sublime Text 3

Monokai (My modification) Colors in RGB and HEX format

#272822#679D47#F8F8F2#E6DB74#A6E22E#FD971F#9e86c8#b05279#66D9EF

  • Background: (39, 40, 34); #272822 #272822
  • Comments: (103,157,71); #679D47 #679D47
  • White: (248, 248, 242); #F8F8F2 #F8F8F2
  • String: (230, 219, 116); #E6DB74 #E6DB74
  • Green:(166, 226, 46); #A6E22E ![#A6E22E](https://placehold.co/15x15/A6E
@AnatoliyLitinskiy
AnatoliyLitinskiy / readme.md
Created September 25, 2018 15:02
javascript proxy server

Here is a quick and dirty workaround if you need to run your dev app on domains other than localhost :

  1. Install concurrently and http-proxy
yarn add concurrently http-proxy || npm install --save-dev concurrently http-proxy
  1. Add proxy-server.js
var http = require('http');
var httpProxy = require('http-proxy');
class TestYield
{
private function clearDir() {
if (!is_dir('./files')) {
return;
}
if ($handle = opendir('./files')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
// echo "$entry\n";
@AnatoliyLitinskiy
AnatoliyLitinskiy / Base__BaseControllerTests.php
Created September 20, 2018 12:51
symfony 2.4 test controllers
<?php
namespace Evolutionnutrition\ApiBundle\Tests\Base;
use Evolutionnutrition\ApiBundle\Tests\Base\BaseUnitTests;
abstract class BaseControllerTests extends BaseUnitTests
{
protected $controllerMethodsList = [
'parseControls',
(function() {
const links = document.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
const a = links.item(i);
if (a.href && a.href.search('screencast.com') >= 0) {
console.log('screencast link', i, a);
let ifrFound = false;
for (let j = 0; j < a.childNodes.length; j++) {
if (a.childNodes.item(j).nodeName === 'IFRAME') {
ifrFound = true;
function getCaretPosition (value) {
// Initialize
let iCaretPos = 0;
const field = document.activeElement;
// IE Support
if (document.selection) {
// To get cursor position, get empty selection range
@AnatoliyLitinskiy
AnatoliyLitinskiy / FormattedDateField.jsx
Created July 5, 2018 07:49
react input format + avoid caret jumping
import React from 'react';
import PropTypes from 'prop-types';
import { parseDate, formatInput, formatDate } from './helpers';
class FormattedDateField extends React.PureComponent {
static propTypes = {
date: PropTypes.instanceOf(Date),
onChange: PropTypes.func.isRequired,
};
@AnatoliyLitinskiy
AnatoliyLitinskiy / css-hierarchical-counter.css
Created June 21, 2018 16:31
custome css hierarchical counter with different list-style-type
/*
.ol-level-1 > .li-level-1 > .ol-level-2 > .li-level-2, .li-level-2_alpha counters
*/
.ol-level-1, .ol-level-2 {
list-style-type: none;
counter-reset: terms-counter-y 0;
}
.li-level-1, .li-level-2 {
counter-increment: terms-counter-y 1;
}
@AnatoliyLitinskiy
AnatoliyLitinskiy / rmDir.js
Created March 30, 2018 10:23
remove / clean out directory using node.js fs
const fs = require('fs');
const path = require('path');
const async = require('async');
function rmDir(dirPath, cb, removeSelf = true) {
try {
fs.readdir(dirPath, (err, files) => {
if (err) return cb(err);
// run tasks in parallel
async.each(files, (file, cb) => {
const allowEvery = (f, delay = 300) => {
let timeOut = null;
let lastCall = null;
return (...args) => {
const n = Date.now();
if (lastCall === null) {
lastCall = n;
} else if (n - lastCall > delay) {
lastCall = n;
f(...args);