Skip to content

Instantly share code, notes, and snippets.

View Varriount's full-sized avatar

Clay Sweetser Varriount

View GitHub Profile
@Varriount
Varriount / nbe-strings.mkd
Last active March 31, 2024 01:12
Nim-By-Example: Strings

String Literals

Strings literals in Nim can be written by surrounding text with either a single pair of double-quotes or with three pairs of double-quotes. Single-quoted string literals may only span one line, while triple-quoted string literals may span multiple lines.

"Hello World"
"""
  Hello
@findstr/v "^@f.*&" "%~f0" | powershell -NoProfile -ExecutionPolicy Bypass - & pause & goto:eof
# The above line allows running this file as a batch file, to overcome the
# need for execution policy changes.
# Note, when making changes to this script, testing needs to be done under the
# version of PowerShell that comes with Windows (PowerShell v5), as that is
# what most users will have access to.
# ## Constants ## #
$OUT_FILE_PATH = "${env:temp}\BG3 Installation Data.txt"
@Varriount
Varriount / sort_terms.py
Created October 3, 2023 20:38
Sort terms based on word and character similarity
import codecs
import sys
from editdistance import eval as distance
from pprint import pprint
import re
def sort_phrases(phrase_list):
result = []
result.append(phrase_list.pop())
@Varriount
Varriount / small_ghidra_functions.py
Created September 30, 2023 00:18
Small Python snippet to find small functions in Ghidra (to mark as inline)
TARGET_FUNCTION_PREFIXES = [
'FUN_', # Default prefix for functions found by Ghidra
'f_p__', # CUSTOM_AUTO_FUNC_PREFIX
'f_p__TS__', # CUSTOM_AUTO_THREAD_FUNC_PREFIX
]
from pprint import pprint
cp = currentProgram
// language=Handlebars
const RAW_CLASS_TEMPLATE = `
class SettingsClass extends {{baseClassName}} {
namespace = {{toStringLiteral namespace}}
//// Private Methods ////
static _register() {
{{#each settings as | setting |}}
game.settings.register(
this.namespace,
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.plugins.action import ActionBase
# Load the display handler to send logging to CLI or relevant display mechanism
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
@Varriount
Varriount / aws_example.nim
Created September 21, 2017 22:38
Nim AWS Snippets
# AWS Version 4 signing example
# EC2 API (DescribeRegions)
# See: http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
# This version makes a GET request and passes the signature
# in the Authorization header.
import base64, httpclient, hmac, nimSHA2, os, times, strutils, httpcore
# ************* REQUEST VALUES *************
@Varriount
Varriount / .env
Created February 11, 2022 20:29
Using Docker Compose's `.env` File to Automatically Use Multiple Compose Files.
COMPOSE_FILES=this.yaml:that.yaml
async function setElevation(value) {
// Scenarios:
// - Tokens are selected, hovered token is undefined.
// - Set elevation of selected tokens.
// - Tokens are selected, hovered token is in selection.
// - Set elevation of selected tokens.
// - Tokens are selected, hovered token is not in selection.
// - Set elevation of hovered token.
// - No tokens are selected, hovered token is undefined.
// - Do nothing
// let realRawData = `...`
// Note: The following code uses inconsistant processing strategies for the purposes of example.
{
//// Utility Functions ////
const querySelectorAll = (node, expr) => node.querySelectorAll(expr);
const querySelector = (node, expr) => node.querySelector(expr);
function* queryXPathAll(node, expr) {
const evaluator = new XPathEvaluator();