Skip to content

Instantly share code, notes, and snippets.

View YiqinZhao's full-sized avatar
🎯
Focusing

Yiqin Zhao YiqinZhao

🎯
Focusing
View GitHub Profile
@YiqinZhao
YiqinZhao / tags.html
Created December 31, 2017 01:16
Useful tags in <head>
<html>
<heda>
<!-- Scratch view for full screen mode in iOS web app -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, viewport-fit=cover">
<!-- WebApp setup -->
<!-- black-translucent: No background for statebar -->
<!-- black: Black background for statebar -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
@YiqinZhao
YiqinZhao / macOS-Restoring-Tool.sh
Created December 31, 2017 01:18
macOS restoring tool.
#!/bin/zsh
echo "========================================"
echo " macOS restoring script"
echo " Copyright Hawkins Zhao 2017"
echo "========================================"
echo "---> Restoring Applications..."
cp ./Apps/* /Applications/
@YiqinZhao
YiqinZhao / 8Queens.cpp
Last active April 6, 2019 06:39
8Queens in 10 Lines of C++
#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];
@YiqinZhao
YiqinZhao / love.c
Created February 22, 2018 14:40
Generate a love shape
#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');
@YiqinZhao
YiqinZhao / question-1.js
Last active June 20, 2019 13:38
[yuanfudao-interview] 猿辅导前端面试总结 #interview
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)
@YiqinZhao
YiqinZhao / index.js
Created March 9, 2018 07:03
[Vue Reactive Data] How to implement a Vue styled reactive data.
// 元数据
let a = {
source: { number: 0 }
}
// 核心:Object.defineProperty
Object.defineProperty(a, 'number', {
enumerable: true,
configurable: true,
get: function () {
@YiqinZhao
YiqinZhao / index.js
Created March 9, 2018 07:34
[Split URL Parameters] Simple code for URL parameters split. #web
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)
@YiqinZhao
YiqinZhao / index.js
Created March 20, 2018 11:25
[Self increasement function]
function * selfIncreasement() {
let i = 0
while (true) {
i++
yield console.log(i)
}
}
let a = selfIncreasement()
@YiqinZhao
YiqinZhao / main.cpp
Created March 21, 2018 03:33
[Lemo Puzzle] Two array, boxes and lemos stand for size of boxes and size of lemos. Every lemo can be put into a box which has equal or bigger size. Pick a start point i from lemos array, find a possible box and repeat this action for i+1, i+2. All lemos in boxes should keep their original orders. What is the longest sequence of lemos in boxes. …
#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;
@YiqinZhao
YiqinZhao / index.js
Created March 22, 2018 02:24
[Promise waterfall] Async function queue #interview
var func1 = function() {
return new Promise(function(resolve) {
setTimeout(function() {
console.log('func1');
resolve();
}, 500);
});
};
var func2 = function() {
return new Promise(function(resolve) {