Skip to content

Instantly share code, notes, and snippets.

View z4yx's full-sized avatar
☢️

Yuxiang Zhang z4yx

☢️
View GitHub Profile
@klange
klange / _.md
Last active December 2, 2023 20:36
It's a résumé, as a readable and compilable C source file. Since Hacker News got here, this has been updated to be most of my actual résumé. This isn't a serious document, just a concept to annoy people who talk about recruiting and the formats they accept résumés in. It's also relatively representative of my coding style.

Since this is on Hacker News and reddit...

  • No, I don't distribute my résumé like this. A friend of mine made a joke about me being the kind of person who would do this, so I did (the link on that page was added later). My actual résumé is a good bit crazier.
  • I apologize for the use of _t in my types. I spend a lot of time at a level where I can do that; "reserved for system libraries? I am the system libraries".
  • Since people kept complaining, I've fixed the assignments of string literals to non-const char *s.
  • My use of type * name, however, is entirely intentional.
  • If you're using an older compiler, you might have trouble with the anonymous unions and the designated initializers - I think gcc 4.4 requires some extra braces to get them working together. Anything reasonably recent should work fine. Clang and gcc (newer than 4.4, at le
/*
* linux 2.6.37-3.x.x x86_64, ~100 LOC
* gcc-4.6 -O2 semtex.c && ./a.out
* 2010 sd@fucksheep.org, salut!
*
* update may 2013:
* seems like centos 2.6.32 backported the perf bug, lol.
* jewgold to 115T6jzGrVMgQ2Nt1Wnua7Ch1EuL9WXT2g if you insist.
*/
@takeshixx
takeshixx / hb-test.py
Last active March 9, 2024 13:37
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <takeshix@adversec.com>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford (jspenguin@jspenguin.org).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
@jeamland
jeamland / gist:11284662
Created April 25, 2014 10:20
Bluetooth LE on OS X via Python
import select
import socket
import sys
import objc
from PyObjCTools import AppHelper
objc.loadBundle("CoreBluetooth", globals(),
bundle_path=objc.pathForFramework(u'/System/Library/Frameworks/IOBluetooth.framework/Versions/A/Frameworks/CoreBluetooth.framework'))
@liuyanghejerry
liuyanghejerry / gist:a309ef54580004879b40
Created May 7, 2014 12:50
在小米路由上运行Node.js

相信很多人和我一样,拿到小米路由玩了几天,感觉官方的步伐不够快不够激进。既然如此,何不自己动手丰衣足食呢?

背景知识

首先你得知道Linux的一些基本理论,比如什么是bash啊,cdls这些命令怎么用等等。

其次你还得知道一些编程相关的东西,因为文章专注于Node.js的编译,所以Node.js和C++的一些基本知识是要有的。

热身准备

@tgarc
tgarc / be8.patch
Last active July 14, 2019 07:07
Patch GCC ARM Embedded Toolchain for big-endian targets (simply git apply be8.patch in top directory)
From 9ba6f4c25c50ce80c9195c45df7fab9d1e1c8152 Mon Sep 17 00:00:00 2001
From: "tdos.apone" <toemossgarcia@gmail.com>
Date: Thu, 10 Dec 2015 11:03:09 -0600
Subject: [PATCH 1/2] initial big-endian attempt
---
build-toolchain.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/build-toolchain.sh b/build-toolchain.sh
#!/bin/bash
function load_var {
eval $(cat ${1} <( echo -e '\nset -o posix;set\n') | env - bash --noprofile --norc --posix | sed 's/^/'$2'_/')
if [ -n "$IF_IPSEC6" ]; then
PEER_ENDPOINT=$PEER_ENDPOINT6
SELF_ENDPOINT=$SELF_ENDPOINT6
fi
}
#include <stdio.h>
#include <unistd.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <linux/if_ether.h>
#include <linux/if_tun.h>
#include <assert.h>
#include <memory.h>
#include <fcntl.h>
#include <poll.h>
@geekman
geekman / myusbgadget
Created January 17, 2017 02:47
Pi Zero multiple USB gadgets minimal example
#!/bin/bash -e
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/
mkdir g && cd g
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
@bekce
bekce / README.md
Created February 21, 2017 13:36
ldap server with mysql backend

I wanted to build an LDAP server that queries a MySQL server to fetch users and check their passwords. It is mainly used for old software that does not work with custom OAuth2 providers. Redmine is an example of this.

Instructions:

  1. Create the database and table with insert.sql