Skip to content

Instantly share code, notes, and snippets.

View hzhangxyz's full-sized avatar

Hao Zhang hzhangxyz

  • University of Science and Technology of China
  • Hefei, China
  • 19:10 (UTC +08:00)
View GitHub Profile
@hzhangxyz
hzhangxyz / user.js
Last active March 31, 2017 07:17
mis.USTC.helper
// ==UserScript==
// @name mis.USTC Helper
// @namespace mis.ustc.edu.cn
// @version 0.0
// @description delete login information for USTC mis automatically
// @author H.Zhang
// @match http://mis.teach.ustc.edu.cn/
// @match http://mis.teach.ustc.edu.cn/index.jsp
// @grant none
// ==/UserScript==
@hzhangxyz
hzhangxyz / pool.js
Last active January 23, 2018 08:19
learn js Promise
pool = []
pool.push([1,1])
plus = async (a,b)=>await a+ await b
time = async (a)=>2* await a
main = async() =>{
for(var i=1;i<=10;i++){
pool.push([
plus(pool[i-1][0], pool[i-1][1]),
@hzhangxyz
hzhangxyz / index.html
Last active March 31, 2017 13:38
HTML5 element
<script>
window.onload = function(){
var Name = document.registerElement("name-div",{
prototype: Object.create(HTMLDivElement.prototype,{
createdCallback: {
value: function(){
this.shadow = this.createShadowRoot();
}
},
attributeChangedCallback: {
@hzhangxyz
hzhangxyz / asyncalize.js
Created April 7, 2017 06:47
convert callback function to async function
//convert callback function to async function
var asyncalize = (func) =>
function(){
console.log(func)
return new Promise(
(callback)=>func(...arguments,callback)
)
}
@hzhangxyz
hzhangxyz / square.tex
Last active April 25, 2017 02:53
tex print square
\documentclass{article}
\usepackage{xcolor}
\begin{document}
{\centering
\count2=10\def\content{O}
\count0=0\loop\ifnum\count0<\count2{
\count1=0\loop \ifnum\count1<\the\numexpr \count2-\count0 {
{\color{white}\content}
}\advance\count1 by 1\repeat
\count1=0\loop \ifnum\count1<\the\numexpr 2*\count0-1{
function exprst{
taskkill /f /im explorer.exe
taskkill /f /im SynTPEnh.exe
& "explorer.exe"
& "C:\Program Files\Synaptics\SynTP\SynTPEnh.exe"
}
function linux_{
bash -c ("DISPLAY=:0 "+($args -join " "))
}
function linux{
#!/usr/bin/env python
import tensorflow as tf
from tensorflow.python import debug as tf_debug
D = 2
t = -0.001
with tf.name_scope("constant"):
@hzhangxyz
hzhangxyz / main.js
Last active February 9, 2018 12:48
python和js的async
sleep = (ms)=> new Promise(resolve => setTimeout(resolve, ms))
function bsleep(millis){
var date = new Date()
var curDate = null
do {curDate = new Date()}
while(curDate-date < millis)
}
print = console.log
foo = async (i)=>{
@hzhangxyz
hzhangxyz / cindy_game.py
Created March 6, 2018 06:09
cindy_game.py
import functools
import sympy
from scipy import optimize
n = 3 # n 个人
m = 3 # m 个坑
def sol(n,m):
v = sympy.symbols(" ".join([str(i) for i in range(m)]))
@hzhangxyz
hzhangxyz / custom.cfg
Created August 22, 2018 15:07
boot from iso via grub
menuentry 'ubuntu live' {
set rootuuid=709ba2df-2ded-4a27-83fe-34093fe97ce7
search --no-floppy --fs-uuid --set=root $rootuuid
set isofile='/img/ubuntu-18.04.1-desktop-amd64.iso'
loopback loop $isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile
initrd (loop)/casper/initrd.lz
}
menuentry 'debian live' {