Skip to content

Instantly share code, notes, and snippets.

View mayneyao's full-sized avatar

Mayne mayneyao

View GitHub Profile
@mayneyao
mayneyao / large-file-hash.py
Created April 13, 2018 04:15 — forked from aunyks/large-file-hash.py
Hash a large file in Python
import hashlib as hash
# Specify how many bytes of the file you want to open at a time
BLOCKSIZE = 65536
sha = hash.sha256()
with open('kali.iso', 'rb') as kali_file:
file_buffer = kali_file.read(BLOCKSIZE)
while len(file_buffer) > 0:
sha.update(file_buffer)
@mayneyao
mayneyao / RegisterBindUser.js
Last active November 1, 2018 09:39
react中使用js防抖校验邮箱
onEmailChange = (e) => {
e.persist();
this.setState({
email: e.target.value
}, () => {
this.checkEmail(e.target.value)
})
};
checkEmail = (email) => {
@mayneyao
mayneyao / models.py
Last active November 1, 2018 09:29
django 通用模型
from django.db import models
class CommonModel(models.Model):
create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True, blank=True)
update_time = models.DateTimeField(verbose_name='更新时间', auto_now=True, blank=True)
active = models.NullBooleanField(verbose_name='是否有效', default=True, blank=True)
class Meta:
abstract = True
@mayneyao
mayneyao / export netease music top100
Last active December 28, 2018 09:51
导出 网易云音乐 听歌排行前100到 Spotify
let allSongsDiv = document.querySelectorAll('div.song > div.tt > div > span');
let songList = [];
allSongsDiv.forEach(item=>songList.push(item.innerText));
let clearSongList = songList.map(item=>{
let [name,artist] = item.split(" -");
return `${name} - ${artist}`
})
let text = clearSongList.join('\n');
text
@mayneyao
mayneyao / react_conetxt_api 
Last active January 7, 2019 03:15
React(16.3+) Context API
import React, {Component, createContext} from 'react';
import {setName} from "./actions";
const Context = createContext();
export class Provider extends Component {
genActions = () => {
let actions = {};
@mayneyao
mayneyao / notion_api.js
Created February 18, 2019 09:59
Notion API
const axios = require('axios')
const { URLSearchParams } = require('url')
const getFullBlockId = (blockId) => {
if (typeof blockId !== 'string') {
throw Error(`blockId: ${typeof blockId} must be string`)
}
if (blockId.match("^[a-zA-Z0-9]+$")) {
return blockId.substr(0, 8) + "-"
+ blockId.substr(8, 4) + "-"
@mayneyao
mayneyao / github.bash
Created March 5, 2019 07:46 — forked from igrigorik/github.bash
Open GitHub URL for current directory/repo...
alias gh="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
@mayneyao
mayneyao / dict2obj.py
Created July 19, 2019 02:48
Python 中字典转对象演示
from types import SimpleNamespace
npc = {
'name': {
'first': 'san',
'last': 'zhang'
},
'hp': 1000
}
npc
npc = SimpleNamespace(**npc)
@mayneyao
mayneyao / README-Template.md
Created August 4, 2019 15:49 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@mayneyao
mayneyao / notion2blog.js
Last active February 29, 2024 18:01
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",