Skip to content

Instantly share code, notes, and snippets.

@rjvdw
rjvdw / tcp-proxy.coffee
Last active Aug 29, 2015
A TCP proxy that allows you to dump all communication.
View tcp-proxy.coffee
#!/usr/bin/env coffee
# vim: set ft=coffee:
"use strict"
# A TCP proxy that allows you to dump all communication.
net = require 'net'
[executing, script, source, dest] = process.argv
@rjvdw
rjvdw / eratosthenes.rs
Last active Dec 26, 2019
Computes all primes up to a certain number.
View eratosthenes.rs
extern crate time; // depend on time="0.2.1"
fn main() {
let upto = 100_000_000_000;
let start = time::PrimitiveDateTime::now();
let primes = sieve(upto);
let end = time::PrimitiveDateTime::now();
println!("found {:?} primes up to {} (in {} seconds).",
@rjvdw
rjvdw / fun-with-iterators.js
Last active Jun 21, 2016
This gist demonstrates how generator functions, iterators and promises work in JavaScript.
View fun-with-iterators.js
/* # 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
@rjvdw
rjvdw / jquery_laravel_jsonp_example.md
Created Aug 30, 2016
JSONP Example With jQuery And Laravel
View jquery_laravel_jsonp_example.md

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 / ByShadow.kt
Last active Dec 11, 2018
Match a CSS selector within all shadow roots
View ByShadow.kt
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 / dialogs.html
Created Dec 7, 2018
Some fun with <dialog>, async functions, and display:grid
View dialogs.html
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Dialog</title>
<style>
html {
font-family: sans-serif;
font-size: 16px;
width: 100%;
}
@rjvdw
rjvdw / buffer_utils.rs
Last active Mar 10, 2019
Using Rust to process wav file
View buffer_utils.rs
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 / brute_force.rs
Last active Mar 26, 2019
Pathfinding algorithms in Rust
View brute_force.rs
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 / get-certs.js
Last active Jun 10, 2019
Script to fetch all non-expired certificates with crt.sh (requires Node 12+)
View get-certs.js
'use strict'
const https = require('https')
const IDENTITIES = [
'rdcl.dev',
'%.rdcl.dev',
'rdcl.nl',
'%.rdcl.nl',
'ruud.online',
@rjvdw
rjvdw / crack.sh
Last active Aug 22, 2020
Simple example of brute forcing an encrypted zip file
View crack.sh
#!/bin/bash
while read line; do
unzip -P $line secret.zip && break
done < file.txt
You can’t perform that action at this time.