Skip to content

Commit 84df324

Browse files
committed
update files
1 parent 0d42833 commit 84df324

34 files changed

+40646
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 代码模版
2+
3+
## c
4+
printf_format.c: printf格式化输出示例
5+
print_binary.c: 输出二进制
6+
dynamic_array.c: 动态定义数组
7+
8+
## html
9+
### common
10+
avoidTextAround.html:防止文字环绕
11+
CenterContent.html: 居中显示内容
12+
clearFloat.html:清除浮动
13+
flexDemo.html:使用flex布局示例
14+
JsonToCheckBox.html: 根据json格式信息自动生成checkbox
15+
16+
### bootstrap
17+
fix_footer.html: 底部固定
18+
loading.html: 加载插件
19+
navigation.html: 导航示例
20+
switch.html: 开关切换插件
21+
toaster.html: 信息提示插件
22+
23+
24+
### html5
25+
FixCanvasSizeOnDevice.html: 使Canvas适应不同设备
26+
PrelaodImages.html: 预加载图片
27+
28+
29+
### threeJs
30+
dynamictexture.html: 在立方体上显示数字
31+
dynamictexture2.html: 在立方体上显示不同数字
32+
dynamictexture3.html: 在立方体上显示数字,可加边框
33+
34+
## Ubuntu
35+
ubuntu_desktop.txt: 创建Ubuntu桌面快捷方式

c/dynamic_array.c

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
4+
/*
5+
* 定义一维数组
6+
*/
7+
void defOneDimArray(int n) {
8+
int *arr = (int*)calloc(n, sizeof(int));
9+
int i;
10+
for(i = 0; i < n; i++) {
11+
arr[i] = i;
12+
}
13+
14+
for(i = 0; i < n; i++) {
15+
printf("i is %d and arr[i] is %d \n", i, arr[i]);
16+
}
17+
//需要释放内存
18+
free(arr);
19+
}
20+
21+
void defTwoDimArray(int m, int n) {
22+
int **arr = (int **)calloc(m, sizeof(int *));
23+
int i, j, index = 0;
24+
for(i = 0; i < m; i++) {
25+
arr[i] = (int *) (calloc(n, sizeof(int)));
26+
}
27+
28+
for(i = 0; i < m; i++) {
29+
for(j = 0; j < n; j++) {
30+
arr[i][j] = index;
31+
index++;
32+
}
33+
}
34+
35+
for(i = 0; i < m; i++) {
36+
for(j = 0; j < n; j++) {
37+
printf("i is %d and j is %d and arr[i][j] is %d\n", i, j, arr[i][j]);
38+
}
39+
}
40+
41+
for(i = 0; i < m; i++) {
42+
free(arr[i]);
43+
}
44+
free(arr);
45+
}
46+
47+
int main() {
48+
defOneDimArray(10);
49+
defTwoDimArray(2, 3);
50+
}

c/print_binary.c

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <stdint.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
#include <string.h>
5+
6+
/*
7+
* 打印二进制
8+
* t: 要打印的数字
9+
* bit_len: 二进制的长度,不要超过64位
10+
*/
11+
void print_binary(uint64_t t, int bit_len) {
12+
short *buffer;
13+
buffer = (short *) calloc(bit_len , sizeof(short));
14+
int i;
15+
for (i = 0; i < bit_len; i++) {
16+
if (t == 0)
17+
break;
18+
if (t % 2 == 0) {
19+
buffer[i] = 0;
20+
} else {
21+
buffer[i] = 1;
22+
}
23+
t = t / 2;
24+
}
25+
for (i = bit_len - 1; i >= 0; i--) {
26+
printf("%hd", buffer[i]);
27+
}
28+
free(buffer);
29+
}
30+
31+
void main() {
32+
print_binary(1234, 8);
33+
printf("\n");
34+
print_binary(1234, 16);
35+
printf("\n");
36+
print_binary(1234, 32);
37+
printf("\n");
38+
print_binary(1234, 64);
39+
printf("\n");
40+
}
41+

