Skip to content

Instantly share code, notes, and snippets.

package fitnesse.html;
import fitnesse.responders.run.SuiteResponder;
import fitnesse.wiki.*;
public class SetupTeardownIncluder {
private PageData pageData;
private boolean isSuite;
private WikiPage testPage;
private StringBuffer newPageContent;
@eloff
eloff / dan.java
Last active March 29, 2024 22:31
package fitnesse.html;
import fitnesse.responders.run.SuiteResponder;
import fitnesse.wiki.*;
// Note: I did not compile or run this, so it may have stupid errors
public class TestableHtml {
private PageData pageData;
private WikiPage wikiPage;
private PageCrawler pageCrawler;
@eloff
eloff / mutex.rs
Last active February 2, 2024 17:00
Rust Mutex for when you don't need poisoning
pub use std::sync::{MutexGuard, RwLockReadGuard, RwLockWriteGuard};
use std::sync::{TryLockError, Mutex, RwLock};
pub struct SimpleMutex<T>(Mutex<T>);
impl<T> SimpleMutex<T> {
pub const fn new(t: T) -> Self {
Self(Mutex::new(t))
}
@eloff
eloff / unsplit_bytes.rs
Last active August 3, 2021 01:24
merge two adjacent Bytes objects into one
// Public Domain
use bytes;
struct BytesAlike {
data: *const u8,
len: usize,
_1: usize,
_2: usize,
}
@eloff
eloff / transport_tls.rs
Created July 4, 2021 12:15
enum to combine ClientConnection and ServerConnection
use std::io;
use std::result::Result;
use rustls::{IoState, ClientConfig, ServerConfig, ClientConnection, ServerConnection, Connection, ServerName, Reader, Writer};
pub enum TransportTls {
NoTls,
Client(ClientConnection),
Server(ServerConnection),
}

Keybase proof

I hereby claim:

  • I am eloff on github.
  • I am eloff (https://keybase.io/eloff) on keybase.
  • I have a public key ASDauBK53p6pr6rbzVuveMaf3Hz9E-CJP1Xr2XuGnSkpgAo

To claim this, I am signing this object:

package main
import (
"fmt"
)
func main() {
fmt.Println(subset([]string{"test1", "test2", "test2"}, []string{"test1", "test2"}))
}
def flatten src_array
flat = []
# It would be more readable to just call flat.concat(flatten(...)) recurisvely
# but that creates and destroys a lot of intermediate arrays, which may be costly
append_all(flat, src_array)
flat
end
def append_all dest_array, src_array
src_array.each do |value|
@eloff
eloff / gist:1246455
Created September 27, 2011 22:33
Add query params to url
from urlparse import urlparse, urlunparse
from urllib import urlencode
def add_query_args(uri, **params):
parts = list(urlparse(uri))
qs = urlencode(params)
if parts[4]:
parts[4] += '&' + qs
else:
parts[4] = qs