This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # | |
| # Copy stdin to the host clipboard using OSC 52. | |
| # | |
| # Examples: | |
| # cat file.txt | osc52 | |
| # printf 'hello\n' | osc52 | |
| # osc52 "hello world" | |
| # | |
| # For tmux: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; z3 supports two types of syntax for declare-datatypes -- z3's own one and smt-lib 2.6 one | |
| ; smt-lib 2.6 syntax | |
| (declare-datatypes ( | |
| (Pair 2) ; datatype | |
| ) | |
| ( | |
| (par (T1 T2) ( | |
| (nil) ; constructor 1 | |
| (mk-pair (first T1) (second T2)) ; constructor 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; https://github.com/llvm/llvm-project/pull/120352/ | |
| (define-sort I8 () (_ BitVec 8)) | |
| (define-fun extract-msb ((x I8)) Int ((_ bv2int 1) ((_ extract 7 7) x))) | |
| (define-fun-rec cl1 ((x I8)) Int (ite (= #x00 x) 0 (ite (= 0 (extract-msb x)) 0 (+ 1 (cl1 (bvshl x #x01)))))) | |
| ; (assert (= (cl1 #x00) 0)) | |
| ; (assert (= (cl1 #x01) 0)) | |
| ; (assert (= (cl1 #x82) 1)) | |
| ; (assert (= (cl1 #xc1) 2)) | |
| ; (assert (= (cl1 #xf7) 4)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef unsigned short ushort1024 __attribute__((ext_vector_type(1024))); | |
| typedef unsigned int uint64 __attribute__((ext_vector_type(64))); | |
| // ushort1024 __attribute__((overloadable)) foo(ushort1024 data, uint64 value, uint64 vec_mask){return (ushort1024) (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void insertPrint(BasicBlock *BB, StringRef S) { | |
| Module *M = BB->getModule(); | |
| LLVMContext &Ctx = M->getContext(); | |
| auto *CharPointerTy = PointerType::get(IntegerType::getInt8Ty(Ctx), 0); | |
| auto *PrintfTy = | |
| FunctionType::get(IntegerType::getInt32Ty(Ctx), {CharPointerTy}, true); | |
| auto Printf = M->getOrInsertFunction("printf", PrintfTy); | |
| auto Arr = ConstantDataArray::getString(Ctx, S); | |
| GlobalVariable *GV = new GlobalVariable( | |
| *M, Arr->getType(), true, GlobalValue::PrivateLinkage, Arr, ".str"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <algorithm> | |
| #include <cstring> | |
| #include <memory> | |
| class MyString { | |
| public: | |
| // Common constructor | |
| MyString(const char * str) : | |
| _len(strlen(str)) |
NewerOlder