Skip to content

Instantly share code, notes, and snippets.

@Jxck
Jxck / dtls_api.md
Created May 24, 2016 08:21
OpenSSL DTLS API

OpenSSL DTLS API

The API used for DTLS is mostly the same as for TLS, because of the mapping of generic functions to protocol specifc ones. Some additional functions are still necessary, because of the new BIO objects and the timer handling for handshake messages. The generic concept of the API is described in the following sections. Examples of applications using DTLS are available at [9].

DTLS の API は TLS とほぼ同じ。 BIO オブジェクトの生成とタイマのために追加でいくつか必要。

@hngouveia01
hngouveia01 / debugging_kernel.txt
Last active June 6, 2024 21:11
Debugging kernel code line by line with Qemu and GDB
We are going to use buildroot to download, configure and compile the kernel.
First, download and uncompress buildroot: https://buildroot.org/download.html
Go to the directory and:
make qemu_x86_defconfig
make menuconfig
@integeruser
integeruser / s-rand.py
Last active September 24, 2023 14:09
Python port of the GLIBC rng
#!/usr/bin/env python2
from ctypes import c_int, c_uint
# http://www.mscs.dal.ca/~selinger/random/
def srand(seed):
srand.r = [0 for _ in range(34)]
srand.r[0] = c_int(seed).value
for i in range(1, 31):
@ForeverZer0
ForeverZer0 / ReshapeWindow.cs
Last active November 5, 2022 17:12
[C#][OpenGL] Maintain aspect ratio when resizing window
/// <summary>
/// Reshapes the drawing are to maintain aspect ratio when the window is resized,
/// using a target pixel ratio to maintain, and applying "pillars" or "letterbox"
/// effect as needed, allowing the drawing context to shrink/grow uniformly.
/// </summary>
/// <param name="width">The new width of the window/drawing area to fit to.</param>
/// <param name="height">The new height of the window/drawing area to fit to.</param>
public void WindowReshape(int width, int height)
{
// Make the projection matrix active
@trevershick
trevershick / CMakeLists.txt
Last active November 21, 2023 06:54
Simple client and server using libuv and unix domain sockets...
set(CMAKE_BUILD_TYPE Debug)
cmake_minimum_required(VERSION 2.8.12)
project(libuv1)
add_definitions("-std=c++11")
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(server server.cpp)
@conwid
conwid / IniFormatter.cs
Last active May 16, 2023 14:37
More complete IFormatter implementation reference for students preparing for MS 70-483
public class IniFormatter : IFormatter
{
public class IniTypeBinder : SerializationBinder
{
public override Type BindToType(string assemblyName, string typeName) => Type.GetType(typeName.Split('=')[1]);
public override void BindToName(Type serializedType, out string assemblyName, out string typeName)
{
assemblyName = $"{IniFormatter.AssemblyNameKey}={serializedType.Assembly.FullName}";
typeName = $"{IniFormatter.ClassNameKey}={serializedType.AssemblyQualifiedName}";
}
@astarasikov
astarasikov / convert_teegris_tas.py
Last active April 19, 2024 20:53
Exynos9820 TEEGRIS TZAR unpack script
#!/usr/bin/env python3
# Usage: python convert_teegris_tas.py ~/Downloads/sw/pda/s10/fw/fw_G973FXXU4BTA8/AP/vendor/tee/
import os
import sys
from textwrap import wrap
def teegris_ta_to_elf(path_from, path_to):
with open(path_from, 'rb') as fin:
with open(path_to, 'wb') as fout:
@sekkr1
sekkr1 / android_gdb.md
Created August 12, 2019 15:27
Attaching GDB to Android apps' native libraries

How to GDB android native libraries

[1] Install NDK from android studio

[2] Push appropriate gdb-server to phone

adb push ~/android-sdk-linux/ndk-bundle/prebuilt/android-<arch>/gdbserver/gdbserver /data/local/tmp
adb shell "chmod 777 /data/local/tmp/gdbserver"
adb shell "ls -l /data/local/tmp/gdbserver"

[4] Forward ports

adb forward tcp:1337 tcp:1337

@zavan
zavan / yt.js
Last active July 8, 2024 08:20
Listening to the YouTube Embed Iframe time change events without polling player.getCurrentTime()
// Load the IFrame Player API code asynchronously.
var tag = document.createElement("script");
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName("script")[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Instantiate the Player.
function onYouTubeIframeAPIReady() {
var player = new YT.Player("player", {
commit ec046ffc2b8b9ed6916e402ee580e18da6673709
Author: Keno Fischer <keno@juliacomputing.com>
Date: Sun Jul 3 01:53:53 2022 +0000
WIP: AMD CPUID override
Since e9ea1e7, we've had the ability to turn a userspace `cpuid`
instruction into a SIGSEGV using the ARCH_(GET|SET)_CPUID arch_prctl.
However, this capability is limited to supported hardware, which
currently means Intel CPUs. AMD CPUs do not have a documented facility