This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getCaretPosition (ctrl) { | |
var caretPos = 0; | |
// IE | |
if (document.selection) { | |
ctrl.focus (); | |
var sel = document.selection.createRange(); | |
sel.moveStart ('character', -ctrl.value.length); | |
caretPos = sel.text.length; | |
} | |
// Firefox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the quickest way - by the bug :-) | |
var IE = !+"\v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JS OVERRIDES | |
*/ | |
(function (window) { | |
'use strict'; | |
String.prototype.trim = function (str) {return this.ltrim(str).rtrim(str); }; | |
String.prototype.ltrim = function (str) { return this.replace(new RegExp('^' + (str ? str : '\\s') + '+'), ''); }; | |
String.prototype.rtrim = function (str) { return this.replace(new RegExp((str ? str : '\\s') + '+$'), ''); }; | |
String.prototype.ucfirst = function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(2500).toLocaleString("en-GB", {style: "currency", currency: "GBP", minimumFractionDigits: 2}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Download YouTube Videos as MP4 | |
// @description Adds a button that lets you download YouTube videos. | |
// @homepageURL https://github.com/gantt/downloadyoutube | |
// @author Gantt | |
// @version 1.8.8 | |
// @date 2016-09-02 | |
// @namespace http://googlesystem.blogspot.com | |
// @include http://www.youtube.com/* | |
// @include https://www.youtube.com/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<link rel="stylesheet" href="css/style.css"> | |
<style> | |
html { height: 100%; } | |
body { | |
font-family: sans-serif; | |
font-weight: 300; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset=UTF-8> | |
<title>Dialog demo</title> | |
<style> | |
.dialog { | |
border: none; | |
border-radius: 3px; | |
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* https://gist.github.com/tborychowski/3799025 | |
*/ | |
var UTILS = { | |
/*jshint maxlen: 500, onevar: false */ | |
isTouch : (/iPhone|iPod|iPad/ig).test(navigator.userAgent), | |
/** | |
* Modified & lintified version of https://gist.github.com/527683 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.fuzzy = function (s) { | |
var hay = this.toLowerCase(), i = 0, n = -1, l; | |
s = s.toLowerCase(); | |
for (; l = s[i++] ;) if (!~(n = hay.indexOf(l, n + 1))) return false; | |
return true; | |
}; | |
('a haystack with a needle').fuzzy('hay sucks'); // false | |
('a haystack with a needle').fuzzy('sack hand'); // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.clear(); | |
var img = new Image(); | |
img.src = 'img/img.png'; | |
img.onload = function () { | |
var canvas = document.createElement('canvas'), context = canvas.getContext('2d'); | |
canvas.width = img.width; | |
canvas.height = img.height; | |
context.drawImage(img, 0, 0, img.width, img.height); | |
console.log(canvas.toDataURL('image/png')); |