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 werobot | |
import random | |
robot = werobot.WeRoBot(token='zzz', | |
enable_session=True) | |
@robot.handler | |
def echo(message, session): | |
if message.content == '猜数字': | |
digits = [str(i) for i in range(10)] |
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 python3 | |
# | |
# VSCode C# extension offline helper | |
# Version 202003061443 | |
# | |
# The MIT License (MIT) | |
# | |
# Copyright © 2020 [email protected] | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy |
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
# God-stick-like | |
from itertools import chain, repeat | |
from functools import partial, reduce | |
this_is_a_list = [1, 2, 3, 4, 5] | |
what_you_want = reduce(chain, map(partial(repeat, times=2), this_is_a_list)) | |
# Normal | |
this_is_a_list = [1, 2, 3, 4, 5] | |
what_you_want = [val for val in this_is_a_list for i in range(2)] |
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/python | |
import errno | |
import socket | |
import sys | |
import time | |
PLAYER_NAMES = ( | |
'Alice', | |
'Bob', |
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 socket | |
import select | |
BACKEND_HOST = 'example' | |
BACKEND_PORT = 1234 | |
BUF_SIZE = 1024 | |
LISTEN_PORT = 1234 | |
proxy_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
proxy_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
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
'Darth virus is licensed under GPL3. | |
'https://www.gnu.org/copyleft/gpl.html | |
' | |
'Copyright (c) 2014 yinian1992. | |
Dim myVirus | |
myVirus = MsgBox ("No, I am your father.", 16, "Darth Virus") |
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 unicodedata | |
from django import template | |
register = template.Library() | |
@register.filter | |
def truncate(text, max_length): | |
max_length = int(max_length) - 3 |
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
# Porting from http://blog.kevburnsjr.com/php-unique-hash | |
# and modified some codes to support variable length | |
# Min length of unique id | |
MIN_LENGTH = 2 | |
# Unique ID contains some of these 56 chars | |
CHARSET = 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789' | |
# Some primes greater than 56 ^ n / 1.61803398874989484 |
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
from datetime import datetime, timedelta | |
import sqlalchemy as sa | |
import sqlalchemy.orm as orm | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
NOW = datetime.utcnow() | |
DBSession = scoped_session(sessionmaker()) | |
Base = declarative_base() |
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
<?php | |
/** | |
* Code Calculator | |
* | |
* count line number of php project | |
* @author yinian1992 | |
* | |
*/ | |
// define('BASEPATH', 'absolute path of your php project'); |