Skip to content

Instantly share code, notes, and snippets.

View ktosiu's full-sized avatar

Marcin Boćkowski ktosiu

View GitHub Profile
#!/usr/bin/env python
## Tiny Syslog Server in Python.
##
## This is a tiny syslog server that is able to receive UDP based syslog
## entries on a specified port and save them to a file.
## That's it... it does nothing else...
## There are a few configuration parameters.
LOG_FILE = 'youlogfile.log'
@ktosiu
ktosiu / echo.py
Last active August 29, 2015 14:08 — forked from jander/echo.py
####################################
# echo.py
####################################
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, division
#!/usr/bin/env python
from base64 import b64decode
from flask import Flask, current_app
from flask_sqlalchemy import SQLAlchemy
from flask_presst import PresstApi, ModelResource
from flask_presst.principal import PrincipalResource
from flask.ext.principal import UserNeed, RoleNeed
"""Simple TCP server for playing Tic-Tac-Toe game.
Use Player-to-Player game mode based on naming auth.
No thoughts about distribution or pub/sub mode
(for monitoring or something like this). Just
basic functionality.
"""
import time
import logging
#!/bin/bash
### Setup a wifi Access Point on Ubuntu 12.04 (or its derivatives).
### make sure that this script is executed from root
if [ $(whoami) != 'root' ]
then
echo "
This script should be executed as root or with sudo:
sudo $0
"
@ktosiu
ktosiu / sc.py
Last active August 29, 2015 14:18 — forked from lichray/sc.py
#!/usr/bin/env python
# Zhihao Yuan <lichray at gmail.com>
SSCMD = 'import -quality 04 -border -frame png:-'
SSCMD_ALT = 'import -quality 04 png:-'
from cStringIO import StringIO
import sys, os
from getopt import getopt
import pygtk
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))
@ktosiu
ktosiu / gevent_poc.py
Created November 18, 2015 16:42 — forked from tmc/gevent_poc.py
gevent + zmq + multiprocessing poc
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple gevent POC to check how to get ZMQ sockets working with
subprocesses spawned by a simple process."""
# this code doesn't seem to work properly; it has a
# tendency to hang at various parts of the req/rep process
# all of this stuff works flawlessly if you change:
@ktosiu
ktosiu / c_json_servlet.c
Created November 22, 2015 23:39 — forked from dcollien/c_json_servlet.c
C program for a libevent server receiving JSON requests and replying with JSON responses over HTTP
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <event.h>
#include <evhttp.h>
@ktosiu
ktosiu / gist:48a8e063d84dca7d5a38
Created November 22, 2015 23:40
jasson json_path test for branch json_path from https://github.com/rogerz/jansson.git
#include <jansson.h>
#include <string.h>
main()
{
json_t *json;
char *result;
// { "top": { "v1" : 1, "v2" : "mama", "a1" : [ 2, { "s1" : "hello" } ] } }