Skip to content

Instantly share code, notes, and snippets.

View wzpan's full-sized avatar
:octocat:
Focusing

潘伟洲 wzpan

:octocat:
Focusing
View GitHub Profile
@wzpan
wzpan / timestamp.py
Created August 20, 2013 12:07
Python - timestamp
import datetime
# 2012-12-15 10:14:51.898000
print datetime.datetime.utcnow()
# The now differs from utcnow as expected
# otherwise they work the same way:
# 2012-12-15 11:15:09.205000
print datetime.datetime.now()
@wzpan
wzpan / scrollspy.html
Last active December 21, 2015 17:38 — forked from hpyhacking/sample.html
Bootstrap ScrollSpy Sample
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap-scrollspy.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style type="text/css">
@wzpan
wzpan / scrollspy-test.html
Last active December 21, 2015 18:49
Bootstrap ScrollSpy's Bugs With Chinese ID Targets
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://code.jquery.com/jquery.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" media="screen">
<!-- Optional theme -->
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
@wzpan
wzpan / struct.c
Created September 2, 2013 05:18
C - struct
#include <math.h>
struct ComplexStruct {
// 定义复数的结构体
double x, y;
};
double real_part(struct ComplexStruct z){
// 返回复数的实部
return z.x;
@wzpan
wzpan / draft.c
Created September 2, 2013 07:35
C - pointer as parameters
#include <stdio.h>
void swap(int *a, int *b){
int temp = *a;
*a = *b;
*b = temp;
}
int main(int argc, char *argv[]){
int num1 = 5;
@wzpan
wzpan / gen_random.c
Created September 2, 2013 09:54
C - random values
#include <stdlib.h>
#include <stdio.h>
#include <time.h> /*用到了time函数,所以要有这个头文件*/
#define MAX 10
int main( void)
{
int number[MAX] = {0};
int i;
srand((unsigned) time(NULL)); /*播种子*/
@wzpan
wzpan / multi_array.c
Created September 2, 2013 13:06
C - multi-dimension string arrays
#include <stdio.h>
void print_day(int day){
char days[8][10] = {
"", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday",
"Saturday", "Sunday"
};
if (day < 1 || day > 7){
@wzpan
wzpan / scanf_example.c
Last active December 22, 2015 03:58
C - scanf
#include <stdio.h>
int main(void){
char str[] = "hello world";
int num;
float value;
scanf("%s", str);
scanf("%d", &num);
scanf("%f", &value);
@wzpan
wzpan / insertion_sort.py
Created September 8, 2013 01:32
C - insertion sort
def insertion_sort(n):
if len(n) == 1:
return n
b = insertion_sort(n[1:])
m = len(b)
for i in range(m):
if n[0] <= b[i]:
return b[:i]+[n[0]]+b[i:]
return b + [n[0]]
@wzpan
wzpan / strassen.cpp
Created September 10, 2013 03:00
C++ - strassen algorithm
#include <iostream>
using namespace std;
const int N = 6; //Define the size of the Matrix
template<typename T>
void Strassen(int n, T A[][N], T B[][N], T C[][N]);
template<typename T>