Skip to content

Instantly share code, notes, and snippets.

@harrywang
harrywang / config.md
Last active June 10, 2020 14:08
tai-config

Setup

Use V3 from Tai: Screen Shot 2020-06-10 at 9 58 22 AM

python -m venv venv
source venv/bin/activate
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple/
@harrywang
harrywang / lin_reg_full_pipeline.py
Created April 22, 2020 14:15
Linear Regression Full Pipeline Code Snippet
### code snippet ####
from sklearn.linear_model import LinearRegression
lin_reg_full_pipeline = Pipeline(
steps=[
('preprocessor', preprocessor),
('lin_reg', LinearRegression()),
]
)
@harrywang
harrywang / object-detection.json
Created March 14, 2020 14:53
google object detection result
{
"responses": [
{
"localizedObjectAnnotations": [
{
"mid": "/j/5qg9b8",
"name": "Packaged goods",
"score": 0.8396697,
"boundingPoly": {
"normalizedVertices": [
@harrywang
harrywang / ocr.json
Created March 14, 2020 14:45
google ocr result
{
"responses": [
{
"textAnnotations": [
{
"locale": "it",
"description": "Unilever\nDove Dove\n国潮盛富 全民嗨购,\nDe Dove Dove ve\nम\n满88送88礼包\n",
"boundingPoly": {
"vertices": [
{
@harrywang
harrywang / index.html
Created March 6, 2020 21:45 — forked from d3noob/index.html
Interactive tree v4 external json
<!DOCTYPE html>
<meta charset="UTF-8">
<style>
.node circle {
fill: #fff;
stroke: steelblue;
stroke-width: 3px;
}
@harrywang
harrywang / git_exercise.MD
Last active February 13, 2020 23:24
Git Exercise

Git Exercise

  • create a new repo
  • clone to local
  • .gitignore
  • Markdown
  • add a python file and run
  • commit the file and push
  • add another python file
  • commit the file and push
import scrapy
from scrapy.loader import ItemLoader
from tutorial.items import QuoteItem
class QuotesSpider(scrapy.Spider):
name = "quotes"
allowed_domains = ["toscrape.com"]
start_urls = ['http://quotes.toscrape.com/']

use wcba as an example:

login as admin. go to cpanel

Screen Shot 2019-09-22 at 10 38 59 AM

go to subdomain and create a new subdomain:

Screen Shot 2019-09-22 at 10 40 26 AM

class SaveQuotesPipeline(object):
def __init__(self):
"""
Initializes database connection and sessionmaker
Creates tables
"""
engine = db_connect()
create_table(engine)
self.Session = sessionmaker(bind=engine)
from sqlalchemy import create_engine, Column, Table, ForeignKey, MetaData
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (
Integer, String, Date, DateTime, Float, Boolean, Text)
from scrapy.utils.project import get_project_settings
Base = declarative_base()