Skip to content

Instantly share code, notes, and snippets.

View WyattJia's full-sized avatar
🎯
Focusing

bitstring WyattJia

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am wellls on github.
  • I am bitstring (https://keybase.io/bitstring) on keybase.
  • I have a public key ASBIqe0885hz69YQsP_sf-VJH3h1LfYCUSXBtqGF3v5r5Ao

To claim this, I am signing this object:

@WyattJia
WyattJia / python-tetris.py
Created March 1, 2018 08:08
Play Tetris with Python
#!/usr/bin/python
"""
Python implementation of text-mode version of the Tetris game
Quick play instructions:
- a (return): move piece left
- d (return): move piece right
- w (return): rotate piece counter clockwise
@WyattJia
WyattJia / Install_python_3.6.4_from_source_on_Ubuntu.sh
Created January 3, 2018 09:15
Install python 3.6.4 from source on Ubuntu.
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
tar -xzvf Python-3.6.4.tgz
cd Python-3.6.4/
./configure --enable-optimizations
sudo make altinstall
#! /usr/bin/env ruby
# encoding: utf-8
require 'rack'
class MyMiddleware
def initialize(app)
@app = app
end
@WyattJia
WyattJia / run_in_executor_example.py
Created December 8, 2017 11:53
run in executor example
import re
from asyncio import get_event_loop, ensure_future, sleep
from collections import deque
from concurrent.futures import ThreadPoolExecutor
import requests
from bs4 import BeautifulSoup
HEADERS = {'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/55.0.2883.95 Safari/537.36'}
@WyattJia
WyattJia / upgrade.md
Last active May 4, 2017 03:42 — forked from chrismccord/upgrade.md
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

#define NALLOC 1024 /* minimum #units to request */
typedef long Align; /* for alignment to long boundarg. 假定 long 类型为最受限的类型。*/
/* 空闲块包含的内容:
* 一个指向链表中下一个块的指针
* 一个块大小的记录
* 一个指向空闲空间本身的指针
@WyattJia
WyattJia / csdn_comment.py
Created April 18, 2017 08:14
自动评论 CSDN 的一段小脚本
# -*- coding=utf-8 -*-
# -*- author: wellls -*-
from __future__ import division
from bs4 import BeautifulSoup
from bs4.element import (
CharsetMetaAttributeValue,
Comment,
ContentMetaAttributeValue,
Doctype,
@WyattJia
WyattJia / pdf_count.py
Last active April 19, 2017 07:25
统计同一个目录下多个 PDF 文件页数的一段代码
# -*- author:wellls -*-
import re, os, glob, sys
rxcountpages = re.compile(r"/Type\s*/Page([^s]|$)", re.MULTILINE|re.DOTALL)
def count_pages(filename):
data = file(filename,"rb").read()
return len(rxcountpages.findall(data))
@WyattJia
WyattJia / shapeshifter.html
Created February 18, 2017 14:40 — forked from iblh/shapeshifter.html
Shape Shifter
<!DOCTYPE html>
<!-- saved from url=(0028)https://hacpai.com/halt.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>发现一个问题</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="https://hacpai.com/$%7BstaticServePath%7D/images/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style>
html {