Skip to content

Instantly share code, notes, and snippets.

@rjvdw
rjvdw / Solve
Last active November 16, 2024 09:57
Find all words in a word list that fit the pattern for the NYT Letter Boxed game
#!/usr/bin/env java --source 23 --enable-preview
import java.util.Scanner;
/// Find all words in a word list that fit the pattern for the
/// [NYT Letter Boxed game](https://www.nytimes.com/puzzles/letter-boxed).
///
/// Usage:
///
/// cat word-list.txt | ./Solve abc def hij klm
'use strict'
function F1() {
console.log('construct F1')
this.name = 'F1'
this.f1 = true
}
// does not call the constructor of F1, works with instanceof
function F2() {
@rjvdw
rjvdw / crack.sh
Last active August 22, 2020 12:21
Simple example of brute forcing an encrypted zip file
#!/bin/bash
while read line; do
unzip -P $line secret.zip && break
done < file.txt
@rjvdw
rjvdw / get-certs.js
Last active June 10, 2019 08:25
Script to fetch all non-expired certificates with crt.sh (requires Node 12+)
'use strict'
const https = require('https')
const IDENTITIES = [
'rdcl.dev',
'%.rdcl.dev',
'rdcl.nl',
'%.rdcl.nl',
'ruud.online',
@rjvdw
rjvdw / brute_force.rs
Last active March 26, 2019 20:24
Pathfinding algorithms in Rust
use std::cmp::min;
use std::collections::HashSet;
use crate::graph::Graph;
use crate::node::Node;
use crate::path::Path;
pub fn brute_force(graph: &Graph, from: &Node, to: &Node) {
let mut seen = HashSet::new();
@rjvdw
rjvdw / buffer_utils.rs
Last active March 10, 2019 13:54
Using Rust to process wav file
use std::str;
pub fn read_string_from_buffer<'a>(header: &'a [u8], from: usize, length: usize) -> &'a str {
let to = from + length;
str::from_utf8(&header[from .. to]).unwrap()
}
pub fn read_u16_from_buffer(header: &[u8], from: usize) -> u16 {
let to = from + 2;
let slice = &header[from .. to];
@rjvdw
rjvdw / dialogs.html
Created December 7, 2018 21:42
Some fun with <dialog>, async functions, and display:grid
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Dialog</title>
<style>
html {
font-family: sans-serif;
font-size: 16px;
width: 100%;
}
@rjvdw
rjvdw / ByShadow.kt
Last active December 11, 2018 14:10
Match a CSS selector within all shadow roots
import org.openqa.selenium.By
import org.openqa.selenium.JavascriptExecutor
import org.openqa.selenium.SearchContext
import org.openqa.selenium.WebElement
class ByShadow(vararg selectors: String) : By() {
private val args = "['" + selectors.joinToString("','") + "']"
override fun findElements(ctx: SearchContext): List<WebElement> {
@rjvdw
rjvdw / jquery_laravel_jsonp_example.md
Created August 30, 2016 08:43
JSONP Example With jQuery And Laravel

JSONP Example With jQuery And Laravel

javascript

$.ajax({ url: '/my-pretty-url', dataType: 'jsonP' })
  .done(function (data, textStatus, jqXHR) {
    console.log(data)
  })
  .fail(function (jqXHR, textStatus, err) {
 throw(err)
@rjvdw
rjvdw / fun-with-iterators.js
Last active June 21, 2016 08:53
This gist demonstrates how generator functions, iterators and promises work in JavaScript.
/* # Fun With Iterators
*
* This snippet of code demonstrates how generator functions, iterators
* and promises work in JavaScript.
*
* ## Promises
*
* A promise is an object that represents a value that is yet to be
* determined. As soon as this value is known the promise will be
* resolved. If however something went wrong, the promise will be