Install Python
$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...
# | |
# script to register Python 2.0 or later for use with win32all | |
# and other extensions that require Python registry settings | |
# written by Joakim Loew for Secret Labs AB / PythonWare | |
# | |
# source: | |
# http://www.pythonware.com/products/works/articles/regpy20.htm | |
# | |
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/[email protected]/msg10512.html | |
Install Python
$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...
#include <stdlib.h> | |
#define SIZE 1024 | |
static int (**hnew())[2] { | |
return calloc(sizeof(int**), SIZE); | |
} | |
static void hdel(int (**e)[2]) { | |
for (int i = 0; i < SIZE; i++) free(e[i]); free(e); | |
} | |
static int (**hget(int (**t)[2], int k))[2] { | |
for (int h = k & (SIZE - 1); **t && ***t != k; h = ((h + 1) & (SIZE - 1)), t += h); |
/* fileman.c -- A tiny application which demonstrates how to use the | |
GNU Readline library. This application interactively allows users | |
to manipulate files and their modes. */ | |
#ifdef HAVE_CONFIG_H | |
# include <config.h> | |
#endif | |
#include <sys/types.h> |
I wanted to be really able to explain to a fair amount of detail how does the program :command:`ls` actually work right from the moment you type the command name and hit ENTER. What goes on in user space and and in kernel space? This is my attempt and what I have learned so far on Linux (Fedora 19, 3.x kernel).
How does the shell find the location of 'ls' ?
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
##问题
给定两个有序的数组 A 和 B,它们任意的两个数之和组成一个包含 N^2 个元素的数组,找出该数组中最小的 k 个数。
##解法
如果直接对这个新的数组进行排序,即使使用较快的快排或堆排序,总的时间复杂度为 N^2 * log(N^2) * k = 2 * k * N^2 * log(N)
。
那么有什么更高效的解法吗?
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/syscall.h> | |
#include <errno.h> | |
int main() | |
{ | |
long rc; | |
char *file_name = "/etc/passwd"; |