Skip to content

Instantly share code, notes, and snippets.

@sunxu
sunxu / 250.csv
Created January 13, 2023 14:26 — forked from jinjier/javdb-top250.md
JavDB Top 250 movies code list. [Updated at 2022/09]
1 LAFBD-41
2 SSNI-497
3 IPX-177
4 ABP-984
5 SSIS-465
6 IPX-580
7 IPX-811
8 SMBD-115
9 IPX-534
10 IPX-726
@sunxu
sunxu / aggregator.lua
Last active August 29, 2015 14:20 — forked from kidd/aggregator.lua
local path = ngx.var.request:split(" ")[2] -- path
local t={}
local cjson = require "cjson"
local m = ngx.re.match(path,[=[^/sentence/(.+)]=])
local words = m[1]:split("%%20") -- words in the sentence
for i,k in pairs(words) do
local res_word = ngx.location.capture("/real/".. k )
local value=cjson.new().decode(res_word.body)
table.insert(t, value.sentiment)

Latency numbers every programmer should know

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

" neocomplcache
" http://github.com/Shougo/neocomplcache
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_max_list = 100
let g:neocomplcache_max_keyword_width = 50
let g:neocomplcache_max_filename_width = 15
let g:neocomplcache_auto_completion_start_length = 2
@sunxu
sunxu / main.c
Created November 29, 2012 13:06
#答问题,赢牛书# 设计一个队列,在满足“先进先出”的特点,同时还能在O(1)时间得到队列的最大值。 http://e.weibo.com/1665356464/z7fnGxAbF
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
typedef struct _node{
int data;
struct _node* next;
struct _node* max;
} Node, *pNode;
@sunxu
sunxu / main.c
Created November 29, 2012 13:03
#答问题,赢牛书# 输入一个数组,判断是否存在一个或若干个数字,他们的和为0。 如输入数组[1,2,3,4],则输出False; 如输入数组[1,2,-3,4],则输出True。 http://e.weibo.com/1665356464/z7fnGxAbF
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
//链表节点,链表头结点不存储数据
typedef struct _node{
int data;
struct _node * next;
} node;
@sunxu
sunxu / minsubstr.c
Created November 15, 2012 06:04
@陈利人 从一个长字符串中查找包含给定字符集合的最短子串。例如,长串为“aaaaaaaaaacbebbbbbdddddddcccccc”,字符集为{abcd},那么最短子串是“acbebbbbbd”。如果将条件改为“包含且只包含给定字符集合”,你的算法和实现又将如何改动。
//
// minsubstr.c
// Test
//
// Created by 孙 旭 on 12-11-15.
// Copyright (c) 2012年 孙 旭. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>