Skip to content

Instantly share code, notes, and snippets.

View beiweiqiang's full-sized avatar
🎯
Focusing

beiweiqiang beiweiqiang

🎯
Focusing
  • Guangzhou, China
View GitHub Profile
@beiweiqiang
beiweiqiang / index.html
Last active March 10, 2019 03:28
纯前端, 解析 json 为 csv 文件并触发 csv 下载
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
</head>
<body>
<h1>This page does nothing....</h1>
@beiweiqiang
beiweiqiang / index.html
Last active March 10, 2019 03:26
defer's script 的执行时机
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
document.addEventListener('DOMContentLoaded', function (event) {
console.log('index.html: 9 -> -> ', 'dom');
console.log('index.html: 10 -> -> ', document.getElementById('img').offsetWidth);
@beiweiqiang
beiweiqiang / index.html
Created March 10, 2019 03:27
document 上的 DOMContentLoaded 事件 / window 上的 load 事件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
document.addEventListener('DOMContentLoaded', function (event) {
console.log('index.html: 9 -> -> ', 'dom');
console.log('index.html: 10 -> -> ', document.getElementById('img').offsetWidth);
@beiweiqiang
beiweiqiang / app2.js
Created March 13, 2019 00:25
defer 脚本总是按照指定它们的顺序进行执行
console.log('app2.js: 1 -> -> ', 'apps');
@beiweiqiang
beiweiqiang / Section.java
Last active July 7, 2019 00:06
java 选择排序
public class Selection {
public static void sort(Comparable[] a) {
int N = a.length;
for (int i = 0; i < N; i++) {
int min = i;
for (int j = i + 1; j < N; j++) {
if (less(a[j], a[min])) {
min = j;
}
}
@beiweiqiang
beiweiqiang / Insertion.java
Created July 8, 2019 00:59
Java 插入排序
public class Insertion {
public static void sort(Comparable[] a) {
int N = a.length;
// 从第二个元素开始操作
for (int i = 1; i < N; i++) {
// 索引之前的所有元素, 从右往左, 一个个进行比较, 如果后一个比前一个小, 则交换相邻的两个元素
for (int j = i; j > 0 && less(a[j], a[j - 1]); j--) {
exch(a, j, j-1);
}
}
@beiweiqiang
beiweiqiang / Shell.java
Last active July 9, 2019 23:45
Java 实现希尔排序
import java.util.Date;
public class Shell {
public static void sort(Comparable[] a) {
// 希尔排序:
// 是基于插入排序的,
// 使数组中, *任意* 每隔 h 是有序的,
// 当 h=1 时, 整个数组都是有序的
int n = a.length;
int h = 1;
@beiweiqiang
beiweiqiang / Merge.java
Created July 17, 2019 00:12
java 实现归并排序, 自顶向下
import java.util.Date;
public class Merge {
private static Comparable[] aux;
public static void sort(Comparable[] a) {
aux = new Comparable[a.length];
sort(a, 0, a.length - 1);
}
@beiweiqiang
beiweiqiang / MergeBU.java
Created July 17, 2019 00:29
java 实现归并排序, 自底向上
import java.util.Date;
public class MergeBU {
private static Comparable[] aux;
public static void sort(Comparable[] a) {
int n = a.length;
aux = new Comparable[n];
// 1 1 归并, 2 2 归并, 4 4 归并, 8 8 归并...
@beiweiqiang
beiweiqiang / os.asm
Last active November 22, 2019 14:43
os asm
; hello-os
; TAB=4
db 0xeb, 0x4e, 0x90
db "helloipl" ; 启动区的名称 8字节
dw 512 ; 每个扇区的大小 512 字节
db 1 ; cluster 的大小 (1个扇区)
dw 1 ; FAT 的起始位置 (第 1 个扇区开始)
db 2 ; FAT 的个数 (2 个)
dw 224 ; 根目录的大小 (224项)