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
const fs = require('fs'), | |
data = fs.readFileSync('pinboard.json', { encoding: 'utf8', flag: 'r' }), | |
bookmarks = JSON.parse(data); | |
const dir = 'pinboard'; | |
if (fs.existsSync(dir)) | |
fs.rmSync(dir, { recursive: true, force: true }); | |
if (!fs.existsSync(dir)) | |
fs.mkdirSync(dir); |
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 copyText (text) { | |
const element = document.createElement('textarea'); | |
element.value = text; | |
document.body.appendChild(element); | |
element.focus(); | |
element.setSelectionRange(0, element.value.length); | |
document.execCommand('copy'); | |
document.body.removeChild(element); | |
} |
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
document.addEventListener('paste', function (event) { | |
var clip = event.clipboardData.getData('text/plain'); | |
var urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; | |
var urlq = clip.match(urlRegex); | |
if (urlq != null) { | |
event.preventDefault(); | |
var anchored = clip.replace(urlRegex, function(url) { | |
return '<a href="' + url + | |
'" style="cursor:pointer" onclick="window.open(this.href);return false">' + | |
url + '</a>'; |
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
<div contenteditable>http://google.com</div> | |
<script> | |
document.onkeydown = function(evt) { | |
evt = evt || window.event; | |
if (evt.keyCode == 13) { // enter key | |
var text = document.querySelector('div').innerHTML; | |
var url = text.match(/(HTTP:\/\/)([a-zA-Z0-9.\/&?_=!*,\(\)+-]+)/i); | |
var foourl = url[0].replace("http", "foo"); | |
document.foo = "foo"; | |
document.http = "http"; |
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
<script type="text/javascript"> | |
function setTime() { | |
var timeOut = false; | |
var currentDate = new Date(); | |
var seconds = currentDate.getSeconds(); | |
var minutes = currentDate.getMinutes() * 60; | |
var hours = currentDate.getHours() * 3600; | |
var myriaseconds = seconds + minutes + hours; | |
var mt = myriaseconds/10000; | |
document.body.innerHTML = mt.toPrecision(5); |
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
document.addEventListener("mousemove", function(event) { | |
mouseX = event.pageX; | |
mouseY = event.pageY; | |
document.body.innerHTML = mouseX + " " + mouseY; | |
}, false); |
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
document.onkeydown = function(evt) { | |
evt = evt || window.event; | |
if (evt.keyCode == 13 && evt.ctrlKey) { | |
evt.preventDefault(); | |
alert('it works!'); | |
} | |
}; |
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
<html> | |
<head> | |
<link href="https://dl.dropboxusercontent.com/u/7984474/GitHub/sand/favicon.ico" rel="Shortcut Icon" /> | |
<meta charset="UTF-8"> | |
<title>sand v5 (ace)</title> | |
<script> | |
var editboxHTML = | |
'<script src="https://dl.dropboxusercontent.com/u/7984474/GitHub/sand/hotkeys.js"><\/script>' + | |
'<script>' + | |
' shortcut.add("Ctrl+Shift+X",function() { window.setCookie(); });' + |
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
<script> | |
document.onkeydown = function(evt) { | |
evt = evt || window.event; | |
if (evt.ctrlKey && evt.keyCode == 13) { | |
evt.preventDefault(); | |
pasteHtmlAtCaret('<li style="margin-left: 15px;"> </li>'); | |
} | |
if (evt.altKey && evt.keyCode == 13) { | |
evt.preventDefault(); | |
pasteHtmlAtCaret('<li style="margin-left: -15px;"> </li>'); |
NewerOlder