Skip to content

Instantly share code, notes, and snippets.

View ryerh's full-sized avatar
🎯
Focusing

荷包蛋扣肉 ryerh

🎯
Focusing
View GitHub Profile
@ryerh
ryerh / ProcessPoolExecutor.py
Last active February 3, 2021 06:05
Python3 多进程并行
import random
import time
from concurrent import futures
def run_parallel_processes(worker_func, job_args, max_workers=None):
"""
每个进程执行一个 worker_func,
每个 worker_func 只从 job_args 中取一条任务处理,
最大并行粒度 max_workers 默认等于 CPU 核心数量。
@ryerh
ryerh / ui_thread.cs
Created December 1, 2020 03:00
UI Thread
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
private void buttonSyntacParse_Click(object sender, EventArgs e)
{
//依存句法分析
var dictMode = new Dictionary<string, int>{
{"web模型", 0},
{"query模型", 1}
};
var options = new Dictionary<string, object>{
{"mode", dictMode[comboBoxSyntacParse.Text.ToString()]}};
var result = client.DepParser(textBoxLexiAnaly.Text, options);
@ryerh
ryerh / sqlalchemy_middleware.py
Created February 12, 2019 10:04 — forked from ar45/sqlalchemy_middleware.py
Quick dirty SQLAlchemy middleware for django < 1.9
from sqlalchemy.engine import create_engine
from sqlalchemy.orm import sessionmaker
def create_engine_from_django_settings(database='default'):
from django.conf import settings
db = settings.DATABASES[database]
engine = db['ENGINE'].lower()
if 'postgresql' in engine:
sqlalchemy_engine = 'postgresql'
@ryerh
ryerh / .editorconfig
Last active December 29, 2018 15:05
EditorConfig for web developers
# https://editorconfig.org
# https://gist.github.com/ryerh/4c9215a95cc8d8c4872f1ca43d52dbda
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
@ryerh
ryerh / Component.tsx
Last active December 7, 2022 13:46
multiple react component decorators in typescript
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import { RouteComponentProps, Form } from 'antd';
import compose from './compose';
interface DecoratorProps {
id: number;
}
@ryerh
ryerh / ajax.js
Created May 3, 2018 07:39
jQuery ajax
import jQuery from 'jquery';
jQuery.ajax({
type: 'POST',
url: 'https://api.github.com',
contentType: 'application/json; charset=UTF-8',
processData: false,
data: JSON.stringify({ foo: 'bar' }),
@ryerh
ryerh / jekyll-and-liquid.md
Created April 16, 2018 15:35 — forked from magicznyleszek/jekyll-and-liquid.md
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes:

@ryerh
ryerh / App.jsx
Last active January 1, 2018 03:06
import React from 'react';
import PropTypes from 'prop-types';
class App extends React.Component {
render() {
const { menu } = this.context;
return menu === '????'
? <h1>???</h1>
: <h1>xxx</h1>;
}