Skip to content

Instantly share code, notes, and snippets.

View vimiix's full-sized avatar
🧱
Coding

Vimiix Yao vimiix

🧱
Coding
View GitHub Profile
@vimiix
vimiix / libpq-demo.cc
Created August 4, 2023 10:34 — forked from ictlyh/libpq-demo.cc
libpq examples.
/*
* Demo of libpq.
* Build: g++ libpq-demo.cc -o libpq-demo -lpq
* Run: ./libpq-demo
*/
#include <arpa/inet.h>
#include <iostream>
#include <libpq-fe.h>
#include <sstream>
@vimiix
vimiix / Makefile
Created November 30, 2020 08:26 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@vimiix
vimiix / simple_python_datasource.py
Created July 10, 2019 08:54 — forked from linar-jether/simple_python_datasource.py
Grafana python datasource - using pandas for timeseries and table data. inspired by and compatible with the simple json datasource
from flask import Flask, request, jsonify, json, abort
from flask_cors import CORS, cross_origin
import pandas as pd
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
@vimiix
vimiix / github.css
Created February 2, 2019 07:34 — forked from andyferra/github.css
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@vimiix
vimiix / brower.py
Created April 10, 2018 11:13 — forked from the5fire/brower.py
简单理解socket模拟浏览器请求
# author: the5fire.com
import re
import socket
from collections import namedtuple
RE_URL = re.compile(r'http://(.*)')
RE_CONTENT_LENGTH = re.compile(b'.*Content-Length: (\d+)')
EOF = '\r\n\r\n'
Response = namedtuple('Response', ['header', 'body'])
@vimiix
vimiix / secrets.py
Created February 1, 2018 08:14 — forked from onjin/secrets.py
python 3.6 secrets module
"""Generate cryptographically strong pseudo-random numbers suitable for
managing secrets such as account authentication, tokens, and similar.
See PEP 506 for more information.
https://www.python.org/dev/peps/pep-0506/
"""
__all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom',
'token_bytes', 'token_hex', 'token_urlsafe',
@vimiix
vimiix / RESTMiddleware.py
Created January 9, 2018 06:51 — forked from g00fy-/RESTMiddleware.py
Simple Django Middleware for handling Form & Multipart Form PUT & DELETE methods AKA REST (GET,POST,PUT,DELETE)
from django.http import QueryDict
from django.http.multipartparser import MultiValueDict
class RESTMiddleware(object):
def process_request(self,request):
request.PUT=QueryDict('')
request.DELETE = QueryDict('')
method = request.META.get('REQUEST_METHOD','').upper() #upper ? rly?
if method == 'PUT':
self.handle_PUT(request)