c/printf_format.c

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* C格式化输出
3+
*/
4+
5+
#include <stdio.h>
6+
7+
int main() {
8+
int i = 10;
9+
float f = 10.0F;
10+
char c = 'D';
11+
char s[] = "DDDD";
12+
char *s1 = "CCCC";
13+
long k = 100L;
14+
long long kk = 100L;
15+
long double ld = 100.0;
16+
17+
18+
//输出有符号十进制整数
19+
printf("**%d**\n", i);
20+
printf("**%i**\n", i);
21+
22+
//输出无符号十进制整数
23+
printf("**%u**\n", i);
24+
25+
//输出无符号八进制整数
26+
printf("**%o**\n", i);
27+
28+
//输出无符号十六进制整数(x-小写字符/X-大写字符)
29+
printf("**%x**\n", i);
30+
printf("**%X**\n", i);
31+
32+
//输出浮点数,十进制计数法
33+
printf("**%f**\n", f);
34+
35+
// %.nf n保留n位小数
36+
printf("**%.2f**\n", f);
37+
38+
//输出浮点数 e--e计数法/E--E计数法
39+
printf("**%e**\n", f);
40+
printf("**%E**\n", f);
41+
42+
//输出字符
43+
printf("**%c**\n", c);
44+
45+
//输出字符串
46+
printf("**%s**\n", s);
47+
48+
//输出指针
49+
printf("**%p**\n",s1);
50+
51+
//打印一个百分号
52+
printf("**%%**\n");
53+
54+
// h 和整数转换符一起使用,表示是一个short int 或者unsigned short int
55+
printf("**%hd**\n", i);
56+
57+
// l 和整数转换说明符一起使用,说明是一个long int或者 unsigned long int
58+
printf("**%ld**\n", k);
59+
60+
// ll 和整数转换说明符一起使用,说明是一个long long int 或者 unsigned long long int
61+
printf("**%lld**\n", kk);
62+
63+
// L 和浮点转换说明符一起使用,表示一个long double值
64+
printf("**%Lf**\n", ld);
65+
66+
// z 和整数转换说明符一起使用,表示一个size_t值(sizeof返回的类型)
67+
printf("**%zd**\n", sizeof(int));
68+
69+
// %n(d/f/...) n表示输出的最小宽度,默认是右对齐,不足补空格
70+
printf("**%4d**\n", i);
71+
72+
// %n.ms n表示最小宽度,m表示字符串输出的字符数目
73+
printf("**%4.1s**\n", s);
74+
75+
// %-n(d/f/...) -表示左对齐
76+
printf("**%-4d**\n", i);
77+
78+
// %+(d/f/...) +在有符号的数字输出时加上 +/- 号
79+
printf("**%+d**\n", i);
80+
81+
// % (d/f/...) ' '(空格)对于有符号数, 符号为+显示前导空格,符号为负显示-
82+
printf("**% d**\n", i);
83+
84+
// %#(o/x/...)使用转化说明的可选形式,如果8进制,则以0开头,16进制以0x开头
85+
printf("**%#x**\n", i);
86+
87+
// %0n(d/f/...) n前面的0表示使用空格填充剩余位
88+
printf("**%04d**\n", i);
89+
90+
}

html/bootstrap/fix_footer.html

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
8+
<title>底部固定</title>
9+
<link rel="stylesheet" href="../libs/bootstrap/css/bootstrap.min.css">
10+
11+
<script type="text/javascript" src="../libs/jquery/jquery-1.11.2.min.js"></script>
12+
<script type="text/javascript" src="../libs/bootstrap/js/bootstrap.js"></script>
13+
14+
<!--[if lt IE 9]>
15+
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
16+
<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
17+
<![endif]-->
18+
19+
<style type="text/css">
20+
* {
21+
margin: 0;
22+
}
23+
24+
html, body {
25+
height: 100%;
26+
}
27+
28+
.wrapper {
29+
min-height: 100%;
30+
height: auto !important;
31+
height: 100%;
32+
margin: 0 auto -6em;
33+
}
34+
35+
/*push和footer的高度不一样是因为加了一条hr*/
36+
.push {
37+
height: 6em;
38+
}
39+
40+
.footer, {
41+
height: 4em;
42+
}
43+
</style>
44+
</head>
45+
<body>
46+
47+
<div class="wrapper">
48+
<div class="container text-center">
49+
<p>这里是内容</p>
50+
</div>
51+
<div class="push"></div>
52+
</div>
53+
54+
<footer class="footer">
55+
<div class=" col-lg-12 text-center">
56+
<hr>
57+
<p>Copyright &copy; zhangjk 2015</p>
58+
</div>
59+
</footer>
60+
61+
</body>
62+
</html>

html/bootstrap/loading.html

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
8+
<!-- 插件地址:https://github.com/ehpc/bootstrap-waitingfor -->
9+
<title>加载插件</title>
10+
<link rel="stylesheet" href="../libs/bootstrap/css/bootstrap.min.css">
11+
12+
<script type="text/javascript" src="../libs/jquery/jquery-1.11.2.min.js"></script>
13+
<script type="text/javascript" src="../libs/bootstrap/js/bootstrap.js"></script>
14+
<script type="text/javascript" src="../libs/bootstrap/js/bootstrap-waitingfor.js"></script>
15+
16+
<!--[if lt IE 9]>
17+
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
18+
<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
19+
<![endif]-->
20+
21+
</head>
22+
<body>
23+
<div>
24+
<button id="open" class="btn btn-primary ">Click Me</button>
25+
</div>
26+
27+
<script type="text/javascript">
28+
$("#open").click(function () {
29+
waitingDialog.show();
30+
31+
setTimeout(function() {
32+
waitingDialog.hide();
33+
},2000);
34+
})
35+
</script>
36+
</body>
37+
</html>

0 commit comments

Comments
 (0)