Skip to content

Instantly share code, notes, and snippets.

@zsrkmyn
zsrkmyn / readfile.c
Created Aug 22, 2019
A simple read file function for x86_64 Linux implemented in asm
View readfile.c
#include <sys/syscall.h>
#include <stddef.h>
#include <fcntl.h>
int readfile(const char *file, char *buf, size_t size)
{
int ret;
asm (
"mov %[mode], %%rsi \n\t"
"mov %[open], %%rax \n\t"
View dcl.c
/*
* My 'dcl' implementation of <the C programming language> chap 5.12.
* Slightly different from the given implementation.
*
* Using left recursion elimination to expand 'dirdcl':
* dcl -> optional *'s dirdcl
* dirdcl -> name
* | (dcl)
* | dirdcl()
* | dirdcl[optional size]
@zsrkmyn
zsrkmyn / vibinding.py
Created Jul 31, 2017
Dvorak Vi bindings for IPython
View vibinding.py
# put this file in ~/.ipython/profile_default/startup
# d,h,t,n for move in ViNavigationMode and ViSelectionMode
# jj to kill a line
# jf/F<char> to kill until meeting <char>
from prompt_toolkit.filters.cli import ViNavigationMode, ViSelectionMode, ViMode
from prompt_toolkit.filters import Always, IsReadOnly
from IPython import get_ipython
from prompt_toolkit.key_binding.bindings.vi import create_operator_decorator, create_text_object_decorator, TextObject
from prompt_toolkit.document import Document
from prompt_toolkit.buffer import ClipboardData
@zsrkmyn
zsrkmyn / debian-mips.txt
Created Jan 19, 2016
用qemu搭建一个debian-mips环境
View debian-mips.txt
1. 下载镜像 https://people.debian.org/~aurel32/qemu/mips{,el}/ ; mips 为大端,mipsel 为小端
2. 设置宿主机网络
```bash
#$ cat network_setup
sudo ip link add qbr0 type bridge
sudo ip addr add 172.20.0.1/16 dev qbr0
sudo ip link set qbr0 up
# sudo dnsmasq -C dnsmasq.conf # for dynamic ip support
```
@zsrkmyn
zsrkmyn / Rvalue_ref.cpp
Last active Aug 29, 2015
C++ 学习笔记
View Rvalue_ref.cpp
#include <iostream>
#include <algorithm>
#include <cstring>
#include <memory>
class MyString {
public:
// Common constructor
MyString(const char * str) :
_len(strlen(str))
View keybase.md

Keybase proof

I hereby claim:

  • I am zsrkmyn on github.
  • I am zsrkmyn (https://keybase.io/zsrkmyn) on keybase.
  • I have a public key whose fingerprint is 0285 FB69 00D1 0203 0550 F20A 3490 8FFB C0BF AC35

To claim this, I am signing this object: