Skip to content

Instantly share code, notes, and snippets.

View wujianguo's full-sized avatar

Jianguo Wu wujianguo

View GitHub Profile
@wujianguo
wujianguo / openai-proxy.py
Last active May 21, 2023 12:03
openai chatgpt python flask proxy 代理,支持 SSE
from flask import Flask, request, Response
import requests, logging
_FIELD_SEPARATOR = ':'
class SSEClient(object):
"""Implementation of a SSE client.
See http://www.w3.org/TR/2009/WD-eventsource-20091029/ for the
specification.
"""
@wujianguo
wujianguo / Seven-segment_display.c
Created August 16, 2018 03:26
Seven-segment_display
typedef struct point {
double x,y;
} POINT;
typedef struct ray {
POINT p,v;
} RAY;
typedef struct polygon {
int n;
@wujianguo
wujianguo / docker-compose.yml
Created February 15, 2017 11:44
gitlab docker-compose
web:
image: 'gitlab/gitlab-ce:latest'
restart: always
hostname: 'gitlab.wujianguo.org'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://gitlab.wujianguo.org/'
nginx['listen_port'] = 8980
gitlab_rails['gitlab_shell_ssh_port'] = 8922
gitlab_rails['time_zone'] = "Asia/Shanghai"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
pass
if __name__ == '__main__':
main()
@wujianguo
wujianguo / UIImageView+setImageWithURL.swift
Created November 3, 2015 09:55
UIImageView set image with url
extension UIImageView {
func setImageWithUrlString(str: String?) {
if let url = NSURL(string: str ?? "") {
setImageWithURL(url)
}
}
func setImageWithURL(url: NSURL) {
NSURLSession.sharedSession().dataTaskWithURL(url) { (data, response, error) -> Void in
dispatch_async(dispatch_get_main_queue()) { () -> Void in
@wujianguo
wujianguo / GesturePasswordView.swift
Created November 3, 2015 09:46
ios swift Gesture Password
//
// GesturePasswordView.swift
// GesturePassword
//
// Created by wujianguo on 15/10/16.
// Copyright © 2015 wujianguo. All rights reserved.
//
import UIKit
@wujianguo
wujianguo / CanDeleteCollectionViewCell.swift
Last active November 3, 2015 09:36
can delete collection view cell
import UIKit
protocol CollectionViewCellDeleteDelegate: class {
func collectionViewCellDeleteClick(cell: UICollectionViewCell)
func collectionViewDidSelectCell(cell: UICollectionViewCell)
}
class CanDeleteCollectionViewCell: UICollectionViewCell, UIScrollViewDelegate {
@wujianguo
wujianguo / CheckVersion.swift
Last active November 3, 2015 09:32
ios swift check version
func checkVersion(appID: String, complete: (hasNewVersion: Bool, downloadAddr: String?) -> Void) {
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: "https://itunes.apple.com/lookup?id=\(appID)")!) { (data, response, error) -> Void in
dispatch_async(dispatch_get_main_queue()) { () -> Void in
if error != nil || data == nil {
complete(hasNewVersion: false, downloadAddr: nil)
return
}
do {
let json = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers)
if let all = json as? NSDictionary {
@wujianguo
wujianguo / Util.swift
Last active November 3, 2015 09:40
ios swift util
import UIKit
extension UIColor {
/**
* Initializes and returns a color object for the given RGB hex integer.
*/
public convenience init(rgb: Int) {
self.init(