Skip to content

Instantly share code, notes, and snippets.

Avatar

wwj718

View GitHub Profile
View itchat_group_test.py
import itchat, time
from itchat.content import TEXT
@itchat.msg_register([TEXT])
def text_reply(msg):
# 不会接受群消息
# msg.user.send('%s: %s' % (msg.type, msg.text))
# author = itchat.search_friends(nickName='Finn')[0]
# author.send('hi ,我正通过codelab的Scratch界面与你聊天!')
content = msg.text
View video_player.html
<html>
<head>
<title>video player</title>
</head>
<body onload="onload();">
<video
id="idle_video"
onended="onVideoEnded();"
controls="controls"
></video>
View mqtt_client.py
'''
IoT: Internet of Things
server : iot.codelab.club
# tool:
pip3 install hbmqtt # 0.9.5
hbmqtt_pub --url mqtt://guest:test@iot.codelab.club -t "/scratch3_sub" -m "hello from hbmqtt_pub"
hbmqtt_sub --url mqtt://guest:test@iot.codelab.club -t "/scratch3_pub"
'''
import logging
View sb3_compress.py
# python3
'''
usage
1. download sb3 and unzip
* box2d_2_codelab_start.sb3
* rename box2d_2_codelab_start.sb3 -> box2d_2_codelab_start.zip
* unzip it: -> box2d_2_codelab_start
2. Modify content
3. zip box2d_2_codelab_start
View simple_https_server.py
# python3
'''
Usage:
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
python3 simple_https_server.py
'''
import http.server, ssl
server_address = ('localhost', 8601)
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
@wwj718
wwj718 / vector_animations.txt
Created Jan 16, 2019
List all animation names:
View vector_animations.txt
anim_launch_cubediscovery
anim_slowpoke_loop_04
anim_dancebeat_quit_01
anim_observing_sides_area_01
anim_message_deleted_short_01
anim_fastbump_loop_01
anim_hiking_driving_start_04
anim_cubedocking_drive_loop_01
anim_hiking_driving_start_03
anim_launch_wakeup_startdriving_01
View vector_bak.py
'''
Vector:
https://developer.anki.com/vector/docs/getstarted.html
https://github.com/anki/vector-python-sdk/blob/master/examples/tutorials/02_drive_square.py
todo:
内置 anki_vector, 是否可行?
'''
import time
import threading
from scratch3_adapter import settings
View python_exec.py
import sys
from io import StringIO
import contextlib
@contextlib.contextmanager
def stdoutIO(stdout=None):
old = sys.stdout
if stdout is None:
stdout = StringIO()
sys.stdout = stdout
@wwj718
wwj718 / gist:e1ee2d4d70db379365d2826c66ae4377
Created Jan 5, 2019
cookiecutter-django-for-scratch-backend
View gist:e1ee2d4d70db379365d2826c66ae4377
➜ ~ cookiecutter https://github.com/pydanny/cookiecutter-django
You've downloaded /Users/wuwenjie/.cookiecutters/cookiecutter-django before. Is it okay to delete and re-download it? [yes]: yes
project_name [My Awesome Project]: scratch_backend
project_slug [scratch_backend]:
description [Behold My Awesome Project!]: scratch backend
author_name [Daniel Roy Greenfeld]: wwj718
domain_name [example.com]: backend.codelab.club
email [wwj718@example.com]: wuwenjie718@gmail.com
version [0.1.0]:
Select open_source_license:
View pyqt_bt_local.py
# https://gist.github.com/midoriiro/320c6990ab8e66343a7b
from PyQt5 import QtBluetooth
from PyQt5.QtBluetooth import QBluetoothLocalDevice
local_device = QBluetoothLocalDevice()
# 查看本机蓝牙 mac
all = local_device.allDevices()
first = all[0]
address = first.address().toString() # 88:E9:FE:5B:99:04
You can’t perform that action at this time.