Skip to content

Instantly share code, notes, and snippets.

View frontenddeveloping's full-sized avatar
:octocat:
Code wins arguments

Alexander frontenddeveloping

:octocat:
Code wins arguments
View GitHub Profile
@frontenddeveloping
frontenddeveloping / gitclean.sh
Created February 15, 2016 21:36 — forked from ericelliott/gitclean.sh
gitclean.sh - cleans merged/stale branches from origin
git remote prune origin
git branch -r --merged master | egrep -iv '(master|develop)' | sed 's/origin\///g' | xargs -n 1 git push --delete origin
/**
* Watcher leaks for jQuery
* RubaXa <trash@rubaxa.org>
* MIT Licensed.
*
* API:
* $.leaks.get();
* $.leaks.watch();
* $.leaks.unwatch();
* $.leaks.remove();
@frontenddeveloping
frontenddeveloping / pdfjs-file-parser.js
Created January 18, 2016 16:32
Parse uploaded pdf file by PDF.js for number of pages and count links
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.1/es6-shim.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
@frontenddeveloping
frontenddeveloping / sw-example.js
Created January 2, 2016 19:23
Service Worker example
var version = 'v2.0.24:';
var offlineFundamentals = [
'/',
'/offline/'
];
//Add core website files to cache during serviceworker installation
var updateStaticCache = function() {
return caches.open(version + 'fundamentals').then(function(cache) {
@frontenddeveloping
frontenddeveloping / fetch-api-wrapper.js
Created October 14, 2015 09:26
Simple fetch API wrapper
(function(global) {
'use strict';
var JSON_TYPE_NAME = 'type';
function getQueryString(queryParams) {
var params = Object.keys(queryParams).map(function(paramName) {
return [paramName, encodeURIComponent(queryParams[paramName])].join('=');
});
return '?' + params.join('&');
@frontenddeveloping
frontenddeveloping / async-javascript-loading.js
Last active August 29, 2015 14:07
Async javascript loading (with saving order).
/*
The main feature is script.async = false.
The async IDL attribute controls whether the element will execute asynchronously or not.
So if you will set async to false, scripts will load without blocking user i/o, but scripts will execute synchronously.
Support:
FF 4+
FF for Android All Versions
IE 10+ (starting with preview 2)
Chrome 12+
Chrome For Android All versions
@frontenddeveloping
frontenddeveloping / dataUri2Blob.js
Created June 20, 2014 06:46
Conversion dataUri string to Blob
function dataUri2Blob (dataUri) {
var dataUriArr = dataUri.split(';base64,'),
imageType = dataUriArr[0].replace('data:', ''),
base64Str = dataUriArr[1],
BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MSBlobBuilder || window.MozBlobBuilder,
binaryString = window.atob(base64Str),
bytes,
arrayBuffer,
blob;
@frontenddeveloping
frontenddeveloping / index.html
Created May 29, 2014 06:23
FileReader.prototype.readAsArrayBuffer vs FileReader.prototype.readAsDataUrl
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FileReader test</title>
</head>
<body>
<form action="">
<input type=file multiple accept="image/*"><br/>
<input type=submit value="Run test">
@frontenddeveloping
frontenddeveloping / array mergeAsNumber
Last active August 29, 2015 13:57
Array.prototype.mergeAsNumber example
Array.prototype.mergeAsNumber = function (array) {
var sortFunction = function (a,b) {return a-b},
commonArray = this.concat(array).sort(sortFunction),
element,
suchNumberAnotherIndex;
for (var i = 0, l = commonArray.length; i<l; i++) {
element = commonArray[i];
suchNumberAnotherIndex = commonArray.indexOf(element, i+1);
while (suchNumberAnotherIndex > -1) {
@frontenddeveloping
frontenddeveloping / javascript-tabs.html
Last active February 13, 2018 21:08
My example can open many links in tabs, not in new windows. Why need this and do not use window.open? Because there is the problem - if you call once window.open it will open new tab or window(it depends of browser), if will call window.open two or more times - first will open like tab/window and all next in the new window only. The individual b…
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Open 3 tabs</title>
<script src="http://codeorigin.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<div id="hidden_div"></div>
<script>