Skip to content

Instantly share code, notes, and snippets.

View daoleno's full-sized avatar
🤘
rock & roll

daoleno daoleno

🤘
rock & roll
View GitHub Profile
@daoleno
daoleno / 递推 贪心 搜索 DP
Last active September 24, 2016 11:09
状态传递
每个阶段只有一个状态->递推;
每个阶段的最优状态都是由上一个阶段的最优状态得到的->贪心;
每个阶段的最优状态是由之前所有阶段的状态的组合得到的->搜索;
每个阶段的最优状态可以从之前某个阶段的某个或某些状态直接得到而不管之前这个状态是如何得到的->动态规划。
@daoleno
daoleno / extern "C" 的作用.md
Created December 11, 2017 07:35
mix C and C++

To ensure that the names declared in that portion of code have C linkage, and thus C++ name mangling is not performed

#ifdef __cplusplus
extern "C" {
#endif

void *memset (void *, int, size_t);
char *strcat (char *, const char *);
int   strcmp (const char *, const char *);
char *strcpy (char *, const char *);
@daoleno
daoleno / meaningfulConst.md
Last active December 25, 2017 06:45
Meaningful const in Function Declarations
void F(int);                     // 1: declaration of F(int)
void F(const int);               // 2: re-declaration of F(int)
void F(int) { /* ... */ }        // 3: definition of F(int)
void F(const int) { /* ... */ }  // 4: error: re-definition of F(int)
void F(const int* x);                  // 1
void F(const int& x); // 2
@daoleno
daoleno / python_repr_vs_str.md
Last active January 4, 2018 12:08
[python] repr vs str
@daoleno
daoleno / 代理设置.md
Last active January 8, 2018 11:51
虚拟机内爬墙
  1. 虚拟机网络为 NAT 模式
  2. 将虚拟机内代理设置成主机IP,端口为shadowsocks端口(1080)
  3. shadowsocks 选中 允许来自局域网的链接
@daoleno
daoleno / book_list.md
Last active February 17, 2020 01:40
book list
@daoleno
daoleno / hanoi.ml
Created January 11, 2018 11:29
OCaml version hanoi tower
(* move n discs from a to z (using third peg named x) *)
let rec hanoi move n a z x = if n = 0 then () else
(hanoi move (n-1) a x z ; move n a z ; hanoi move (n-1) x z a)
let printmove disc a b = print_endline
("Move disc " ^ (string_of_int disc) ^ " from " ^ a ^ " to " ^ b) ;;
hanoi printmove 4 "peg A" "peg C" "peg B"
@daoleno
daoleno / struct_tips_in_c.md
Created January 15, 2018 06:52
struct tips in c
typedef struct X { 
    int x; 
} X;

struct S { 
    int x; 
};
typedef struct S S;
@daoleno
daoleno / server_client.md
Created February 4, 2018 15:55
strace and nc

Server

strace -r -e trace=bind,listen,accept,poll,read,write nc -l -p 8080 

Client

strace -r -e trace=connect,poll,read,write,close nc 127.0.0.1 8080
@daoleno
daoleno / vm.md
Created March 5, 2018 03:14
What should a virtual machine generally implement?
  • Compilation of source language into VM specific bytecode
  • Data structures to contains instructions and operands (the data the instructions process)
  • A call stack for function call operations
  • An ‘Instruction Pointer’ (IP) pointing to the next instruction to execute
  • A virtual ‘CPU’ – the instruction dispatcher that
    • Fetches the next instruction (addressed by the instruction pointer)
    • Decodes the operands
  • Executes the instruction