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
func noReturn() (result int) { | |
defer func() { | |
p := recover() | |
result = p.(int) | |
}() | |
panic(42) | |
} |
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
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. | |
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ | |
// See page 165. | |
// Package intset provides a set of integers based on a bit vector. | |
package intset | |
import ( | |
"bytes" |
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/env python | |
# coding: utf-8 | |
import requests | |
import StringIO | |
from PIL import Image | |
import os | |
import time | |
YES = 'X' | |
NO = '-' |
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
"""实在是对位运算不熟,甚是麻烦,直接操作字符串了。 | |
""" | |
def test_rev_encode(): | |
for i in range(500): | |
encode = rev_encode(i) | |
if rev_encode(encode) != i: | |
print('{0}>{1} {1}>{2}'.format(i,encode,rev_encode(encode))) | |
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
package main | |
import "golang.org/x/tour/tree" | |
import "fmt" | |
// Walk 步进 tree t 将所有的值从 tree 发送到 channel ch。 | |
func Walk(t *tree.Tree, ch chan int) { | |
if t == nil { | |
return | |
} |
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/env python | |
from datetime import datetime, timedelta | |
filename = 'input.vtt' | |
srt = [] | |
delta = -10 # Subtitle timeline | |
count = 1 | |
timeline = 0 | |
def changetime(time, delta): |
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
say --voice="Agnes" Isn\'t it nice to have a computer that will talk to you? | |
say --voice="Albert" I have a frog in my throat. No, I mean a real frog! | |
say --voice="Alex" Most people recognize me by my voice. | |
say --voice="Alice" Salve, mi chiamo Alice e sono una voce italiana. | |
say --voice="Alva" Hej, jag heter Alva. Jag är en svensk röst. | |
say --voice="Amelie" Bonjour, je m ’ appelle Amelie. Je suis une voix canadienne. | |
say --voice="Anna" Hallo, ich heiße Anna und ich bin eine deutsche Stimme. | |
say --voice="Bad News" The light you see at the end of the tunnel is the headlamp of a fast approaching train. | |
say --voice="Bahh" Do not pull the wool over my eyes. | |
say --voice="Bells" Time flies when you are having fun. |
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 random | |
def randsums(nrange, count): | |
l = [] | |
for i in range(count): | |
# print(nrange) | |
if i == count-1: | |
l.append(nrange[-1]) | |
else: | |
r = random.randrange(*nrange) |
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
// 要在console中选择相应的页面 | |
// iframe(play) | |
window.onfocus = function(){console.log('ononfocus')}; | |
window.onblur = function(){console.log('onblur')}; | |
// 去掉所有的定时器。 | |
var biggestTimeoutId = window.setTimeout(function(){}, 1),i; | |
for(i = 1; i <= biggestTimeoutId; i++) { | |
clearTimeout(i); | |
};console.log('biggestTimeoutId',biggestTimeoutId) |
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
# Don't get me wrong, I love pretty colors as much as the next guy... but what does it mean? pretty_pixels.png | |
# https://static2.ichunqiu.com/icq/resources/fileupload/CTF/IceCTF/stego/pretty.png | |
from PIL import Image | |
from sys import stdout | |
img = Image.open('pretty.png') | |
x_size, y_size = img.size |