Skip to content

Instantly share code, notes, and snippets.

@run
run / get.c
Created September 6, 2018 06:12 — forked from garcia556/get.c
POSIX shared memory IPC example (shm_open, mmap), working on Linux and macOS
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define STORAGE_ID "/SHM_TEST"
#define STORAGE_SIZE 32
int main(int argc, char *argv[])
@run
run / nginx.conf
Created November 21, 2016 17:20 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@run
run / semtex.c
Last active October 16, 2016 03:31 — forked from onemouth/semtex.c
/*
* 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.
*/
@run
run / project.md
Created September 24, 2016 01:29

有了这个列表,程序员不愁没练手的小项目了

初衷

这个列表原本首发在伯乐在线的一篇译文:http://blog.jobbole.com/49762/。2016年9月21日,该文章推送到微信公众号 程序员的那些事 (ID: iProgrammer ) 后,@BleethNie 留言建议把这 120+ 练手小项目统一放在一个地方,同时其他人可以把自己完成项目提交合并到一起,相互参考学习。于是我们在 GitHub 创建了这个项目。后续会以超链的形式合并大家提交的成果到这个列表。欢迎 fork & star,并扩散给更多人。

下面列出 120 多个项目构思,根据主题分成了 10 个分类。

文本操作

@run
run / ipv6.c
Last active October 29, 2015 16:41
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <arpa/inet.h>
typedef uint32_t ipv4_addr_t;
typedef struct ipv6_addr_s ipv6_addr_t;
typedef union ipx_addr_s ipx_addr_t;
@run
run / pcap.py
Created September 22, 2015 04:56
#!/usr/bin/python
import os, sys, struct
f = open('./blog.pcap').read()
total = len(f)
index = 0;
magic = f[index:index+4].encode('hex')
# pcap file is generated in my pc, which is little endian
@run
run / head.c
Created September 21, 2015 04:27
typedef struct pcaprec_hdr_s {
guint32 ts_sec; /* timestamp seconds */
guint32 ts_usec; /* timestamp microseconds */
guint32 incl_len; /* number of octets of packet saved in file */
guint32 orig_len; /* actual length of packet */
} pcaprec_hdr_t;
@run
run / pcap.c
Created September 21, 2015 03:05
typedef struct pcap_hdr_s {
guint32 magic_number; /* magic number */
guint16 version_major; /* major version number */
guint16 version_minor; /* minor version number */
gint32 thiszone; /* GMT to local correction */
guint32 sigfigs; /* accuracy of timestamps */
guint32 snaplen; /* max length of captured packets, in octets */
guint32 network; /* data link type */
} pcap_hdr_t;
@run
run / user.c
Created February 19, 2015 06:22
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#define PAGE_SIZE (4 * 1024)
#define KERNEL_PHY_ADDR 0x77128000
int main()
@run
run / Restore IP Addresses.cpp
Created October 28, 2014 02:50
Restore IP Addresses
class Solution {
public:
vector<string> restoreIpAddresses(string s) {
vector<string> tmp;
vector<string> result;
if (s.size() < 4 && s.size() > 12) {
return result;
}