Skip to content

Instantly share code, notes, and snippets.

@StrikeW
StrikeW / cralwer_baoman.py
Created April 19, 2014 07:41
A cralwer demo
#!/usr/bin/env python
# encoding: utf-8
# a cralwer demo, crawl image of "Nao can dui hua" on http://baozoumanhua.com
import urllib2
import urllib
import re
def get_all_page_urls():
url = 'http://baozoumanhua.com/duihua/hot/page/'
@StrikeW
StrikeW / varargs.c
Created April 21, 2014 10:03
C varargs: variable-length argument list
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
double average(int i, ...);
int main(int argc, char *argv[])
{
double x = 22.5, y = 10.5, z = 13.2;
printf("x+y+z=%.2f\n", average(3, x, y, z));
@StrikeW
StrikeW / search
Created October 13, 2014 03:06
Search a file for text. Like grep, but prints a window
@StrikeW
StrikeW / backup
Created October 13, 2014 03:11
Tiny script used to backup folders
#!/bin/bash
#
# backup - Tiny script used to backup folders. This
# is an exercise for learning shell programming.
#
#
# Join elements in array
#
#!/bin/sh
##
# Install autoconf, automake and libtool smoothly on Mac OS X.
# Newer versions of these libraries are available and may work better on OS X
#
# This script is originally from http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html
#
export build=~/devtools # or wherever you'd like to build
@StrikeW
StrikeW / cppstr.cpp
Created February 17, 2017 03:19
C++ string当作buffer来使用
// 2017.2.17
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
struct yfs_dir_entry {
uint32_t inode; /* Inode number */
uint16_t rec_len; /* Directory entry length */
@StrikeW
StrikeW / getcurtime.cpp
Created February 17, 2017 03:33
Linux下获取当前时区的时间
// Linux获取当前时区的时间
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
int main(int argc, char *argv[])
{
@StrikeW
StrikeW / latency.txt
Created April 15, 2017 03:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@StrikeW
StrikeW / tmux-cheatsheet.markdown
Created July 10, 2017 11:12 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@StrikeW
StrikeW / format_st_mtime.c
Created April 20, 2014 15:25
format st_mtime which get from stat()
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
int main(int argc, char *argv[])
{
struct stat st;
char *f = "README";