Skip to content

Instantly share code, notes, and snippets.

kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@darrenjs
darrenjs / ssl_server_nonblock.c
Last active March 22, 2024 08:34
OpenSSL example using memory BIO with non-blocking socket IO
/*
This file had now been added to the git repo
https://github.com/darrenjs/openssl_examples
... which also includes a non blocking client example.
-------------------------------------------------------------------------------
ssl_server_nonblock.c -- Copyright 2017 Darren Smith -- MIT license
@utilForever
utilForever / SimpleReflection.cpp
Created August 25, 2016 01:54
Simple reflection on C++17 [Very simple approach to convert any struct (up to N members) to a tuple using C++17 structured bindings and the idea from Boost.DI]
#include <tuple>
#include <type_traits>
#include <cassert>
template <class T, class... TArgs> decltype(void(T{std::declval<TArgs>()...}), std::true_type{}) test_is_braces_constructible(int);
template <class, class...> std::false_type test_is_braces_constructible(...);
template <class T, class... TArgs> using is_braces_constructible = decltype(test_is_braces_constructible<T, TArgs...>(0));
struct any_type {
template<class T>
@irbull
irbull / OpenSSLExample.cpp
Created August 11, 2016 18:32
Code signing and verification with OpenSSL
#include <iostream>
#include <openssl/aes.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <assert.h>
@kaedea
kaedea / MediaCodecInfoTest.java
Created July 27, 2016 08:12
get MediaCodecInfo
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void testMediaCodecInfo() {
// list media codec
int numCodec = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodec; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
Log.i(TAG, "[kaede][testMediaCodecInfo]" +
"=================================== " + codecInfo.getName() + " ===================================");
boolean isEncoder = codecInfo.isEncoder();
Log.d(TAG, "isEncoder = " + isEncoder);
@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 オブジェクトの生成とタイマのために追加でいくつか必要。

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString

青空文庫テキストファイル用Shift_JISとUnicodeとの変換定義(私案)

本文書は、青空文庫で配布されているテキストファイルをUnicodeに変換する規則、またUnicodeで入力されたテキストファイルを青空文庫テキストファイル用のShift_JISのファイルに変換する規則を提案する。

動機

青空文庫テキストファイルはJIS X 0208のShift_JISで記述されているが、Unicodeに相互変換したいというニーズがある。

  • UTF-8で入力・出力したい
  • UTF-8に対応したツールを使いたい
@voluntas
voluntas / firefox_simulcast.md
Last active April 6, 2024 12:00
Firefox の Simulcast 実装について

Firefox の Simulcast 実装について

こちらの資料は古いので WebRTC Simulcast コトハジメ をどうぞ。

Simulcast とは

WebRTC の Simulcast という仕組みは、複数の品質で映像を配信する仕組みのことです。

P2P で必要かどうかというと、必要ではありません。Simulcast はクライアント・サーバモデル、さらに SFU モデルでの利用を前提としています。

@caojianhua
caojianhua / OpenGLToCVPixelBuffer.m
Created January 27, 2016 09:29
Create CVPixelBufferRef from OpenGL
@interface SREAGLContext : NSObject
+ (EAGLContext*)sharedContext;
+ (EAGLContext*)newContext: (EAGLRenderingAPI) api;
@end
@implementation SREAGLContext