Skip to content

Instantly share code, notes, and snippets.

View w32zhong's full-sized avatar
⛹️
Trying to keep up.

Wei w32zhong

⛹️
Trying to keep up.
View GitHub Profile
@sodabrew
sodabrew / gist:2655193
Created May 10, 2012 19:10
libevent HTTP server client IP address
void http_request_cb(struct evhttp_request *req, void *user)
{
char *client_ip;
u_short client_port;
evhttp_connection_get_peer(evhttp_request_get_connection(req), &client_ip, &client_port);
printf("Client IP [%s] port [%d]\n", client_ip, client_port);
}
@irachex
irachex / Treap.py
Created October 20, 2012 08:43
Treap (tree + heap) in Python
import random
class TreapNode(object):
def __init__(self, key, data):
self.key = key
self.ran = random.random()
self.size = 1
self.cnt = 1
self.data = data
self.left = None
@hariadi
hariadi / httpd-git.conf
Created August 20, 2013 23:46
Apache > 2.4 Git Config
<VirtualHost *:80>
# Configure hostname
ServerAdmin postmaster@jpa.gov.my
ServerName git.jpa.gov.my
# Repository location
DocumentRoot /data/www/jpa.gov.my/git
# Deny to access
<Files ~ "(^\.htaccess|^.*\.conf)">
@laughinghan
laughinghan / MathSON.md
Last active December 7, 2023 21:52
MathSON - JSON for Math Formulae

MathSON

Status: Draft 1 In Progress. This document is undergoing its first revision. Initial implementation has begun alongside editing Draft 1. Your feedback is hoped and dreamed of.

Mathematical Structured Object Notation is a JSON-based representation for most of the common subset of what LaTeX and Presentation MathML can

#include "var.h"
#include <stdio.h>
#define hello1(s) hello2(s, "default string")
void hello2(const char *s, const char* s2) {
printf("hello2 %s and %s\n", s, s2);
}
#define hello(...) xglue(hello, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
Things in C/C++ that are hard to parse
======================================
Type names
----------
C is "mostly" LL(1) and generally relatively straightforward to parse. The primary
unncessary complication is that parsing C requires keeping a symbol table during
parsing that knows whether a given identifier in the current scope refers to a type
name or not. Take this example snippet:
@iampaul83
iampaul83 / ssh-copy-id-script.md
Last active November 16, 2022 07:32
ssh-copy-id script

目標

  1. 實現ssh免打密碼登入
  2. 自動化上面的過程
    • 因為要實現免打密碼登入,一開始還是要打一次密碼

NOTE: 以下的範例都是在macOS10.12中執行,不同OS或版本可能會有出入

@adrianwong
adrianwong / mathjax-responsive-scaling.html
Last active December 6, 2019 23:08
Responsive scaling of MathJax formulae
<script type="text/javascript">
window.MathJax = {
jax: ["input/TeX", "output/CommonHTML"],
extensions: ["tex2jax.js"],
TeX: {
equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]
},
/* The MathJax API provides us with the ability to register
callbacks on signals broadcast during its startup sequence.
@ErikAugust
ErikAugust / spectre.c
Last active July 5, 2024 18:14
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@albertomolina
albertomolina / iSCSI_cheatsheet.md
Last active June 16, 2024 23:59
iSCSI cheatsheet

iSCSI server with tgt

apt install tgt

Manual configuration of targets

Create a new target named "target1":

tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2020-01.es.tinaja:target1

Delete a specific target: