This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/std@0.181.0/http/server.ts"; | |
async function handleRequest(request: Request): Promise<Response> { | |
if (request.method === "OPTIONS") { | |
return handleOPTIONS(request); | |
} | |
const url = new URL(request.url); | |
url.host = "api.groq.com"; | |
url.pathname = "/openai" + url.pathname; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wrk.path = "/rest/ping" | |
wrk.method = "POST" | |
wrk.body = "id=7579764573763278289&platformid=ANDROID&version=1.0.0" | |
wrk.headers["Content-Type"] = "application/x-www-form-urlencoded" | |
wrk.headers["deviceid"] = "354435052821931" | |
wrk.headers["Accept"] = "application/json" | |
logfile = io.open("wrk.log", "w"); | |
local cnt = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import urllib, urllib2, json | |
RPC_URL = 'http://192.168.1.2/jsonrpc' | |
def pushStream(stream, rpc=RPC_URL): | |
''' | |
Push stream URL to XBMC jsonrpc api, XBMC play the streaming. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gevent.wsgi import WSGIServer | |
from prometheus_client import multiprocess | |
from prometheus_client import generate_latest, CollectorRegistry, CONTENT_TYPE_LATEST | |
# Expose metrics. | |
def app(environ, start_response): | |
registry = CollectorRegistry() | |
multiprocess.MultiProcessCollector(registry) | |
data = generate_latest(registry) | |
status = '200 OK' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:utf-8 -*- | |
""" | |
一个基于thread和queue的线程池,以任务为队列元素,动态创建线程,重复利用线程, | |
通过close和terminate方法关闭线程池。 | |
""" | |
import queue | |
import threading | |
import contextlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *server) respond(w http.ResponseWriter, r *http.Request, data interface{}, status int) { | |
w.WriteHeader(status) | |
if data != nil { | |
err := json.NewEncoder(w).Encode(data) | |
s.logf("json encode %s", err) | |
} | |
} | |
func (s *server) decode(w http.ResponseWriter, r *http.Request, v interface{}) error { | |
return json.NewDecoder(r.Body).Decode(v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
import ( | |
"reflect" | |
"unsafe" | |
) | |
func BytesToString(b []byte) string { | |
return *(*string)(unsafe.Pointer(&b)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -w %{time_connect}:%{time_starttransfer}:%{time_total} -X POST 'http://service-uri' -H 'Content-Type: application/json' --data 'post-data' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from tornado import gen | |
from tornado import httpclient | |
from tornado import httputil | |
from tornado import ioloop | |
from tornado import websocket | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from __future__ import print_function | |
import re | |
import sys | |
filter = re.compile(r'site-packages/requests/.*') | |
def tracer(frame, event, args): |
NewerOlder