Skip to content

Instantly share code, notes, and snippets.

View AnatoliyLitinskiy's full-sized avatar

Anatoliy Litinskiy AnatoliyLitinskiy

View GitHub Profile
@AnatoliyLitinskiy
AnatoliyLitinskiy / git-add-gr.md
Last active August 29, 2015 14:26
show git tree
Add to ~/.bashrc file alias gr show tree without dates
echo 'alias gr="git log --graph --full-history --all --color --pretty=tformat:\"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m;\""' >> ~/.bashrc
add to ~/.bashrc file alias grd show tree with dates
echo 'alias grd="git log --graph --full-history --all --color --pretty=tformat:\"%x1b[31m%h%x09%x1b[36m%ad%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m;\" --date=iso"' >> ~/.bashrc
@AnatoliyLitinskiy
AnatoliyLitinskiy / i18n-Sublime-snippet.md
Last active August 29, 2015 14:27
Sublime snippet 'i18n' [xml], [python], [js]

i18n Sublime snippet

<snippet>
  <content><![CDATA[
<?php echo __( '${1:${SELECTION/'/\\'/g}}' ) ?>
]]></content>
  <tabTrigger>i18n</tabTrigger>
</snippet>
@AnatoliyLitinskiy
AnatoliyLitinskiy / bounds.js
Last active August 29, 2015 14:27 — forked from mapsense-examples/bounds.js
Drag & drop geojson to map
// Hat tip Mike Bostock: https://github.com/mbostock/polymaps/blob/master/examples/bounds/bounds.js
function bounds(features) {
var i = -1,
n = features.length,
geometry,
bounds = [{lon: Infinity, lat: Infinity}, {lon: -Infinity, lat: -Infinity}];
while (++i < n) {
//geometry = features[i].data.geometry;
geometry = features[i].geometry;
@AnatoliyLitinskiy
AnatoliyLitinskiy / tabsData.js
Created October 7, 2015 12:19
Don't allow open several tabs
angular.module('myMod').factory('tabsData', function (localStorageService) {
var Factory = {},
keyReg = /^tab-(\d+-\d+)$/;
/**
* get all tabs data
* @return array
**/
Factory.all = function () {
var keys = localStorageService.keys(),
ret = [];
@AnatoliyLitinskiy
AnatoliyLitinskiy / TODO.md
Created April 4, 2016 17:16 — forked from uupaa/TODO.md
TODO
  • TODO
  • TODO
@AnatoliyLitinskiy
AnatoliyLitinskiy / imagedata-to-filename.js
Created September 23, 2016 17:10 — forked from iwek/imagedata-to-filename.js
Convert CANVAS data to binary data and then to a filename using a Blob
function binaryblob(){
var byteString = atob(document.querySelector("canvas").toDataURL().replace(/^data:image\/(png|jpg);base64,/, ""));
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
var dataView = new DataView(ab);
var blob = new Blob([dataView], {type: "image/png"});
var DOMURL = self.URL || self.webkitURL || self;
var newurl = DOMURL.createObjectURL(blob);
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);
@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) => {
@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 / 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,
};