Skip to content

Instantly share code, notes, and snippets.

View AnatoliyLitinskiy's full-sized avatar

Anatoliy Litinskiy AnatoliyLitinskiy

View GitHub Profile
@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);
@AnatoliyLitinskiy
AnatoliyLitinskiy / TODO.md
Created April 4, 2016 17:16 — forked from uupaa/TODO.md
TODO
  • TODO
  • TODO
@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 / 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 / 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 / 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