Skip to content

Instantly share code, notes, and snippets.

View teidesu's full-sized avatar
🌸
bark bark woof woof idrk

alina 🌸🦴 teidesu

🌸
bark bark woof woof idrk
View GitHub Profile
@teidesu
teidesu / KawaiiCircularProgress.java
Created June 22, 2021 13:12
Kawaii material circular progress for android. preview: https://imgur.com/49Qs6GT
package desu.player.views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
@teidesu
teidesu / success-race.js
Created June 22, 2021 13:11
Promise.race but error-tolerant
/**
* Similar to Promise.race(), but resolves once one of the promises
* resolve to a successful value and didn't throw error.
* A promise result is considered `successful` when
* check(result) resolves to a truthy value.
*
* When all promises resulted with unsuccessful values, `null` is returned,
* otherwise result of first successful one is returned
*
@teidesu
teidesu / torrent-to-magnet.js
Created June 22, 2021 13:11
Simple NodeJS function to convert .torrent files to magnet URIs
// This file is licensed under LGPLv3
// (c) teidesu 2020
const qs = require('querystring')
const crypto = require('crypto')
// https://gist.github.com/teidesu/a1eadf71ffd88166415e2ea8b94d3f3b
const bencode = require('./bencode')
function convert (file) {
const data = bencode.decode(f)
@teidesu
teidesu / base32.js
Created June 22, 2021 13:11
JavaScript Base32 implementation
// This file is licensed under LGPLv3
// (c) teidesu 2020
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'
const padLength = [0, 1, 3, 4, 6]
const padChar = '='
function encode (buf) {
let arr = [...buf]
let len = arr.length
let ret = ''
@teidesu
teidesu / bencode.js
Created June 22, 2021 13:11
JavaScript BEncode implementation
// This file is licensed under LGPLv3
// (c) teidesu 2020
class Decoder {
pos = 0
constructor (str) {
this.str = str
}
decode () {
@teidesu
teidesu / create-sse.ts
Created June 22, 2021 13:11
simple sse for koa
import { Context } from 'koa'
function isPojo (obj: any): boolean {
return obj && typeof obj === 'object' && obj.constructor === Object
}
export interface SseController {
emit (options?: SseEmitOptions): void
close (): void
@teidesu
teidesu / exloader.js
Created June 22, 2021 13:11
Simple script to download galleries from exhentai.org w/out GPs, H@H or torrents.
#!/usr/bin/env node
/*
Simple script to download galleries from exhentai.org w/out GPs, H@H or torrents
Requires node >= 10 to run (uses fs.promises)
Dependencies:
yarn add cheerio node-fetch mime-types
# or
npm install cheerio node-fetch mime-types
@teidesu
teidesu / linked-list.js
Created June 22, 2021 13:11
Linked list for JavaScript without using native arrays. Pretty untested, but kind of works
export class LinkedList {
constructor () {
this._first = null
this._last = null
this.length = 0
}
push (item) {
let value = {
prev: null,
@teidesu
teidesu / firefox-pass-export.js
Created June 22, 2021 13:11
Small script for exporting passwords from Firefox Lockwise to Chrome CSV
/*
Small script for exporting passwords from Firefox Lockwise to Chrome CSV
Usage:
1. Open passwords page (about:logins)
2. Open devtools (F12)
3. Paste the following script
4. Wait a few seconds, a download prompt will appear.
Tested with 70.0.1 (64-bit) (Linux x64)
(c) teidesu 2019. This script is licensed under GPLv3
@teidesu
teidesu / update-cf-dns.sh
Created June 22, 2021 13:11
update ip in cloudflare dns for those nibbas who has dynamic ip
#!/bin/bash
API_KEY="..."
ZONE_ID="..."
RECORD_ID="..."
ADDRESS="..."
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" --data "{\"type\": \"A\", \"name\": \"$ADDRESS\", \"content\": \"$(curl ipv4.icanhazip.com)\", \"proxied\": false}"