Skip to content

Instantly share code, notes, and snippets.

@FWEugene
FWEugene / SwiftConcurrency.md
Created January 10, 2019 17:37
All about concurrency

Threads

Foundation offers a Thread class, internally based on pthread, that can be used to create new threads and execute closures.

// Detaches a new thread and uses the specified selector as the thread entry point.
Thread.detachNewThreadSelector(selector: Selector>, toTarget: Any, with: Any)

// Subclass
class MyThread: Thread {
@standinga
standinga / main.swift
Created November 18, 2018 00:16
Read MJPEG int CGImage using Swift4, URLSession, OSX
//
// main.swift
// MJPEGreader
//
// Created by michal on 17/11/2017.
// Copyright © 2018 michal. All rights reserved.
//
import Foundation

In this tutorial we're going to build a set of parser combinators.

What is a parser combinator?

We'll answer the above question in 2 steps.

  1. What is a parser?
  2. and, what is a parser combinator?

So first question: What is parser?

@mbinna
mbinna / effective_modern_cmake.md
Last active May 3, 2024 15:44
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

proxy_cache_path /var/nginx/cache/aws/trueniu levels=2:2:2 use_temp_path=off keys_zone=aws_3:500m inactive=30d max_size=10g;
server {
listen 80;
server_name trueniu.com www.trueniu.com;
if ( $scheme = http ) {
return 301 https://www.trueniu.com$request_uri;
}
}
@arielzn
arielzn / ssh_run.py
Last active December 12, 2017 06:40
Running commands with paramiko on remote hosts defined on ssh_config
#!/usr/bin/env python
import os
import paramiko
import argparse
import socket
import logging
def create_ssh_client(hostname):
@matejb
matejb / pipe_executor.go
Created August 10, 2017 08:27
simple Go pipe executor
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"strings"
)
@gorayni
gorayni / largest_inscribed_isothetic_rectangle.py
Created August 9, 2017 19:56
Example of computing the largest inscribed isothetic rectangle. Originally presented by H. Alt, D. Hsu, and J. Snoeyink. Computing the largest inscribed isothetic rectangle. In Proc. 7th Canadian Conf. Comput. Geom., Universit'e Laval, Qu'ebec, August 1995, pp. 67--72. Based on the code by Daniel Sud.
from __future__ import division
import numpy as np
class Edge(object):
def __init__(self, p, q):
self.xmin = np.min((p[0], q[0]))
self.xmax = np.max((p[0], q[0]))
self.ymin = np.min((p[1], q[1]))
@voluntas
voluntas / openssl_speed_aes_gcm_chacha20_poly1305.md
Last active March 29, 2024 15:09
$ openssl speed -evp aes-gcm | chacha20-poly1305 の結果を集めるスレ

$ openssl speed -evp aes-128-gcm | chacha20-poly1305 の結果を集めるスレ

AES-CBC が早いけど、AES-GCM/AES-CTR が遅かったり、Ryzen が爆速だったり、 ChaCha20-Poly1305 が ARM で早かったりするという噂の真相が知りたいです。コメントに適当にべたべた結果を貼ってください。

ちなみに Apple M2 おかしいくらい早いです。

CPU 情報はできれば詳細なのがほしいです。

OpenSSL のバージョンは 3.1 系の最新版でお願いします。