Skip to content

Instantly share code, notes, and snippets.

@mywaiting
mywaiting / asyncio_loop_in_thread.py
Created November 14, 2024 08:52 — forked from dmfigol/asyncio_loop_in_thread.py
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable
@mywaiting
mywaiting / 01.js
Created April 15, 2022 06:40 — forked from vielhuber/01.js
Google Translate API Hacking #knowhow #tools
function Bp(a, b) {
var c = b.split(".");
b = Number(c[0]) || 0;
for (var d = [], e = 0, f = 0; f < a.length; f++) {
var h = a.charCodeAt(f);
128 > h ? d[e++] = h : (2048 > h ? d[e++] = h >> 6 | 192 : (55296 == (h & 64512) && f + 1 < a.length && 56320 == (a.charCodeAt(f + 1) & 64512) ? (h = 65536 + ((h & 1023) << 10) + (a.charCodeAt(++f) & 1023), d[e++] = h >> 18 | 240, d[e++] = h >> 12 & 63 | 128) : d[e++] = h >> 12 | 224, d[e++] = h >> 6 & 63 | 128), d[e++] = h & 63 | 128)
}
a = b;
for (e = 0; e < d.length; e++) a += d[e], a = Ap(a, "+-a^+6");
a = Ap(a, "+-3^+b+-f");
@mywaiting
mywaiting / reflect.py
Created April 4, 2017 08:20 — forked from huyng/reflect.py
A simple echo server to inspect http web requests
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@mywaiting
mywaiting / rules-both.iptables
Created November 11, 2015 17:34 — forked from jirutka/rules-both.iptables
Basic iptables template for ordinary servers (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <[email protected]>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is

新闻w

RHEL 7 发布应该算是比较大的新闻了吧~

人民群众纷纷表示红帽步子太大不要扯着蛋了比较好...

F_XZ: 完全没关心...

猫注意的新功能有 virtio 等 KVM 优化, docker 支持, 以及 ruby 2.0, python 2.7, java 7 之类的吧

var list = new Array("Bulgaria", "93.123.23.1/59",
"Egypt", "197.199.253.1/59",
"Egypt", "197.199.254.1/59",
"Hong Kong", "218.189.25.129/187",
"Hong Kong", "218.253.0.76/92", "218.253.0.140/187",
"Iceland", "149.126.86.1/59",
"Indonesia", "111.92.162.4/6", "111.92.162.12/59",
"Iraq", "62.201.216.196/251",
"Japan", "218.176.242.4/251",
"Kenya", "41.84.159.12/30",
@mywaiting
mywaiting / gist:3452130
Created August 24, 2012 15:42 — forked from mitchellh/gist:1241519
reCaptcha field for WTForms
"""
Contains reCaptcha fields for WTForms which can be used
for various forms. This library depends on `recaptcha-client` ~> 1.0.6.
Example usage is below.
Defining a form with a ``RecaptchaField``:
from wtforms import Form
from recaptcha_field import RecaptchaField
@mywaiting
mywaiting / gist:2792038
Created May 26, 2012 03:47 — forked from jparise/gist:2789026
Protocol Buffer Mixin for Tornado
class ProtocolBufferMixin(object):
"""Protocol Buffer support for RequestHandler objects."""
MIMETYPE = 'application/x-protobuf'
def read_protobuf(self, message_type, data):
"""Attempts to parse a protocol buffer message from the given data."""
# Create the message object and attempt to parse the data into it.
try:
message = message_type()
@mywaiting
mywaiting / tornado_static.py
Created May 20, 2012 04:26 — forked from peterbe/tornado_static.py
tornado_static
"""
tornado_static is a module for displaying static resources in a Tornado web
application.
It can take care of merging, compressing and giving URLs ideal renamings
suitable for aggressive HTTP caching.
(c) [email protected]
"""