Skip to content

Instantly share code, notes, and snippets.

@swallez
swallez / SSLUtils.java
Created March 14, 2023 22:05
A Java SSLContext that will accept any certificate (dangerous for production, useful for tests with a self-signed certificate)
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
import java.security.cert.X509Certificate;
public class SSLUtils {
private static SSLContext yesCtx = null;
/**
* Returns an SSLContext that will accept any server certificate.
@swallez
swallez / cercles_fractals.rs
Created September 23, 2022 12:04
Cercles fractals en Rust avec la librairie macroquad
use macroquad::prelude::*;
#[macroquad::main("Cercles fractals")]
async fn main() {
loop {
clear_background(LIGHTGRAY);
circles(0, screen_width() / 2.0, screen_height()/2.0, 150.0, 0);
next_frame().await
}
}
// Example of static methods in Rust traits, to illustrate this tweet:
// https://twitter.com/bluxte/status/1316315285356531712
//
// Try it in the Rust playground at
// https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=524057bcc33ea47ddefad9f0b31146e3
/// Something that has a name and can say it
trait NamedThing {
/// Static method
fn new(name: String) -> Self;
@swallez
swallez / build.xml
Created November 28, 2018 12:42
Ant file that produces html JUnit reports
<project name="scala-services" default="junitreport">
<target name="junitreport">
<mkdir dir="./target/test-html"/>
<junitreport>
<fileset dir="./target/test-reports">
<include name="TEST-*.xml"/>
</fileset>
<report todir="./target/test-html"/>
@swallez
swallez / CacheUtils.scala
Created September 18, 2018 19:10
A caching wrapper around an async function
import java.util.concurrent.atomic.AtomicReference
import scala.concurrent.{Await, ExecutionContext, Future, Promise}
import scala.concurrent.duration._
object CacheUtils {
private case class CacheInfo[T](p: Promise[T], expires: Long) {
/* Return the promise if it's not yet completed or hasn't expired */
def get: Option[Promise[T]] = {
@swallez
swallez / JacksonDSL.scala
Last active November 28, 2017 12:38
Experimenting a Scala DSL to create JSON objects with Jackson
import com.fasterxml.jackson.databind.{JsonNode, ObjectMapper}
import com.fasterxml.jackson.databind.node._
import scala.language.implicitConversions
object JacksonDSL {
// Builder objects using varargs

Keybase proof

I hereby claim:

  • I am swallez on github.
  • I am swallez (https://keybase.io/swallez) on keybase.
  • I have a public key whose fingerprint is E866 62A9 D259 55DF 2DDC BB19 C9B5 A6EC E2D7 74DF

To claim this, I am signing this object: