Skip to content

Instantly share code, notes, and snippets.

@iigmir
iigmir / fetch-page.py
Created June 1, 2024 08:13
Fetch lemma pages
import requests
page_size = 50
total = 205
page = 1
# It should be: `https://www.taichung.gov.tw/10026/Lpsimplelist?Page=1&PageSize=50&type=`
def get_api(page = 0, page_size = 0, total = 0):
return "https://www.taichung.gov.tw/10026/Lpsimplelist?Page=" + str(page) + "&PageSize=" + str(page_size) + "&type="
// ==UserScript==
// @name TVT scripts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description TV Tropes scripts
// @author iigmir
// @match https://tvtropes.org/**/*
// @icon https://assets.tvtropes.org/img/icons/favicon.ico
// @grant none
// ==/UserScript==
@iigmir
iigmir / dlsite-total-prices.js
Created May 23, 2024 12:58
Return the total price of your wishlist on DLsite
// ==UserScript==
// @name Total prices
// @namespace http://tampermonkey.net/
// @version 2024-05-19
// @description Return the total price of your wishlist before yuo try to clean.
// @author You
// @match https://www.dlsite.com/**/mypage/wishlist
// @icon https://www.google.com/s2/favicons?sz=64&domain=dlsite.com
// @grant none
// ==/UserScript==
@iigmir
iigmir / ci-en-download-images.js
Last active May 23, 2024 12:57
Download images on ci-en.dlsite.com
// ==UserScript==
// @name Ci-en Download images
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Download images on ci-en.dlsite.com
// @author You
// @match https://ci-en.dlsite.com/creator/**/article/**
// @icon https://www.google.com/s2/favicons?sz=64&domain=dlsite.com
// @grant none
// ==/UserScript==
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>All work and no play makes Jack a dull boy</title>
</head>
<body>
<h1>All work and no play makes Jack a dull boy</h1>
<article id="all-work-and-no-play-makes-jack-a-dull-boy">
@iigmir
iigmir / crawl.js
Created April 17, 2024 06:36
crawl.js
import { JSDOM } from "jsdom";
import { writeFile, existsSync, mkdirSync } from "fs";
/**
* Get HTML content.
* @param {String} url
* @returns {String} A HTML source code
*/
const CrawlPage = async (url = "https://example.com") => {
const r = await fetch(url, {
@iigmir
iigmir / docker-compose.yml
Last active May 23, 2024 13:04
laravel-docker-with-phpmyadmin
version: "3.3"
services:
ldb:
image: "bitnami/mariadb:latest"
environment:
ALLOW_EMPTY_PASSWORD: yes
MARIADB_USER: "bn_myapp"
MARIADB_DATABASE: "bitnami_myapp"
networks:
@iigmir
iigmir / index.js
Created February 5, 2024 14:14
The Twelve Days of Christmas
const build_result_array = (input_array = [], current_length = 0, output_array = []) => {
const current = input_array[current_length - 1];
if( current_length === 1 ) {
return [...output_array, `1 ${current}`];
}
return build_result_array(
input_array,
current_length - 1,
[
...output_array,
@iigmir
iigmir / error_handling.js
Last active May 5, 2023 15:51
Error handling
/**
* ha ha
* @see https://stackoverflow.com/a/549611/7162445
* @param up Something is really wrong
*/
const error_handling = (up) => {
if (up) {
console.error( up );
throw up;
}
@iigmir
iigmir / csv-to-json-functional.js
Last active February 2, 2023 17:32
csv-to-convertor
/**
* @param {Array} keys Array of keys. By definition from [RFC 4180](https://www.rfc-editor.org/rfc/rfc4180), it will be the first line of the file.
* @returns {Function}
*/
const csv_array_to_json = (keys) =>
{
/**
* @param {Array} item Values
* @returns {Object} A JSON format interface.
*/