- Install
xmpppymodule for python. (Manually download it from Downloads Page or tryeasy_install xmpppy) - Create a script file. (Ex.
lol_echo_bot.py) - Follow steps below.
Import
xmpp.
xmpppy module for python. (Manually download it from Downloads Page or try easy_install xmpppy)lol_echo_bot.py)Import
xmpp.
| import re | |
| import inspect | |
| FORMAT_REGEX = re.compile(r'\\\(([a-zA-Z_]\w*)\)') | |
| def formatted(string, silent=False): | |
| to_be_replaced = FORMAT_REGEX.findall(string) | |
| variables = inspect.stack()[1][0].f_locals | |
| for item in to_be_replaced: | |
| if item in variables: | |
| string = string.replace('\({})'.format(item), str(variables[item])) |
| try: | |
| import cPickle as pickle | |
| except ImportError: | |
| import pickle | |
| import zlib | |
| from Crypto.Cipher import AES | |
| from Crypto.Hash import MD5 | |
| from Crypto import Random | |
| from base64 import b64encode, b64decode |
| # coding: utf-8 | |
| import requests | |
| import time | |
| class KakaoStoryAPI(object): | |
| def __init__(self, cookie): | |
| self.headers = { | |
| 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:37.0) Gecko/20100101 Firefox/37.0', | |
| 'Accept': 'application/json', |
| # coding: utf-8 | |
| import requests | |
| import time | |
| from urlparse import parse_qsl | |
| from bs4 import BeautifulSoup | |
| class KakaostoryAPI(object): | |
| def __init__(self, raw_cookie): | |
| self.session = requests.Session() |
| class SliceTime(object): | |
| @property | |
| def hour(self): | |
| return self._hour | |
| @hour.setter | |
| def hour(self, value): | |
| if not isinstance(value, (int, long)) or not 0 <= value <= 23: | |
| raise ValueError('hour must be an integer value in 0 ~ 23') | |
| else: |
| import pygame | |
| from pygame.locals import * | |
| WIDTH, HEIGHT = 100, 100 | |
| PIXEL_SIZE = 5 # should be bigger than 1 | |
| SCREEN_WIDTH, SCREEN_HEIGHT = WIDTH * PIXEL_SIZE, HEIGHT * PIXEL_SIZE | |
| surf = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT)) | |
| surf.fill((0, 0, 0)) |
| f=lambda a,b,n:f(b,a+b,n-1)if n>1else b # simple and fast | |
| # for test | |
| import sys | |
| sys.setrecursionlimit(5001) # as default, it was 1000 in my computer | |
| print(f(0,1,5000)) # 0 1 1 2 3 5 8 13 21 ... | |
| print(f(1,1,5000)) # 1 1 2 3 5 8 13 21 34 ... |
| from datetime import date | |
| def is_leap_year(year): | |
| try: date(year, 2, 29) | |
| except ValueError: return False | |
| else: return True |
| #include <stdio.h> | |
| #include <conio.h> | |
| #include <Windows.h> | |
| #define MAX_BULLETS_COUNT 100 | |
| typedef struct { | |
| int alive; | |
| char ch; | |
| int x, y, color; |