Skip to content

Instantly share code, notes, and snippets.

View magikid's full-sized avatar

Chris Jones magikid

View GitHub Profile
@magikid
magikid / download_kindle.js
Created February 17, 2025 16:31 — forked from akagr/download_kindle.js
Download kindle books from Amazon web
/*
I was looking to try a non-kindle e-reader, but my library kept weighing me down. While I had calibre and the de-drm plugin, I found the downloaded books on my kindle were in kfx format and weren't playing well with calibre, even with the kfx input plugin.
Further, I found downloading books directly from web (Amazon > content library) did give me an azw3 file, which works well with de-drm.
To automate part of the process, I wrote a short js script. It doesn't walk through all the pages in content library, but it does download all the books currently visible on the list. Amazon lets us view 25 books per page, so I just had to switch pages, run script, repeat.
The meat of this script is constructing the url used to start a download. Device type, serial number, customer id etc. will be different for everyone, so it's best to download one book manually and check the network inspector for the request details. Apart from the book's `key`, all other details remain same for all the books (at least they did for me
@magikid
magikid / docker-compose.yml
Created April 21, 2022 16:28
Grafana DB Schema for Digital Ocean since not every table has a primary key
version: '3.8'
services:
grafana:
image: grafana/grafana:8.4.5-ubuntu
environment:
- GF_DEFAULT_INSTANCE_NAME=grafana.hilandchris.com
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_DATABASE_URL=mysql://grafana:grafana@mysql:3306/grafana
ports:
0 info it worked if it ends with ok
1 verbose cli [ '/Users/cjone0102/.asdf/installs/nodejs/10.16.0/bin/node',
1 verbose cli '/Users/cjone0102/.asdf/installs/nodejs/10.16.0/.npm/bin/npm',
1 verbose cli 'install',
1 verbose cli 'grpc' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 08432355887bac0b
5 silly install loadCurrentTree
6 silly install readLocalPackageData
@magikid
magikid / moving-points.html
Last active February 26, 2017 16:46
WebGL Discussion
<!DOCTYPE html>
<!--
This page shows an animation of colored disks moving around
in a canvas, bouncing off the edges. The program uses WebGL.
All of the points are drawn as single primitive of type POINTS.
The color is an attribute in the vertex shader, allowing
each point to be a different primitive. The user can decide
whether to have randomly colored points or to make all the
points red. The point size is a uniform variable, so all
@magikid
magikid / Camera.java
Created February 12, 2017 04:03
Discussion 4
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.glu.GLU;
import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
/**
* A Camera object encapsulates the information needed to define a
@magikid
magikid / math.rs
Created January 16, 2017 17:12
Fibonacci Sequence Using Constant Function
#![feature(type_ascription)]
#[no_mangle]
pub extern fn fib(n: i32) -> f64 {
let inverse_five_sqrt:f64 = 1.0/(5.0:f64).sqrt();
let first_term = (1.0+(5.0:f64).sqrt()) / 2.0;
let second_term = (1.0-(5.0:f64).sqrt()) / 2.0;
(inverse_five_sqrt * first_term.powi(n) - inverse_five_sqrt * second_term.powi(n)).round()
}
@magikid
magikid / benchmark.rb
Last active January 13, 2016 00:48
My own benchmarks on each_with_object
require 'benchmark'
array = [1, 2, 3]
iterations = 1_000_000
def method_one(array)
hash = {}
array.each do |integer|
hash[integer] = integer ** 2
end
hash
@magikid
magikid / delete.rb
Last active August 29, 2015 14:23
List functions
def delete(list, element)
if element.prev != nil then
element.prev.next = element.next
else
list.head = x.next
end
if element.next != nil then
element.next.prev = element.prev
end
@magikid
magikid / fib.rb
Created June 17, 2015 23:15
Week 1 Forum
def fib_i(n)
i=0
two_back = 0
one_back = 1
while i<n do
i+=1
current_answer = one_back + two_back
two_back = one_back
one_back = current_answer
end
@magikid
magikid / elevatorsaga.js
Created April 30, 2015 22:21
Elevator Saga Program
{
init: function(elevators, floors) {
_.each(floors, function(floor) {
floor.on("up_button_pressed down_button_pressed", function() {
var elevator = elevators[Math.floor(Math.random() + elevators.length) % elevators.length];
if(elevators.some(function(elevator){ elevator.isDestination(floor.floorNum()) })){
return;
elevator.goToFloor(floor.floorNum());
});
});