Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Code wins arguments

Alexander frontenddeveloping

:octocat:
Code wins arguments
View GitHub Profile
@frontenddeveloping
frontenddeveloping / gitclean.sh
Created Feb 15, 2016 — forked from ericelliott/gitclean.sh
gitclean.sh - cleans merged/stale branches from origin
View gitclean.sh
git remote prune origin
git branch -r --merged master | egrep -iv '(master|develop)' | sed 's/origin\///g' | xargs -n 1 git push --delete origin
View jquery.leaks.js
/**
* 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 Jan 18, 2016
Parse uploaded pdf file by PDF.js for number of pages and count links
View pdfjs-file-parser.js
<!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>
View sw-example.js
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) {
View fetch-api-wrapper.js
(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 Aug 29, 2015
Async javascript loading (with saving order).
View async-javascript-loading.js
/*
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 Jun 20, 2014
Conversion dataUri string to Blob
View dataUri2Blob.js
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
FileReader.prototype.readAsArrayBuffer vs FileReader.prototype.readAsDataUrl
View index.html
<!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 Aug 29, 2015
Array.prototype.mergeAsNumber example
View array mergeAsNumber
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 Feb 13, 2018
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…
View javascript-tabs.html
<!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>