Skip to content

Instantly share code, notes, and snippets.

View shangliuyan's full-sized avatar

leo shang shangliuyan

View GitHub Profile
@patidardhaval
patidardhaval / README.md
Last active June 1, 2024 14:31
Node Rest api using hapi and mysql

NodeRestful

Create Node Restful APIs with MySQL Database

Install Node JS and MySQL Software, create a database and import SQL file.

Go to terminal or command line.

Execute following commands to run this application.

Start Project

@IrSent
IrSent / celery.py
Created November 12, 2016 19:12
Celery Best Practices
# Safe Queue Celery App Settings
from __future__ import absolute_import, unicode_literals
from celery import Celery
app = Celery('some_project',
broker='amqp://',
backend='amqp://',
include=['some_project.tasks'])
@snakevil
snakevil / docker-and-the-pid-1-zombie-reaping-problem.md
Last active March 21, 2023 12:30
【译】Docker 和子进程“僵尸化”问题

【译】Docker 和子进程“僵尸化”问题

作者 Hongli Lai 看着像是华人,可惜没找到文章的中文版本,于是就很土鳖地手翻了一遍。文章的措辞很口语化,因此意译为主。点击这里可以阅读原文。


在构建 Docker 容器时,我们需要注意子进程的“僵尸化”问题(PID 1 Zombie Reaping Problem)。这会导致不可预知的和看起来匪夷所思的问题。本文解释了这个问题,也解释了如何去解决,并提供了一种预构建方案:Baseimage-docker 。

@jbuck
jbuck / rqmetrics.sh
Created June 3, 2016 19:48
Read RQ metrics and put into CloudWatch
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
COUNT=60
REDIS_HOST=$2
@shelwinnn
shelwinnn / crawl.py
Last active July 6, 2016 07:52 — forked from venkat/crawl.py
Using gevent to crawl 100 links given a seed link, based off of http://blog.hownowstephen.com/post/50743415449/gevent-tutorial
# monkey-patch
import gevent.monkey
gevent.monkey.patch_all()
import gevent.pool
import gevent.queue
import sys
import re
import requests
@drgarcia1986
drgarcia1986 / __main__.py
Last active August 9, 2023 21:20
Example of OAuth2 autentication server with Client Credentials grant (using python-oauth2 and tornado)
# !/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Diego Garcia'
import tornado.web
import tornado.ioloop
import oauth2.tokengenerator
import oauth2.grant
import oauth2.store.redisdb
import oauth2.store.mongodb
function scroll_to(splash, x, y)
local js = string.format(
"window.scrollTo(%s, %s);",
tonumber(x),
tonumber(y)
)
return splash:runjs(js)
end
@johnpaulhayes
johnpaulhayes / celery_tasks.py
Created January 13, 2014 16:22
correct task definitions when using tasks by name.
from celery_app import Celery
celery = Celery("tasks", backend="amqp", broker="amqp://guest@localhost")
@celery.task(name='test_task')
def test_task():
return "boom!"
@jqlblue
jqlblue / sentry.conf.py
Created December 18, 2013 06:38
sentry config example
# This file is just Python, with a touch of Django which means you
# you can inherit and tweak settings to your hearts content.
from sentry.conf.server import *
import os.path
CONF_ROOT = os.path.dirname(__file__)
DATABASES = {
'default': {
# You can swap out the engine for MySQL easily by changing this value
@pckujawa
pckujawa / a4.py
Created December 15, 2013 20:17
Simple audio classifier (speech vs music) using scikit-learn (Naive Bayes classifier). Made for Multimedia Processing course.
""" usage:
a4.py train TRAIN_FEATURE_FILE [--new] [--validate]
a4.py classify MUSIC_FEATURE_FILE
The files should be CSV with 6 columns, the last of which is the target/label/class (or empty, if classifying), and the first of which is ignored.
"""
#-------------------------------------------------------------------------------
# Name: Pat Kujawa
# Purpose: MM audio classification asn 4
#-------------------------------------------------------------------------------