Skip to content

Instantly share code, notes, and snippets.

View enginebai's full-sized avatar
📈
Focusing, Learning, Improving, Evolving

Engine Bai enginebai

📈
Focusing, Learning, Improving, Evolving
View GitHub Profile
#!/usr/bin/python3
# -*- coding: utf8 -*-
from selenium import webdriver
from bs4 import BeautifulSoup
__author__ = "Engine Bai"
url = "https://medium.com/dualcores-studio/make-an-android-custom-view-publish-and-open-source-99a3d86df228"
driver = webdriver.Chrome(executable_path="./driver/chromedriver")
driver.get(url)
@enginebai
enginebai / fb_messager.py
Created June 18, 2017 18:09
Facebook messager receive message
@app.route(config.web_hook_url, methods=["POST"])
def receive_message():
message_entries = json.loads(request.data.decode("utf-8"))
print("message_entries:", message_entries)
for entry in message_entries["entry"]:
for message in entry["messaging"]:
sender = message["sender"]["id"]
# print("sender:", sender)
if chat_thread.get(sender, None) is None:
@enginebai
enginebai / bot.py
Last active June 20, 2017 23:59
Chatbot implement
#!/usr/bin/python3
# -*- encoding: utf-8 -*-
import configparser
import time
from enum import Enum
from nlp_parser import parse_sentence, Intent
from message import Messager, QuickReply, GenericElement, ActionButton, ButtonType
import config
import api
@enginebai
enginebai / nlp_parser.py
Created June 21, 2017 15:49
NLP module in Facebook messager bot
class Intent(Enum):
HELP = "help"
WORKS_PRIMARY = "works_primary"
WORKS_SECONDARY = "works_secondary"
PROJECTS = "projects"
OPEN_SOURCES = "open_sources"
JOBS = "jobs"
ARTICLES = "articles"
SPEECH = "speech"
REPORT = "report"
package com.machipopo.swag.utils;
/**
* Created by engine on 2017/7/3.
*/
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
package com.machipopo.swag.utils;
import android.content.Context;
import android.net.Uri;
import android.os.Handler;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.MediaSource;
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" profiles="urn:mpeg:dash:profile:isoff-live:2011" type="static" mediaPresentationDuration="PT9.3S" minBufferTime="PT2.0S">
<ProgramInformation></ProgramInformation>
<Period start="PT0.0S">
<AdaptationSet contentType="video" segmentAlignment="true" bitstreamSwitching="true" maxFrameRate="30/1">
<Representation id="0" mimeType="video/mp4" codecs="avc1.640015" bandwidth="593184" width="320" height="568" frameRate="24/1">
<SegmentTemplate timescale="12288" initialization="5a7dbbe424117c69b3a1608a-$RepresentationID$-00000.mp4" media="5a7dbbe424117c69b3a1608a-$RepresentationID$-$Number%05d$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="30720" r=
package com.machipopo.swag.feature.profile.archive
import org.junit.Before
import org.junit.Test
import org.mockito.Mock
import org.mockito.Mockito
class ArchiveTTest {
@Before
@app.route(API_ROOT + FB_WEBHOOK, methods=["GET"])
def fb_webhook():
verification_code = 'I_AM_VERIFICIATION_CODE'
verify_token = request.args.get('hub.verify_token')
if verification_code == verify_token:
return request.args.get('hub.challenge')
@app.route(API_ROOT + FB_WEBHOOK, methods=['POST'])
def fb_receive_message():
message_entries = json.loads(request.data.decode('utf8'))['entry']
for entry in message_entries:
for message in entry['messaging']:
if message.get('message'):
print("{sender[id]} says {message[text]}".format(**message))
return "Hi"