Skip to content

Instantly share code, notes, and snippets.

View gawen's full-sized avatar

Gawen Arab gawen

View GitHub Profile
@superbrothers
superbrothers / main.go
Created September 8, 2016 02:42
http request with context in Go
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
)
@Jxck
Jxck / dtls_api.md
Created May 24, 2016 08:21
OpenSSL DTLS API

OpenSSL DTLS API

The API used for DTLS is mostly the same as for TLS, because of the mapping of generic functions to protocol specifc ones. Some additional functions are still necessary, because of the new BIO objects and the timer handling for handshake messages. The generic concept of the API is described in the following sections. Examples of applications using DTLS are available at [9].

DTLS の API は TLS とほぼ同じ。 BIO オブジェクトの生成とタイマのために追加でいくつか必要。

@loderunner
loderunner / getbroadaddr.c
Last active April 2, 2017 03:13
get broadcast address for an interface
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
#include <netdb.h>
# Unlike Twisted, Tulip and Tornado, gevent can use existing Python libraries:
# Django, Flask, requests, redis-py, SQLAlchemy to name a few
from gevent import monkey; monkey.patch_all()
import gevent
import requests
from flask import Flask
app = Flask(__name__)
@ursachec
ursachec / build-libevent-ios.sh
Last active June 30, 2023 07:22
libevent build script for iOS
#!/bin/bash
set -u
# Setup architectures, library name and other vars + cleanup from previous runs
ARCHS=("armv7" "armv7s" "i386")
SDKS=("iphoneos" "iphoneos" "macosx")
LIB_NAME="libevent-2.0.21-stable"
TEMP_DIR="$(pwd)/tmp"
TEMP_LIB_PATH="$(pwd)/tmp/${LIB_NAME}"
@lepture
lepture / gevent-flask.py
Last active January 30, 2020 15:29
gevent with werkzeug reload and debug
def runserver(port=5000, profile_log=None):
"""Runs a development server."""
from gevent.wsgi import WSGIServer
from werkzeug.serving import run_with_reloader
from werkzeug.debug import DebuggedApplication
from werkzeug.contrib.profiler import ProfilerMiddleware
port = int(port)
if profile_log:
@catwell
catwell / active.md
Last active December 21, 2023 09:47
Speakerdecks
@gawen
gawen / gevent_watchdog.py
Created April 11, 2012 12:58
Python Watchdog with gevent
""" Use watchdogs to make your code safer. (http://en.wikipedia.org/wiki/Watchdog_timer)
Usage:
with watchdog.Watchdog(duration = 1.0):
# Some code which takes less than 1s
# If it takes more, the exception Watchdog.Reset will be raised
# To notify the watchdog the section is still alive, call the method
# 'tick' to reset its internal timer.