Skip to content

Instantly share code, notes, and snippets.

View JamesMenetrey's full-sized avatar
🐹
Shifting some bits ...

Jämes Ménétrey JamesMenetrey

🐹
Shifting some bits ...
View GitHub Profile
@JamesMenetrey
JamesMenetrey / inheritance.py
Created March 27, 2024 17:06
Inheritance Python
from abc import abstractmethod, abstractproperty, ABC
from typing import List
def load_from_file(filename):
return [GuineaPig("Kéké"), GuineaPig("Choki"), Cat("Gaspard")]
@JamesMenetrey
JamesMenetrey / app.cs
Last active February 12, 2024 14:31
WAMR, generate the Intel SGX attestation User Data field and verification in C#
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
const ushort securityVersionReference = 0;
const ushort productIdReference = 0;
byte[] nonce =
{
0x21, 0x0D, 0x7A, 0x62, 0xFA, 0xC0, 0x71, 0xAD, 0x92, 0x2A, 0xE0, 0x7B, 0x28, 0xFE, 0xCA, 0xD2,
@JamesMenetrey
JamesMenetrey / day2-part1.cs
Created December 2, 2021 13:48
Advent of Code 2021 - day 2
// Advent of Code 2021, day 2, part 1.
// Solved using funny immutable and functional C#.
// Written by Jämes Ménétrey.
using System;
using System.IO;
using System.Linq;
var result = File.ReadAllLines("input.txt")
.Aggregate(new Submarine(), ParseInput, submarine => submarine.Result);
Console.WriteLine($"Result: {result}");
@JamesMenetrey
JamesMenetrey / with-persistant-rootfs.log
Last active April 28, 2021 17:43
OP-TEE boot log on i.MX8
U-Boot SPL 2020.10-rc1 (Apr 28 2021 - 16:33:11 +0000)
PMIC: PFUZE100 ID=0x10
Normal Boot
Trying to boot from MMC2
D/TC:0 get_aslr_seed:1380 Warning: no ASLR seed
D/TC:0 add_phys_mem:564 TEE_SHMEM_START type NSEC_SHM 0xffe00000 size 0x00200000
D/TC:0 add_phys_mem:564 TA_RAM_START type TA_RAM 0xfe200000 size 0x01c00000
D/TC:0 add_phys_mem:564 VCORE_UNPG_RW_PA type TEE_RAM_RW 0xfe062000 size 0x0019e000
D/TC:0 add_phys_mem:564 VCORE_UNPG_RX_PA type TEE_RAM_RX 0xfe000000 size 0x00062000
D/TC:0 add_phys_mem:564 ROUNDDOWN(0x38800000, CORE_MMU_PGDIR_SIZE) type IO_SEC 0x38800000 size 0x00200000
@JamesMenetrey
JamesMenetrey / winnt.h
Created May 27, 2019 02:47
WinNT.h in Windows 10 SDK (10.0.17763.0)
/*++ BUILD Version: 0073 Increment this if a change has global effects
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
winnt.h
Abstract:
@JamesMenetrey
JamesMenetrey / bbl.cpp
Created April 17, 2019 16:15
Pin tool (binary instrumentation) - Count the number of executed basic blocks in an application
/*! @file
* The pin tool is based on the sample tool MyPinTool and has been modified
* to only count the executed basic blocks of an application.
*
* Written by Jämes Ménétrey.
*/
#include "pin.H"
#include <iostream>
@JamesMenetrey
JamesMenetrey / out.cs
Last active April 14, 2019 20:03
C# stackalloc using Span<T>; password not handled by the GC.
static void Main(string[] args)
{
// Allocate the buffer on the stack (therefore not managed by the GC)
Span<char> buffer = stackalloc char[20];
// Ask for the password
Console.Write("Type a password: ");
TypePassword(buffer, 0);
Console.WriteLine();
@JamesMenetrey
JamesMenetrey / a.c
Last active April 7, 2019 16:30
C - quick and dirty hex to double
// Use the online compiler: https://www.onlinegdb.com/online_c_compiler
#include <stdio.h>
int main()
{
char v[] = {00, 00, 0xd8, 0x0a, 0x9b, 0x5f, 0x53, 0x42};
double* d_ptr = &v;
@JamesMenetrey
JamesMenetrey / demo.go
Created April 4, 2019 00:16
Go; Direct Memory Editing
package main
import (
"fmt"
"unsafe"
)
func main() {
var i int = 66
var j int = 1234
@JamesMenetrey
JamesMenetrey / BinaryTree.scala
Last active March 10, 2019 03:20
Academic implementation of a binary tree in Scala.
// Written by Jämes Ménétrey for the lecture Advanced Programming Paradigms.
// Linear walk through inspired from https://gist.github.com/dholbrook/2967371.
import scala.annotation.tailrec
import scala.language.implicitConversions
object BinaryTreeImpl {
/**
* The contract that defines a binary tree.