Skip to content

Instantly share code, notes, and snippets.

@oucb
oucb / hs.md
Created June 21, 2012 06:27 — forked from jackywyz/hs.md
Haskell总结

###haskell 基本类型,bool(True/False),list[],tuple(),int,Integer,Double,char'' ,string"",function(\x->x+1)

  1. wiki
@oucb
oucb / gist:4a6ead1574c72568c2f4d8b60e9384b3
Created June 15, 2018 10:09 — forked from hest/gist:8798884
Fast SQLAlchemy counting (avoid query.count() subquery)
def get_count(q):
count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar()
return count
q = session.query(TestModel).filter(...).order_by(...)
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ...
print q.count()
@oucb
oucb / async-mysql.py
Created August 4, 2018 03:39 — forked from syfun/async-mysql.py
python async mysql redis http
import asyncio
import aiomysql
from aiomysql.cursors import DictCursor
class MysqlWrapper:
def __init__(self, host, port, user, password, db):
self.host = host
self.port = port
@oucb
oucb / run_forever.py
Created August 4, 2018 03:39 — forked from syfun/run_forever.py
python3 asyncio correctry interrupt.
import asyncio
async def task():
while True:
print('Do something.')
await asyncio.sleep(1)
async def run(lp):
@oucb
oucb / partition.py
Created August 30, 2018 01:11 — forked from zhoubaozhou/partition.py
sqlalchemy分表测试代码
#-!-coding:utf-8-!-
# schema
# revision identifiers, used by Alembic.
revision = '507c3af35680'
down_revision = None
from alembic import op
import sqlalchemy as sa
@oucb
oucb / effective-graphql-and-antd.md
Created September 13, 2018 01:06
Effective GraphQL + Antd

高效的 GraphQL + Antd

本文原载于我的独立博客 https://lutaonan.com/blog/effective-graphql-and-antd/

在过去的几年,不论是面向内部的系统,还是面向外部的产品,我们都大量地使用了 Ant.Design —— 一个基于 React 的 UI 组件库。

在做内部系统时,Ant.Design 解决了几乎 60% 的问题。剩下的问题在业务逻辑和代码组织的复杂度。我见过很多内部系统因为滥用状态管理而使代码变得复杂,他们之所以使用状态管理库,并不是因为应用的状态复杂,而是因为需要一个状态树来管理网络请求的状态、接口返回的数据等等这些和接口相关的状态。

真的需要状态管理库吗?在之前,我没有信心回答这个问题。但在使用了 GraphQL (Apollo) 后,我确信,在大多数场景,你不再需要状态管理。

@oucb
oucb / spacemacs global search and replace.md
Created September 13, 2018 07:15 — forked from ivar/spacemacs global search and replace.md
spacemacs - global search and replace

There's a couple of ways, one way is

  • Get search results
    • Do SPC / and type in your search string
    • or SPC x S and search string - where x is your scope indicator (p for project, d for directory, etc..)
  • Once you have the occurences you want, hit C-c C-e inside the helm buffer to put all your match occurences and puts them into a special buffer called the edit buffer or something like that
  • in that buffer you can use any commands you'd normally use on a buffer
  • the C-c C-c to commit your changes.
@oucb
oucb / gotibet_list
Created November 1, 2018 09:59 — forked from ahappyforest/gotibet_list
滇藏线骑行的一些装备, 大家可以补充, 可以根据自己的需要进行选择, 这里列出了一个总的清单!
车子相关:
头盔
驼包
货架
补胎工具
水杯
内胎
码表
V刹皮
强光手电筒(18650电池也要带几块备用)
@oucb
oucb / supervisord.service
Created November 14, 2018 03:24 — forked from mozillazg/supervisord.service
install and configure supervisord on centos 7.
[Unit]
Description=supervisord - Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target
[Service]
Type=forking
ExecStart=/bin/supervisord -c /etc/supervisord/supervisord.conf
ExecReload=/bin/supervisorctl reload
ExecStop=/bin/supervisorctl shutdown