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
const STATES = { | |
PENDING: 'Pending', | |
RESOLVED: 'Resolved', | |
REJECTED: 'Rejected' | |
} | |
class Promise { | |
constructor(executor) { | |
const tryCall = callback => Promise.try(() => callback(this.value)); | |
const invokes = []; | |
const callLater = getMethod => callback => new Promise(resolve => invokes.push(() => resolve(getMethod()(callback)))); |
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
matrix: | |
include: | |
- os: osx | |
osx_image: xcode10.2 | |
language: node_js | |
node_js: "10" | |
env: | |
- ELECTRON_CACHE=$HOME/.cache/electron | |
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder |
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
// Async function | |
const request = i => new Promise((resolve, reject) => { | |
console.log(`No.${i} gets started.`); | |
setTimeout(() => { | |
resolve(`No.${i} gets resolved.`); | |
console.log(`No.${i} gets resolved.`); | |
}, 1000); | |
}); | |
// Create a list of parameters |
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 printM3uFile() { | |
let $btns = $('[target="_blank"]'); | |
let address = $.makeArray($btns.map((i, btn) => $(btn).attr('href'))) | |
.map(n => n.split('=')[1].split('&')[0]); | |
let names = $.makeArray($btns.map((i, btn) => $(btn).text())); | |
let configure = address.map((n, i) => `#EXTINF:-1 group-title="all",${names[i]}<br>https://iptv.tsinghua.edu.cn/hls/${n}.m3u8`); | |
let content = document.createElement('div'); | |
content.innerHTML = `<div>#EXTM3U<br><br>${configure.join('<br>')}</div>`; | |
document.body.innerHTML = ''; |
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 changeVisibility() { | |
const loadingTime = 2000; | |
const s = document.createElement("script"); | |
s.setAttribute("src","https://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"); | |
s.onload = () => { | |
const timer = setInterval(() => { | |
$(document).scrollTop(50000); | |
}, loadingTime) |
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/sh | |
git filter-branch --env-filter ' | |
# user specified | |
OLD_EMAIL="[email protected]" | |
CORRECT_NAME="correctGitHubName" | |
CORRECT_EMAIL="[email protected]" | |
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] | |
then |
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
#!/usr/bin/bash | |
IP4=$(ifconfig | grep "59.66.[0-9]*\.[0-9]*" | cut -d ' ' -f3) # your IPv4 address | |
sudo ifconfig gif0 create | |
sudo ifconfig gif0 tunnel $IP4 166.111.21.1 | |
sudo ipconfig set gif0 MANUAL-V6 2402:f000:1:1501:200:5efe:$IP4 64 | |
sudo route add -inet6 ::/0 -interface gif0 |
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
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.image import MIMEImage | |
from email.mime.text import MIMEText | |
def send_qr_mails(attach_path): | |
from_address = "xxxxxxxx" # sender's mail address | |
pwd = 'xxxxx' # sender's password | |
to_address = 'xxxxx' # receiver's address |