Skip to content

Instantly share code, notes, and snippets.

View lu911's full-sized avatar
🎯
Focusing

Seungchan Yuk lu911

🎯
Focusing
View GitHub Profile
package com.example.androidta_refort;
public class MainActivity extends Activity {
RadioGroup rg;
ImageView iv;@
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView rtv = (TextView) findViewById(R.id.dtv);
final TextView rtv2 = (TextView) findViewById(R.id.dtv2);
def init_log(app):
import os
if not os.path.exists('logs'):
os.makedirs('logs')
import logging
logging.basicConfig(filename='logs/db.log')
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
#-*- coding:utf8 -*-
import requests
def run():
url = 'http://deview.kr/2014/saveParticipant'
headers = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'http://deview.kr/2014/registParticipant',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 \
import ssl
import socket
ssl_sock = ssl.wrap_socket(
socket.socket(socket.AF_INET, socket.SOCK_STREAM),
ssl_version=ssl.PROTOCOL_SSLv3,
certfile=CERT_FILE
)
ssl_sock.connect(APNS_SERVER)
query = query.with_entities(Item.id).paginate(page, 60, False)
_items = []
for item in query.items:
item = Item.get_by_id(int(item[0]))
if item:
_items.append(item.serialize())
SELECT items.id AS items_id, items.created_at AS items_created_at, items.updated_at AS items_updated_at, items.origin_id AS items_origin_id, items.origin_category_id AS items_origin_category_id, items.origin_photo_url AS items_origin_photo_url, items.name AS items_name, items.price AS items_price, items.sale_price AS items_sale_price, items.description AS items_description, items.redirect_url AS items_redirect_url, items.view_count AS items_view_count, items.category_id AS items_category_id, items.mall_id AS items_mall_id
FROM items INNER JOIN categories ON categories.id = items.category_id
WHERE categories.id = 10000 OR categories.id = 10100 OR categories.id = 10200 OR categories.id = 10300 OR categories.id = 10400 OR categories.id = 10500 OR categories.id = 10501 OR categories.id = 10502 OR categories.id = 10503 OR categories.id = 10504 OR categories.id = 10505 OR categories.id = 10500 OR categories.id = 10600 OR categories.id = 10700 OR categories.id = 10701 OR categories.id = 10702 OR categories.id = 1070
# -*- coding: utf-8 -*-
from flask import Flask, request
from config import DefaultConfig
from extensions import db
def create_app(_config=DefaultConfig()):
app = Flask(__name__)
app.config.from_object(_config)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/loup/Desktop/projects/new_kidsmamma/kidsmamma/models/mixins.py", line 14, in get_by_id
return cls.query.get(int(id))
File "/home/loup/.virtualenvs/new-kidsmamma/local/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 426, in __get__
mapper = orm.class_mapper(type)
File "/home/loup/.virtualenvs/new-kidsmamma/local/lib/python2.7/site-packages/sqlalchemy/orm/base.py", line 378, in class_mapper
mapper = _inspect_mapped_class(class_, configure=configure)
File "/home/loup/.virtualenvs/new-kidsmamma/local/lib/python2.7/site-packages/sqlalchemy/orm/base.py", line 355, in _inspect_mapped_class
mapper._configure_all()
TITLE = 'healthcare'
class Category(CRUDMixin, db.Model):
__tablename__ = '%s_categories' % TITLE
name = db.Column(db.String(16), nullable=False)
type_code = db.Column(db.SmallInteger, default=ETC_TYPE, nullable=False)
parent_category_id = db.Column(db.Integer, db.ForeignKey('%s.id' % __tablename__))
children = db.relationship('Category', cascade='all',
@lu911
lu911 / models.py
Last active August 29, 2015 14:00
Category Model
class Category(IdMixin, CRUDMixin, db.Model):
__tablename__ = '%s_categories' % TITLE
name = db.Column(db.String(16), nullable=False)
type_code = db.Column(db.SmallInteger, default=ETC_TYPE, nullable=False)
parent_category_id = db.Column(db.Integer, db.ForeignKey('%s.id' % __tablename__))
children = db.relationship('Category', cascade='all',
backref=db.backref('parent_category', remote_side='%s.c.id' % __tablename__))
def __init__(self, name, type_code=None, parent_category_id=None):