Skip to content

Instantly share code, notes, and snippets.

View UNIcodeX's full-sized avatar

Jared Fields UNIcodeX

View GitHub Profile
@wlib
wlib / LICENSE
Last active April 30, 2024 17:07
Run a shell script with bash, line-by-line, prompted on each command. Useful for running unknown scripts or debugging. Not a secure substitute for understanding a script beforehand.
MIT License
Copyright (c) 2021 Daniel Ethridge
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@Guevara-chan
Guevara-chan / nDustman.nim
Last active April 24, 2021 13:12
Junk sites URL generation util.
# Get compiled executable there: https://github.com/Guevara-chan/packages/releases/tag/nDustman_0.01
import random, nativesockets, threadpool, parsecfg, strutils, sequtils, terminal
const header = "# nDustman junk sites URL generator v0.01\n# Developed in 2021 by Victoria A. Guevara"
# Basic init.
randomize()
const config_file = "config.ini"
config_file.open(fmAppend).close()
var cfg = config_file.loadConfig()
@gullyn
gullyn / flappy.html
Last active January 24, 2025 00:41
Flappy bird in 205 bytes (improved!)
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>
@haxscramper
haxscramper / htppserve.nim
Last active May 12, 2021 12:04
Nim emscripten hello world
import asynchttpserver, asyncdispatch, os
proc handler(req: Request) {.async.} =
echo "request for path ", req.url.path
let cwd = getCurrentDir()
let file = cwd / req.url.path
if fileExists(file):
await req.respond(Http200, file.readFile())
else:
@snej
snej / threadSafeFuture.nim
Last active November 12, 2020 14:38
Thread-safe Futures for Nim
# threadSafeFuture.nim
# Jens Alfke, 30 June 2020
import asyncdispatch, deques, locks, sugar, threadpool
## Utilities for mixing async/await with threads.
##
## ``threadSafe()`` takes a Future and returns a new Future that can be completed on any thread.
## The original Future's callback will still be invoked on its original thread, and ``await``
## works normally.
# nim c -r --threads:on --gc:orc
import cpuinfo, os, random, locks, deques
type
WorkReq = ref object
id: int
WorkRes = ref object
id: int
@juancarlospaco
juancarlospaco / build_generic_nim_module.yml
Last active May 22, 2021 23:53
.github/workflows/build.yml GitHub Action for Nim (Generic Base Template)
name: Build Nim 👑
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
@juancarlospaco
juancarlospaco / nicy.nim
Last active April 7, 2021 16:10
ZSH Terminal "DIY prompt", uses https://github.com/icyphox/nicy
import strformat, times, os, osproc, nicypkg/functions
export functions
when isMainModule:
let
prompt = returnCondition(ok = "👍", ng = "👎") & " "
nl = "\n"
gitBranch = color(gitBranch(), "yellow")
cwd = color(tilde(getCwd()), "cyan")
dirty = color("×", "red")
@juancarlospaco
juancarlospaco / 0README.md
Last active June 8, 2021 19:14
Python Versus Nim: Async

Python Versus Nim: Async

  • No performance benchmark.
  • Python ⟿ PEP-8
  • Nim ⟿ NEP1
  • Python ⟿ 3.7
  • Nim ⟿ 0.19
  • No Ofuscation, no Code-Golf.

This is to compare elegant, simple, expressive code.

@mashingan
mashingan / crud_web.nim
Last active June 11, 2023 00:45
Simplistic crud example using Jester and Nim
# This example using
# Nim: 0.18.0
# Jester: 0.2.1
# Using Jester >= 0.3.0 is preferrable if your Nim version > 0.18.0
# In case you're using Jester >= 0.3.0, look the syntax different
# in its example because it's not backward compatible
import db_sqlite, asyncdispatch, json, strformat, strutils, sequtils
import jester