Skip to content

Instantly share code, notes, and snippets.

View ShujianDou's full-sized avatar
🎇
Exploring Literature

Chay ShujianDou

🎇
Exploring Literature
View GitHub Profile
@ShujianDou
ShujianDou / video.nim
Last active June 18, 2024 05:05
Video player using time-based FPS video synchronization using FFmpeg and SDL2
import ffmpeg
import sdl2, sdl2/audio
import os, strformat, times, math, asyncdispatch, locks, threadpool, times, terminal
import ../kyuickObject
import sugar
type
CodecData* = ref object of RootObj
params*: AVcodecParameters
codec*: ptr AVCodec
@ShujianDou
ShujianDou / evp_BytesToKey.nim
Created January 3, 2024 04:42
EVP_BytesToKey implementation in Nim. Returns the key and iv given a password and salt.
import std/[base64, strutils]
import checksums/md5
# AES-256 sizes; _password in plaintext form, and _salt in byte form.
proc evp_BytesToKey*(passwordz, saltz: string): tuple[key, iv: string] =
var password: string = passwordz
var salt: string = saltz
var passwordBytes = newString(len(password))
@ShujianDou
ShujianDou / approximation.nim
Last active April 24, 2023 01:08
Trapezoid, Midpoint, Simpsons, approximation implementation
import math
var i: float = 0
var iterations: int = 1
var n: int = 4 # Number of slices
var deltaX: float = 1/4 # deltaX, (b - a)/n
template dfunk*(): untyped =
10*cos(i*i) # Type your integral function here.
@ShujianDou
ShujianDou / fib.nim
Created November 4, 2022 00:02
nim fib
import std/math
proc fibbonacci*(n: int): int =
var idx: int = 1
var num: int = 1
var prv: int = 0
while idx <= n:
inc idx
let t: int = num
num = (num + prv)
@ShujianDou
ShujianDou / seeker.nim
Created October 31, 2022 23:33
xmltree seeking through recursion test, 1; I plan on adding a way to get the path later.
import std/[os, osproc, terminal, htmlparser, xmltree, strutils, strtabs, parseutils]
import system/io
#var kindSimilar: bool = false
#var isXnElement: bool = false
#var attrTag: bool = false
#var isEquivalent: bool = false
#if a.kind == b.kind:
# kindSimilar = true
# if a.kind == xnElement:
@ShujianDou
ShujianDou / lightnovelpub.nims
Created October 12, 2022 04:10
Script to scrape LightNovelPub; incomplete atm.
# name:LightNovelPub
# scraperType:nvl
# version:0.0.1
# siteUri:www.lightnovelpub.com
import std/[htmlparser, xmltree]
var defaultHeaders: seq[tuple[key: string, value: string]] = @[
("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0"),
("Accept-Encoding", "identity"), ("Accept", "*/*")]
var page: XmlNode
@ShujianDou
ShujianDou / testCore.nim
Created August 3, 2022 18:18
Test program written for ADLCore
import ADLCore, ADLCore/Novel/NovelTypes, ADLCore/Novel/NovelHall
import ADLCore/Video/VideoType, ADLCore/Video/VidStream, ADLCore/genericMediaTypes
import std/[os, terminal, strutils]
echo "Testing ADLCore"
var videoObj: Video
echo "Testing Video -- VidStream"
videoObj = GenerateNewVideoInstance("vidstreamAni", "https://gogoplay1.com/videos/shine-post-episode-4")
assert videoObj != nil
@ShujianDou
ShujianDou / quadraticSolver.nim
Created December 31, 2021 07:15
Quadratic solver in NIM
import os
import std/math
import strutils
let a = float64(parseFloat(paramStr(1)))
let b = float64(parseFloat(paramStr(2)))
let c = float64(parseFloat(paramStr(3)))
proc getVertex(a: float64, b: float64): float64 =
@ShujianDou
ShujianDou / Epub.cs
Created February 12, 2021 17:29
Simplistic ~500 line document to create EPUBs and export EPUB files. EPUBs are compatible with Calibre, Lithium, etc
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Compression;
namespace ADLCore
{
public enum MediaType
{