Skip to content

Instantly share code, notes, and snippets.

View yangsheng1107's full-sized avatar

yangsheng1107

View GitHub Profile
# Run the last command as root
sudo !!
# Serve current directory tree at http://$HOSTNAME:8000/
python -m SimpleHTTPServer
# Save a file you edited in vim without the needed permissions
:w !sudo tee %
# change to the previous working directory
cd -
# Runs previous command but replacing
^foo^bar
@yangsheng1107
yangsheng1107 / route_dump.c
Created June 14, 2017 15:41 — forked from cl4u2/route_dump.c
Linux route monitoring example
/*
iflist.c : retrieve network interface information thru netlink sockets
(c) Jean Lorchat @ Internet Initiative Japan - Innovation Institute
v1.0 : initial version - Feb 19th 2010
This file was obtained at the following address :
http://www.iijlab.net/~jean/iflist.c
@yangsheng1107
yangsheng1107 / twseStock.py
Created March 15, 2016 14:23
TWSE stock with python
#!/usr/bin/env python
#-------------------------------------------------------------------------------
# Name: Get Stock Quote from TWSE
# Purpose:
#
# Author: yangsheng
#
# Created: 03/15/2016
# Copyright: (c) yangsheng 2015
# Licence: <your licence>
@yangsheng1107
yangsheng1107 / Taiwan live streaming
Last active February 28, 2016 13:46
透過 python 來看 youtube live streaming
# mac 安裝方式
```bash
# brew install youtube-dl
# brew cask install mpv
```
@yangsheng1107
yangsheng1107 / mmap.c
Created December 25, 2015 05:56
sample to use posix shared memory
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/mman.h>
// http://man7.org/tlpi/code/online/dist/mmap/anon_mmap.c
//#define USE_MAP_ANON
//#define USE_MAP_SHARED_WITH_OPEN
@yangsheng1107
yangsheng1107 / uncrustify.cfg
Created December 25, 2015 05:49
config file for uncrustify
#
# 'add' vs. 'force'
# cf. http://sourceforge.net/projects/uncrustify/forums/forum/511737/topic/3066522?message=6693806
#
# Uncrustify 0.60
#
# General options
#
#!/bin/bash
function loop() {
## Do nothing if * doesn't match anything.
## This is needed for empty directories, otherwise
## "foo/*" expands to the literal string "foo/*"/
shopt -s nullglob
## Make ** recurse into subdirectories
shopt -s globstar
"檢查文件的類型
filetype on
syntax on
" 自動縮排:啟用自動縮排以後,在貼上剪貼簿的資料時排版可能會亂掉,這時可以手動切換至貼上模式 :set paste 再進行貼上。
set ai
set autoindent
set cindent
set smartindent
@yangsheng1107
yangsheng1107 / Makefile
Created December 8, 2015 01:49 — forked from Eun/Makefile
Makefile
## MAKEFILE V 1.3 ##
BIN = a.out
CC = gcc
CPLUS = g++
LINK = g++
OBJC = $(shell find ./src -name "*.c" | sed 's/\.c/\.o/g' | sed 's/\.\/src\//\.\/obj\//g')
OBJCPP = $(shell find ./src -name "*.cpp" | sed 's/\.cpp/\.opp/g' | sed 's/\.\/src\//\.\/obj\//g')
OBJ = $(OBJC) $(OBJCPP)

#我的 Vim 指令筆記

##vim 的三種模式 ###模式

  • 輸入模式:輸入內文。
  • 指揮模式:也叫指令模式,主要是進入到可以對文件做修改,複製,剪下貼上,游標移動等動作。
  • 執行模式:文件存檔,離開等等行為。

###常用模式的切換

  • 輸入模式 -> 指揮模式 : 鍵盤 Esc