Skip to content

Instantly share code, notes, and snippets.

Archive.org Scanned Book Downloader Bookmarklet

A simple "1-click" javascript approach to downloading a scanned book from archive.org to read at your leisure on the device of your choosing w/out having to manually screenshot every pages of the book by hand. In short it's a glorified "Save Image As..." approach but consolidated down to "1 click". BTW there may be a much better option than this out there - I just built this as an autistic project to see if it would work.

Demo Video

Archive.org SBDL Demo

Obligatory Legal/Disclaimer:

By using this script you agree to delete all book files/images after your 1 hour or 14 days is up! I don't support using this script for any other use cases. After all, none of us have ever kept a library book past it's return date, right?

@canwe
canwe / quiz.java
Created November 9, 2023 12:52 — forked from yegor256/quiz.java
quiz.java
/**
* Please review the class below and suggest improvements. How would
* you refactor this class if it would be in a real-life project?
* There are many problems here, both high-level design mistakes,
* and low-level implementation bugs. We're interested to see high-level
* problems first, since they are most critical. The more mistakes
* you can spot, the better programmer you are.
*/
/**
@canwe
canwe / Cache.java
Created August 5, 2022 12:23 — forked from nikartx/Cache.java
Android. Example how to save an image file in the App cache and get Uri for it. The Image will not be saved in a device gallery, only in an internal App cache.
package com.github.example;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
@OptIn(ExperimentalAnimationApi::class)
@Composable
fun Heart(modifier: Modifier, horizontalPadding: Int, bottomMargin: Int) {
val width = LocalConfiguration.current.screenWidthDp
val height = LocalConfiguration.current.screenHeightDp - bottomMargin
val yRandom = Random.nextInt(0, height / 2)
val xRandom = Random.nextInt(horizontalPadding, (width - horizontalPadding))
val state = remember {
@canwe
canwe / System Design.md
Created November 23, 2020 11:46 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@canwe
canwe / Leaderboard Using Redis
Created November 17, 2020 08:03 — forked from wonjun27/Leaderboard Using Redis
Leaderboard Using Redis
Leaderboard Using Redis
http://labs.strava.com/blog/koms-powered-by-redis/
Strava KOMS, Powered by Redis
----------------
http://aimeeault.com/2014/06/22/making-the-most-of-redis-and-sorted-sets/
For example, what if I only want to see a leaderboard of members who are between the ages of 18 and 49? The Sorted Set contains no information on how old each member is. And I don’t want to maintain a separate Redis Sorted Set for just these users, because that’s kind of redundant, right? You probably don’t want to fetch every single one of the potentially hundreds of thousands of records and filter individually… that’s not very efficient! There’s a couple of ways you could approach this with Redis. One is by way of Lua scripting with use of EVAL (which runs Lua) and ZSCAN (which can be used for matching keys and values by rules, similar to regular expressions).
@canwe
canwe / permute.py
Created November 8, 2020 08:39 — forked from gsamokovarov/permute.py
Iterative permutation implementation in Python.
def permute(sequence, index=0):
length = len(sequence)
if index > length:
raise StopIteration
if index == length:
yield sequence
else:
for i in range(index, length):
@canwe
canwe / permgen.py
Created November 7, 2020 15:05 — forked from interstar/permgen.py
Python Permutation Generator : A generator that outputs all permutations of a sequence
def perm(xs) :
if xs == [] :
yield []
for x in xs :
ys = [y for y in xs if not y==x]
for p in perm(ys) :
yield ([x] + p)
@canwe
canwe / wget.sh
Created November 1, 2020 20:10 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@canwe
canwe / README.md
Created October 31, 2020 08:36 — forked from joyrexus/README.md
groupby and countby for python

groupby and countby for python

Python has the standard methods for applying functions over iterables, viz. map, filter, and reduce.

For example, we can use filter to filter some numbers by some criterion:

even = lambda x: x % 2 is 0
odd  = lambda x: not even(x)
data = [1, 2, 3, 4]