Skip to content

Instantly share code, notes, and snippets.

@sigsergv
sigsergv / folds.py
Last active June 16, 2022 15:55
python fold tasks
def flen(lst):
return reduce(lambda acc, x: acc + 1, lst, 0)
def flpos(lst, item):
def f(acc, x):
found, pos = acc
if found != -1:
return acc
if x == item:
return pos, pos
@cemerson
cemerson / archive.org-scanned-book-downloader-bookmarklet.md
Last active November 15, 2024 05:14
Archive.org Scanned Book Downloader Bookmarklet

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 / 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).
@cedrickring
cedrickring / ColoredShadow.kt
Last active September 5, 2024 21:56
Draw a colored shadow in Android Jetpack Compose
/*
Copyright 2020 Cedric Kring.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@jonathanmza
jonathanmza / DatabaseHealthCheck.java
Created October 8, 2019 15:35
Simple database health check with Spring
package your.package;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SingleColumnRowMapper;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component
@canwe
canwe / android-websters.md
Created September 30, 2019 11:54 — forked from jsomers/android-websters.md
Instructions for using Webster's 1913 on Android

To use Webster's 1913 dictionary on Android, install Colordict 3, an app that accepts this StarDict format. https://play.google.com/store/apps/details?id=com.socialnmobile.colordict

Next download James's S3 archive. https://s3.amazonaws.com/jsomers/dictionary.zip

You will need to extract the .dict file from inside three containers - .dz, .tar, .bz2 from innermost to outermost. 7zip handles all of these formats.

Place the .dict, .idx and .ifo files in the dictdata directory on your sdcard or local storage root. This is where colordict looks for dictionaries.

When the files are in the right place, you can run Colordict and tap the folder icon in the top right to see the dictionaries installed and set the dictionary priority. I put the 1913 dictionary above the defaults "Wordnet" and "Wikipedia." When you look up a word, ColorDict shows the definition, if available, from these multiple sources.

@fidanov
fidanov / cloudflare_worker.js
Created May 8, 2019 09:27
Resizing images on demand in Cloudflare Workers
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
@tkphd
tkphd / bite-size.tex
Created March 8, 2019 01:16
Modifications for @B0rk's excellent Bite Size Networking to get a proper 2-sided booklet
% Modifications for @b0rk's excellent Bite Size Networking
% to get a proper 2-sided booklet
\documentclass[12pt]{article}
\usepackage{graphicx,pdfpages}
\usepackage[paperheight=11in,paperwidth=8.5in,margin=0in]{geometry}
\pagestyle{empty}
\begin{document}
\begin{figure}\centering
\vskip-1cm
\includegraphics[page=24,width=8.25in,angle=180]{bite-size-networking.pdf}
@breadtk
breadtk / gist:bf3591a1ec181b62b659b68411694a06
Last active January 19, 2021 12:35
Stevey's Google Platforms Rant
(archived from: https://plus.google.com/+RipRowan/posts/eVeouesvaVX)
Stevey's Google Platforms Rant
I was at Amazon for about six and a half years, and now I've been at Google for
that long. One thing that struck me immediately about the two companies -- an
impression that has been reinforced almost daily -- is that Amazon does
everything wrong, and Google does everything right. Sure, it's a sweeping
generalization, but a surprisingly accurate one. It's pretty crazy. There are
probably a hundred or even two hundred different ways you can compare the two
# When no more interesting kata can be resolved, I just choose to create the new kata, to solve their own, to enjoy the process --myjinxin2015 said
#
# Description:
# There is a infinite string. You can imagine it's a combination of numbers from 1 to n, like this:
#
# "123456789101112131415....n-2n-1n"
# Please note: the length of the string is infinite. It depends on how long you need it(I can't offer it as a argument, it only exists in your imagination) ;-)
#
# Your task is complete function findPosition that accept a digital string num. Returns the position(index) of the digital string(the first appearance).
#