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
#!/bin/bash | |
#URL="https://itunes.apple.com/us/podcast/surprisingly-awesome/id1053898" | |
isValidURLRegex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]' | |
if [[ $1 =~ $isValidURLRegex ]] | |
then | |
# extract id from url | |
ID=$(echo $1 | grep -oP 'id\d+' | grep -oP '\d+') | |
else | |
ID=$1 |
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
var saveSelection, restoreSelection; | |
if (window.getSelection && document.createRange) { | |
saveSelection = function(containerEl) { | |
var range = window.getSelection().getRangeAt(0); | |
var preSelectionRange = range.cloneRange(); | |
preSelectionRange.selectNodeContents(containerEl); | |
preSelectionRange.setEnd(range.startContainer, range.startOffset); | |
var start = preSelectionRange.toString().length; |
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 calculateStringFitness(str0,str1,opt){ | |
function countMatches(a0, a1){ | |
var matches, pos0, pos1, matchObj; | |
matches = pos0 = pos1 = 0; | |
matchObj = {}; | |
a0 = a0.sort(); | |
a1 = a1.sort(); |
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
// writen but untested | |
function HashTable(obj){ | |
this.length = 0; | |
this.items = { }; | |
for(var p in obj){ | |
if(obj.hasOwnProperty(p)){ | |
this.items[p] = obj[p]; | |
this.length++; |
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
#!/bin/bash | |
if command -v chrome 1>/dev/null; then | |
chromeUrlList=( | |
"https://google.com" | |
"https://gmail.com" | |
) | |
# create subShell | |
( chrome ${chromeUrlList[*]} &>/dev/null 2>/dev/null & ) | |
fi |
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
# onCD | |
# ----- | |
# Place the code below in your .bashrc file. | |
# then place a script in any directory, named 'oncd.sh' | |
# the script will receive an argument of 'enter' or 'leave' | |
# when cd'ing into or out of the directory. | |
#(doesn't work with "shopt -s autocd", use COMMAND_PROMPT for that) | |
cd () { | |
oldpath=$PWD |
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 (root, factory) { | |
if (typeof define === "function" && define.amd) define(factory); // amd | |
else if(typeof module == 'object') module.exports = factory(); // node require | |
else if(typeof exports == 'object') exports = factory(); // browserify | |
else root.ResizeSensor = factory(); // root/window | |
})(this, function () { | |
// code here | |
// return foo; | |
}) |
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
var gradientCircle = function(x,y,r,innerColor,outerColor){ | |
this.beginPath(); | |
this.arc(x,y,r,0*Math.PI,2*Math.PI); | |
var grd = this.createRadialGradient(x, y, 0, x, y, r); | |
grd.addColorStop(0,innerColor); | |
grd.addColorStop(1,outerColor); | |
this.fillStyle = grd; | |
this.fill(); | |
this.closePath(); | |
}.bind(this.ctx); |
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
// match everything within style tags | |
(?<=(<style[^>]*>))([^]+?)(?=(<\/style>)) |
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
Summary: | |
-------- | |
add: unshift -> array <- push | |
remove: shift <- array -> pop | |
Chart: | |
------ | |
add remove start end | |
push X X | |
pop X X |
NewerOlder