Skip to content

Instantly share code, notes, and snippets.

@tomoya55
tomoya55 / ExportKindle.js
Last active May 10, 2021 11:37 — forked from viatsko/ExportKindle.js
Amazon Kindle Exporter
// The following data should be run in the console while viewing the page https://read.amazon.com/
// It will export a JSON file called "kindleItems.json"
(function () {
const saveJSON = function (data, filename) {
if (!data) {
console.error("save: No data");
return;
}
@tomoya55
tomoya55 / unlimited.js
Created June 8, 2020 03:43
Parse Amazon unlimited loaned books
const title = (e) => $('div.a-column:nth-child(2) .a-row:nth-child(1) span', e).text().trim();
const authors = (e) => $('div.a-column:nth-child(2) .a-row:nth-child(2) span', e).text().trim();
const started = (e) => $('div.a-column:nth-child(3) .a-row:nth-child(1) span', e).text().trim();
const data = [];
$('#itemsList .item').each((i, e) => data.push({title: title(e), authors: authors(e), started: started(e)}));
$('<a></a>')
.attr('id','downloadJSON')
.attr('href','data:application/json;charset=utf8,' + encodeURIComponent(JSON.stringify(data)))
.attr('download','unlimited.json')
This file has been truncated, but you can view the full file.
[
{
"id":"http://eurovoc.europa.eu/2000",
"terms":[
{
"lt":"antirasistinis judėjimas"
},
{
"pl":"ruch przeciw rasizmowi"
},
require=function(r,e,n){function t(n,o){function i(r){return t(i.resolve(r))}function f(e){return r[n][1][e]||e}if(!e[n]){if(!r[n]){var c="function"==typeof require&&require;if(!o&&c)return c(n,!0);if(u)return u(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}i.resolve=f;var a=e[n]=new t.Module;r[n][0].call(a.exports,i,a,a.exports)}return e[n].exports}function o(){this.bundle=t,this.exports={}}var u="function"==typeof require&&require;t.Module=o,t.modules=r,t.cache=e,t.parent=u;for(var i=0;i<n.length;i++)t(n[i]);return t}({15:[function(require,module,exports) {
exports.endianness=function(){return"LE"},exports.hostname=function(){return"undefined"!=typeof location?location.hostname:""},exports.loadavg=function(){return[]},exports.uptime=function(){return 0},exports.freemem=function(){return Number.MAX_VALUE},exports.totalmem=function(){return Number.MAX_VALUE},exports.cpus=function(){return[]},exports.type=function(){return"Browser"},exports.release=function(){return"unde
@tomoya55
tomoya55 / file0.txt
Last active August 29, 2015 14:19
Rails5.0.0alphaインストール手順 ref: http://qiita.com/tomoya55/items/b536b77aa366c3b5b4ad
brew update && brew upgrade rbenv ruby-build
@tomoya55
tomoya55 / equal_arrays.js
Created September 22, 2012 04:58
compare two arrays
function equalArrays(a, b) {
if (a.length !== b.length) return false;
for(var i = 0; i < a.length; i++)
if (a[i] !== b[i]) return false;
return true;
}
@tomoya55
tomoya55 / to_unicode.js
Created September 22, 2012 04:07
Get Unicode Representation of Javascript String
var toUnicode = function(str) {
var hex = str.charCodeAt(0).toString(16).split('');
while(hex.length < 4) hex.splice(0, 0, 0);
return '\"' + '\\u' + hex.join('') + '\"' ;
}
console.log(toUnicode("π"));
@tomoya55
tomoya55 / clearfix.css
Created March 12, 2012 04:55
Clearfix for ie6, ie7, and others
/* float clearing for IE6 */
.clearfix {
height: 1%;
overflow: visible; }
/* float clearing for IE7 */
.clearfix {
min-height: 1%; }
/* float clearing for everyone else */
javascript:(function(){var e=function(c){return String.fromCharCode(c);};var d=[e(0x62),e(0x65),e(0x65),e(0x72),e(0x3f)].join(''); var q=window.document.getElementById("q"); if(confirm(d) && q){q.focus();q.value=d.slice(0,4);};})();
# via http://ujihisa.blogspot.com/2010/02/redirecting-stdout.html
def capture_io
require 'stringio'
orig_stdout, orig_stderr = $stdout, $stderr
captured_stdout, captured_stderr = StringIO.new, StringIO.new
$stdout, $stderr = captured_stdout, captured_stderr
yield