Skip to content

Instantly share code, notes, and snippets.

@nayato
nayato / ClientProgram.cs
Created March 1, 2015 07:36
Loss of messages when receiving in Helios client. press any key during run in client program to see current messages pending for receipt from server. Press Enter in server program to see number of processed messages.
namespace Helios.Samples.LossClient
{
using System;
using System.Diagnostics;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Helios.Net.Bootstrap;
using Helios.Topology;
@nayato
nayato / ReadOnlyListView.cs
Created July 22, 2016 18:58
Read-Only List View
[Serializable]
[DebuggerDisplay("Count = {Count}")]
public struct ReadOnlyListView<T> : IReadOnlyList<T>
{
static readonly List<T> EmptyList = new List<T>();
public static ReadOnlyListView<T> Empty => new ReadOnlyListView<T>(EmptyList);
readonly List<T> list;
internal class Program
{
private static void Main(string[] args)
{
var s = new Mock<Stream>();
s.SetupGet(x => x.CanWrite).Returns(true);
s.Setup(x => x.Write(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>()))
.Callback((byte[] buf, int ofs, int cnt) => Console.WriteLine(
$"under : len: {cnt} content:" + Environment.NewLine + ByteBufferUtil.PrettyHexDump(Unpooled
.WrappedBuffer(buf, ofs, cnt).Slice(0, Math.Min(cnt, 10)))));
under : len: 10 content:
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|100000000| 1F 8B 08 00 00 00 00 00 04 00 |.......... |
+--------+-------------------------------------------------+----------------+
under : len: 8192 content:
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
@nayato
nayato / Howto convert a PFX to a seperate .key & .crt file
Created July 1, 2017 09:13 — forked from TemporaryJam/Howto convert a PFX to a seperate .key & .crt file
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
@nayato
nayato / tools.md
Created July 14, 2017 00:45 — forked from nrc/tools.md
Rust tooling

Rust developer tools - status and strategy

Availability and quality of developer tools are an important factor in the success of a programming language. C/C++ has remained dominant in the systems space in part because of the huge number of tools tailored to these lanaguages. Succesful modern languages have had excellent tool support (Java in particular, Scala, Javascript, etc.). Finally, LLVM has been successful in part because it is much easier to extend than GCC. So far, Rust has done pretty well with developer tools, we have a compiler which produces good quality code in reasonable time, good support for debug symbols which lets us leverage C++/lanaguge agnostic tools such as debuggers, profilers, etc., there are also syntax highlighting, cross-reference, code completion, and documentation tools.

In this document I want to layout what Rust tools exist and where to find them, highlight opportunities for tool developement in the short and long term, and start a discussion about where to focus our time an

@nayato
nayato / sasl-expanded.rs
Created September 18, 2017 18:04
SASL exchange in rust-amqp1 expanded
#![feature(prelude_import)]
#![no_std]
#![feature(proc_macro, conservative_impl_trait, generators)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
extern crate amqp1 as amqp;
extern crate futures_await as futures;
extern crate tokio_io;
@nayato
nayato / erasure.rs
Created October 12, 2017 20:09 — forked from anonymous/playground.rs
Rust code shared from the playground
fn main() {
let a = Test(None);
a.print();
let b = Test(Some(23));//Box::new(Test(Some(23)));
b.print();
print_it(&b);
}
struct Test (Option<i32>);