Skip to content

Instantly share code, notes, and snippets.

View zhangyuchi's full-sized avatar

Terrell Franzman zhangyuchi

View GitHub Profile
package main
import (
"encoding/json"
"fmt"
"log"
"github.com/graphql-go/graphql"
)
@zhangyuchi
zhangyuchi / futures03_async_await.md
Created September 5, 2019 07:04 — forked from bmwill/futures03_async_await.md
Futures 0.3 and Async/Await

OUTDATED

Futures 0.3 and Async/Await

This document will try to give a short tutorial of how to use the new style futures (0.3), how to use Async/Await, and how to use the compatibility layer to interoperate with old futures (0.1) and tokio.

Terminology

When dealing with futures in this new world there are a lot of different parts and it can be difficult to keep things straight at times. As such here is a quick run down of the different parts and what they are.

@zhangyuchi
zhangyuchi / effective_modern_cmake.md
Created March 22, 2019 02:59 — forked from mbinna/effective_modern_cmake.md
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

@zhangyuchi
zhangyuchi / centos7ksiso.md
Created December 7, 2017 07:06 — forked from abrahamrhoffman/centos7ksiso.md
CentOS 7 Kickstart File & How to build an (auto install) ISO

CentOS 7 Kickstart File - HOWTO Build ISO

There is so much documentation online from RedHat and CentOS about this topic - it's sad that I am writing this. But the real state of documentation on this topic (CentOS 7 + KS + ISO = Bootable DVD) is almost non-existent.

I found this: http://smorgasbork.com/component/content/article/35-linux/151-building-a-custom-centos-7-kickstart-disc-part-1

Which I greatly appreciate and +1, but the documentation is half-baked and there are numerous errors.

Finally... FINALLY! After four days of banging my head, I got this to work. Hopefully someone else will be able to do this in a few hours, instead of blowing their weekend like me. :(

@zhangyuchi
zhangyuchi / openssl-ecc.c
Last active June 30, 2017 09:53 — forked from louismullie/openssl-ecc.m
OpenSSL ECC encrypt/decrypt
secure_t * ecies_encrypt(char *key, unsigned char *data, size_t length) {
void *body;
HMAC_CTX hmac;
int body_length;
secure_t *cryptex;
EVP_CIPHER_CTX cipher;
unsigned int mac_length;
EC_KEY *user, *ephemeral;
size_t envelope_length, block_length, key_length;
@zhangyuchi
zhangyuchi / memusg
Created June 14, 2017 04:07 — forked from netj/memusg
memusg -- Measure memory usage of processes
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
@zhangyuchi
zhangyuchi / memcpy.c
Created June 8, 2017 04:36 — forked from nicky-zs/memcpy.c
One way to solve the glibc compatibility problem. In my case, when building a program with libthrift.a on linux with glibc version 2.15, ld always links memcpy@GLIBC_2.14 which cannot be found on systems with glibc version < 2.14. So, use this file to define a symbol __wrap_memcpy and use -Wl,--wrap=memcpy to tell ld using this symbol when meeti…
#include <string.h>
void *__memcpy_glibc_2_2_5(void *, const void *, size_t);
asm(".symver __memcpy_glibc_2_2_5, memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n)
{
return __memcpy_glibc_2_2_5(dest, src, n);
}
@zhangyuchi
zhangyuchi / golang-tls.md
Created March 15, 2017 08:15 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
openssl ecparam -genkey -name secp384r1 -out server.key
@zhangyuchi
zhangyuchi / 0_reuse_code.js
Created May 3, 2016 07:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@zhangyuchi
zhangyuchi / sort1mb.cpp
Last active August 29, 2015 14:13 — forked from preshing/sort1mb.cpp
Sort one million 8-digit numbers in 1MB RAM, with statistics
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------