Create Bookmarklet (browser bookmark that executes Javsacript) to copy a given text to Clipboard.
This is the base javascript:
(function (text) {
var node = document.createElement('textarea')
var selection = document.getSelection()| //variant of https://gist.github.com/Contra/6368485 | |
| (function () { | |
| var isStorageAvailable = function (storage) { | |
| if (typeof storage == 'undefined') return false; | |
| try { // hack for safari incognito | |
| storage.setItem("storage", ""); | |
| storage.getItem("storage"); | |
| storage.removeItem("storage"); |
| // ==UserScript== | |
| // @name KindleKeywordsExporter | |
| // @namespace https://kindle.amazon.com/your_highlights | |
| // @version 0.0.8 | |
| // @downloadURL https://gist.github.com/raw/65e198dcda8784c557075b9b89265a16/kindle.user.js | |
| // @updateURL https://gist.github.com/raw/65e198dcda8784c557075b9b89265a16/kindle.meta.js | |
| // @description Helps exporting highlighted keywords from Kindle | |
| // @include https://kindle.amazon.com/your_highlights | |
| // @match https://kindle.amazon.com/your_highlights | |
| // @grant GM_setValue |
| import c3 from 'c3'; | |
| export function charts() { | |
| const errorChart = c3.generate({ | |
| bindto: '.js-chart', | |
| data: { | |
| x: 'date', | |
| y: 'errors', | |
| url: './data/dummydata.json', |
| ! Title: Disqus click-to-load | |
| # Copy-paste the static filters below into your "My filters" pane in the | |
| # dashboard. | |
| # Purpose is to load Disqus comments on demand only, so that no connection | |
| # to `disqus.com` occurs by default when you land on a site which uses | |
| # Disqus comments widget. | |
| # Not connecting to Disqus by default is a good thing for such a | |
| # ubiquitous server as `disqus.com`, which can be used to build a |
Source: http://ie2.php.net/manual/en/function.fgets.php#113113
Regarding Leigh Purdie's comment (from 4 years ago) about stream_get_line being better for large files, I decided to test this in case it was optimized since then and I found out that Leigh's comment is just completely incorrect
fgets actually has a small amount of better performance, but the test Leigh did was not set up to produce good results.
The suggested test was:
| /** | |
| * Check if element is in viewport | |
| * @param {Node} el | |
| * @return {Object} | |
| */ | |
| export function elementInViewport(el) { | |
| let top = el.offsetTop; | |
| let left = el.offsetLeft; | |
| let width = el.offsetWidth; | |
| let height = el.offsetHeight; |
| For | |
| * ES5 | |
| * ES6 | |
| * CoffeeScript |
| /* | |
| * @fileoverview Program to free the content in kindle books as plain HTML. | |
| * | |
| * This is largely based on reverse engineering kindle cloud app | |
| * (https://read.amazon.com) to read book data from webSQL. | |
| * | |
| * Access to kindle library is required to download this book. | |
| */ | |
| // The Kindle Compression Module copied from http://read.amazon.com application |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <script> | |
| // Test if service workers are supported | |
| if ('serviceWorker' in navigator) { |