Skip to content

Instantly share code, notes, and snippets.

View njofce's full-sized avatar

Nasi njofce

  • Skopje
View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
@njofce
njofce / generate-key
Last active November 8, 2022 11:19
Generate ECDSA key pair
#!/usr/bin/env sh
set -e
key=`openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout 2>/dev/null`
# Extract the public key and remove the EC prefix 0x04
pub=`echo "${key}" | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//'`
# Extract the private key and remove the leading zero byte
priv=`echo "${key}" | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//'`
@njofce
njofce / generate-key.sh
Created November 7, 2022 20:14
Generate ECDSA key pair
#!/usr/bin/env bash
set -e
openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > key
cat key | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//' > pub
cat key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv
echo "Private Key: \n"
cat priv
@njofce
njofce / generate-key.sh
Created November 7, 2022 20:11
Generate ECDSA key pair
#!/usr/bin/env bash
set -e
openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > key
cat key | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//' > pub
cat key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv
@njofce
njofce / generate-key.sh
Created November 7, 2022 20:09
Generate ECDSA key pair
openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout > key
cat key | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//' > pub
cat key | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//' > priv
public class FileMetadata {
public String id;
public String fileName;
public long length;
public byte[] contents;
public class FeignClient {
public static void main(String[] args) throws ExecutionException, InterruptedException {
synchronousTest();
asyncTest();
}
private static void synchronousTest() {
FileApi fileApi = FileApiFactory.getSynchronousFileAPI();
@RequestMapping("file")
public interface AsyncFileApi {
@GetMapping("/{id}")
CompletableFuture<FileMetadata> getFile(@PathVariable String id);
@GetMapping("/search")
CompletableFuture<List<FileMetadata>> searchFiles(@RequestParam(name = "name") String name);
@PostMapping("/save")
// Custom datetime serializer
private static final LocalDateTimeSerializer CUSTOM_DATE_SERIALIZER =
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("dd-MMM-yyyy HH:mm"));
// Custom datetime deserializer
private static final LocalDateTimeDeserializer CUSTOM_DATE_DESERIALIZER =
new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("dd-MMM-yyyy HH:mm"));
// Feign based API
public static FileApi getFileAPI() {
public static FileApi getFileAPI() {
String URL = "http://localhost:8080"; // This must be passed as an ENV variable
return Feign.builder()
.contract(new SpringMvcContract())
.target(FileApi.class, URL);
}