This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
echo "========================================" | |
echo " macOS restoring script" | |
echo " Copyright Hawkins Zhao 2017" | |
echo "========================================" | |
echo "---> Restoring Applications..." | |
cp ./Apps/* /Applications/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
const int N = 8; | |
int queen[N]; | |
bool check(int n) { | |
for (int i = 0; i < n; i++) { | |
int x = n - i; | |
int y = queen[n] - queen[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
for (float y = 1.5f; y > -1.5f; y -= 0.1f) { | |
for (float x = -1.5f; x < 1.5f; x += 0.07f) { | |
float a = x * x + y * y - 1; | |
putchar(' '); | |
putchar(a * a * a - x * x * y * y * y <= 0.0f ? '*' : ' '); | |
} | |
putchar('\n'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let N = 10 | |
let source = [] | |
let M = 4 | |
for (let i = 0; i < N; i++) { | |
let len = Math.floor(Math.random() * 5) + 5 | |
let item = [] | |
for (let j = 0; j < len; j++) item.push(Math.floor(Math.random() * 10)) | |
source.push(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 元数据 | |
let a = { | |
source: { number: 0 } | |
} | |
// 核心:Object.defineProperty | |
Object.defineProperty(a, 'number', { | |
enumerable: true, | |
configurable: true, | |
get: function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result = window.location.href | |
.split('?')[1] | |
.split('&') | |
.map(v => v.split('=')) | |
.reduce((obj, v) => { obj[v[0]] = v[1]; return obj }, {}) | |
console.log(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function * selfIncreasement() { | |
let i = 0 | |
while (true) { | |
i++ | |
yield console.log(i) | |
} | |
} | |
let a = selfIncreasement() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int boxes[10] = {5, 3, 2, 7, 10, 9, 1, 6, 4, 8}; | |
int lemons[10] = {2, 6, 7, 1, 10, 5, 4, 3, 9, 8}; | |
int main() { | |
int globalMax = -1; | |
for (int k = 0; k < 10; k++) { | |
int i = k, j = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var func1 = function() { | |
return new Promise(function(resolve) { | |
setTimeout(function() { | |
console.log('func1'); | |
resolve(); | |
}, 500); | |
}); | |
}; | |
var func2 = function() { | |
return new Promise(function(resolve) { |
OlderNewer