Skip to content

Instantly share code, notes, and snippets.

View ChlodAlejandro's full-sized avatar
🐢
adoring this turtle

Chlod Aidan Alejandro ChlodAlejandro

🐢
adoring this turtle
View GitHub Profile
#!/usr/bin/env python3
# 1. Install Python 3 if you don't have it yet.
# 2. Download your data dump (Settings > Privacy and Safety > Request Data)
# 3. Wait for the dump to get sent, then download it.
# 4. Extract the dump to any folder.
# 5. Download and place this file in the "messages" folder of your data dump.
# 6. Run it with `python3 discord-scatter-plot.py`
# 7. (optional) You can edit the "serverYouWant" variable down below to specify a specific server.
# This accepts a server ID. To get the server ID, enable "Developer Mode" (Settings > Advanced),
# right click on a server, and then click on "Copy ID".
@ChlodAlejandro
ChlodAlejandro / get.mjs
Last active January 29, 2024 17:30
CNN Philippines externallinks archive status report for English Wikipedia
// save result of https://quarry.wmcloud.org/query/80025 as csv
// put in directory as "masterlist.csv"
import * as fs from "fs";
import fetch from "node-fetch"
const BASE_URL = "https://cnnphilippines.com";
const data = fs.readFileSync("masterlist.csv").toString("utf8").split("\n").slice(1);
if (fs.existsSync("a.txt"))
fs.unlinkSync("a.txt");
@ChlodAlejandro
ChlodAlejandro / copypatrol-open-count.js
Last active August 11, 2023 17:32
Calculates open CopyPatrol cases which can't be actioned (page is deleted or content is already revision-deleted).
/*!
Calculates open CopyPatrol cases which can't be actioned (page is
deleted or content is already revision-deleted).
Run the following commands beforehand:
```sh
npm install knex mysql2 dotenv
# Replace <shell> with your Toolforge username.
ssh -L 4711:enwiki.analytics.db.svc.eqiad.wmflabs:3306 -L 4712:tools.db.svc.eqiad.wmflabs:3306 <shell>@dev.toolforge.org -Nv
```
@ChlodAlejandro
ChlodAlejandro / 01.wordy.ts
Last active April 15, 2023 13:58
Scan for contentful Wikipedia edits per minute
import WikimediaStream from "wikimedia-streams";
import axios from 'axios';
import * as fs from "fs/promises";
import { MediaWikiRecentChangeEditEvent } from "wikimedia-streams/build/src/streams/MediaWikiRecentChangeEvent";
import { diffSentences } from "diff";
const outputFile = "data.json";
const outputMap: Record<string, number> = {};
(async () => {
@ChlodAlejandro
ChlodAlejandro / cpc-response-count.js
Last active September 19, 2022 15:45
Counts the number of instances of {{CPC}} transclusions in the Wikipedia:Copyright problems pagespace.
// !!!
// This version is !! UNMAINTAINED !!
// See https://github.com/ChlodAlejandro/deputy/tree/main/scripts/cpcrc.js for an updated version.
// !!!
/**
* Counts the number of instances of {{CPC}} transclusions in the Wikipedia:Copyright problems pagespace.
* ================================================================================================
* Copyright © 2022 Chlod Aidan Alejandro
*
@ChlodAlejandro
ChlodAlejandro / classMix.ts
Last active March 15, 2022 21:41
Mix a set of string, boolean, undefined, or null values into a clean CSS class list. Used in conjunction with React.
type ArrayOrNot<T> = T | T[];
export default function (
...classes: ArrayOrNot<string | null | undefined | false>[]
): string {
const processedClasses = [];
for (const _class of classes) {
if (Array.isArray(_class)) processedClasses.push(..._class);
else processedClasses.push(_class);
@ChlodAlejandro
ChlodAlejandro / keybase.md
Created January 24, 2022 22:28
Keybase verification gist

Keybase proof

I hereby claim:

  • I am ChlodAlejandro on github.
  • I am chlod (https://keybase.io/chlod) on keybase.
  • I have a public key whose fingerprint is D7B4 3C2E D795 86A6 1E4A 8D0F A1E6 7C59 037B 0CC1

To claim this, I am signing this object:

@ChlodAlejandro
ChlodAlejandro / system-user.sh
Last active October 28, 2021 00:51
Create a system user and generate an SSH key for the user for continuous deployment.
#!/bin/bash
# Make sure that you have a `cd` group for continuous deployment purposes.
# Also make sure that this group is already in the `sudoers.d` file, allowing
# sudo for systemctl operations ONLY (possibly git, if you want as well).
# This will output the SSH private key on your current directory.
# To delete the generated user, use `deluser --remove-home <username>`
# Tested on Debian 11.
@ChlodAlejandro
ChlodAlejandro / OpenGraph template.html
Last active January 31, 2021 03:17
OpenGraph meta tags for HTML pages.
<title>{title}</title>
<meta name="twitter:card" content="summary"/>
<meta name="twitter:creator" content="ChlodAlejandro"/>
<meta name="twitter:image" content="{image}"/>
<meta name="og:title" property="og:title" content="{title}" />
<meta name="og:description" property="og:description" content="{description}" />
<meta name="description" content="{description}">
<meta name="og:image" property="og:image" content="{image}"/>
@ChlodAlejandro
ChlodAlejandro / template.html
Created January 31, 2021 02:15
Baseline HTML file.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Website</title>