Skip to content

Instantly share code, notes, and snippets.

View dcdunkan's full-sized avatar

Dunkan dcdunkan

View GitHub Profile
@dcdunkan
dcdunkan / 1337x-proxy-open-link.userscript.js
Last active August 20, 2024 19:26
userscript to open the magnet link right in the 1337x-to-search.pages.dev proxy
@dcdunkan
dcdunkan / etlab-auto-login.userscript.js
Last active May 6, 2024 14:22
Script for logging in automatically each time I open the damn site cuz the session is expired very quickly.
// ==UserScript==
// @name etlab auto login
// @namespace Violentmonkey Scripts
// @match https://*.etlab.in/*
// @grant GM_getValue
// @grant GM_setValue
// @version 0.4
// @author Dunkan <https://github.com/dcdunkan>
// @description 3/12/2024, 2:32:52 AM
// @run-at document-end
@dcdunkan
dcdunkan / github-raw-jio-fix.user.js
Created June 22, 2023 14:23
For some reason its not possible to access GitHub raw links via Jio's connection. So a tiny temporary unreliable fix.
// ==UserScript==
// @name GitHub raw links bypasser for Jio connections
// @namespace http://tampermonkey.net/
// @version 0.1
// @description For some reason its not possible to access GitHub raw links via Jio's connection. So a tiny temp unreliable fix.
// @author Dunkan <https://github.com/dcdunkan>
// @match http*://github.com/*
// @match http*://raw.githubusercontent.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant none
@dcdunkan
dcdunkan / broken.ts
Last active June 3, 2023 14:50
script for validating links in grammyjs/website before building the website
import { extname, join } from "https://deno.land/[email protected]/path/mod.ts";
import {
DOMParser,
HTMLDocument,
} from "https://deno.land/x/[email protected]/deno-dom-wasm.ts";
import MarkdownIt from "https://esm.sh/[email protected]";
import anchorPlugin from "https://esm.sh/[email protected]";
import { slugify } from "https://esm.sh/@mdit-vue/[email protected]";
import {
blue as b,
export interface GistOptions {
token: string;
gistId: string;
fileName: string;
}
const API_ROOT = "https://api.github.com";
export class GistKV {
constructor(private options: GistOptions) {}
@dcdunkan
dcdunkan / resolve_path.ts
Last active March 28, 2023 10:46
Resolve remote and local paths in Deno
import { fromFileUrl, isAbsolute } from "https://deno.land/[email protected]/path/mod.ts";
const isRemoteImport = ["http:", "https:"]
.includes(new URL(import.meta.url).protocol);
function isUrl(path: string) {
try {
new URL(path);
return true;
} catch (_) {
@dcdunkan
dcdunkan / slot-machine.ts
Last active February 8, 2024 07:15
Resolve Telegram's slot machine dice value (from tdesktop source)
const e = ["🔤", "🫐", "🍋", "7️⃣"];
function computePartValue(value: number, partIndex: number) {
return ((value - 1) >> (partIndex * 2)) & 0x03; // 0..3
}
function resolve(value: number) {
if (value <= 0 && value > 64) return;
let text = `${value}:`;
for (let i = 0; i < 3; i++) text += ` e[computePartValue(value, i)]`;
@dcdunkan
dcdunkan / deno_deta_base.ts
Last active March 27, 2023 10:06
Tiny https://deta.sh base client.
export class Base {
private rootUrl: string;
constructor(private projectKey: string, baseName: string) {
const projectId = projectKey.split("_")[0];
this.rootUrl = `https://database.deta.sh/v1/${projectId}/${baseName}`;
}
async request(query: string, payload?: unknown) {
const [method, ...pathname] = query.split(" ");
const response = await fetch(`${this.rootUrl}${pathname.join(" ")}`, {
@dcdunkan
dcdunkan / slideshare_bot.ts
Last active March 27, 2023 10:07
Slideshare downloader
import { Bot, InputFile } from "https://deno.land/x/[email protected]/mod.ts";
import { DOMParser } from "https://deno.land/x/[email protected]/deno-dom-wasm.ts";
import { StatusMessage } from "https://gist.githubusercontent.com/dcdunkan/235859eac749d36f4df7c00b99fbbc8f/raw/status.ts";
const bot = new Bot(Deno.env.get("BOT_TOKEN")!);
bot.command("start", async (ctx) => await ctx.reply("yeah!"));
bot.on("message:text").on("::url", async (ctx) => {
const url = ctx.message.text;
@dcdunkan
dcdunkan / example.ts
Last active February 3, 2022 13:07
Telegraph API wrapper different parse mode examples
/*
* This is just for demonstrational purposes. A minimal one, haven't used so many
* available tags, markdown syntaxes. See the library and documentation here:
* https://github.com/dcdunkan/telegraph.
*/
import { Telegraph, parse } from "https://deno.land/x/telegraph/mod.ts";
const tph = new Telegraph({
// SANDBOX access token from Official API Docs: https://telegra.ph/api