Skip to content

Instantly share code, notes, and snippets.

View congzhangzh's full-sized avatar
🎯
Focusing

Cong Zhang congzhangzh

🎯
Focusing
View GitHub Profile
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#define MAX_BUF 1024
#define pipename "\\\\.\\pipe\\LogPipe"
int main()
{
HANDLE pipe = CreateFile(pipename, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
if (pipe == INVALID_HANDLE_VALUE)
@polachok
polachok / gist:ab0937985d57b0398ad8
Last active July 7, 2023 13:50
Building statically linked binaries with rust

glibc is not statically linkable (because reasons, mainly nss), so you have to link against another libc. Fortunately, rust developers made binary builds of std linked with musl libc available in beta and nightly channels. Which means that all you need is:

  • std linked with musl

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-musl.tar.gz
  • "normal" std for build scripts

    • http://static.rust-lang.org/dist/$(date -v -1d +'%Y-%m-%d')/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz
@dimitrispaxinos
dimitrispaxinos / LogEventEnricher.cs
Created November 9, 2015 21:05
Serilog: Add Context using ILogEventEnricher implementations
public class UserLogEventEnricher : ILogEventEnricher
{
private readonly IUser _user;
public UserLogEventEnricher(IUser user)
{
_user = user;
}
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
@martyngigg
martyngigg / setup.md
Created December 15, 2015 12:53
VirtualGL and NoMachine
#!/bin/bash
@oxyflour
oxyflour / ssh-vpn.sh
Last active January 15, 2024 08:41
how to setup non-root ssh vpn tunnel
# remember to add
#PermitTunnel yes
# in /etc/ssh/sshd_config
# create tun device on both machines
# ref: http://www.k336.org/2013/04/non-root-ssh-vpn.html
sudo ip tuntap add dev tun0 mode tun user oxyflour group oxyflour
# delete tun
sudo ip tuntap del dev tun0 mode tun
julia> c=b.args[2]^C
julia> c = Condition()
@Condition(Any[])
julia> @as^C
julia> @async begin
wait(c)
println("im notifyed")
#include <stdio.h>
#include <stdlib.h>
#include <poll.h>
#include <uv.h>
static void on_close(uv_handle_t* handle);
static void on_connect(uv_connect_t* req, int status);
static void on_write(uv_write_t* req, int status);
static void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf)
@jkullick
jkullick / openport-knock-ssh-necat.md
Created September 8, 2016 12:47
Open Port Knock Guarded SSH Port with Netcat
for PORT in $PORT1 $PORT2 $PORT3; do nc -vz $SSH_HOST $PORT; done; ssh $SSH_USER@SSH_HOST
@UnaNancyOwen
UnaNancyOwen / CMakeLists.txt
Last active June 12, 2024 00:21
CMakeLists for OpenCV that installed using Vcpkg
cmake_minimum_required( VERSION 3.0 )
set( CMAKE_TOOLCHAIN_FILE "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" )
# Create Project
project( solution )
add_executable( project main.cpp )
# Set OpenCVConfig.cmake Search Directory
set( OpenCV_DIR )
if( NOT CMAKE_CL_64 )
@dcode
dcode / GitHub Flavored Asciidoc (GFA).adoc
Last active March 22, 2026 05:44
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)