Skip to content

Instantly share code, notes, and snippets.

@gene9
gene9 / asynch-echo-inc.c
Created September 2, 2016 20:29 — forked from jtrindade/asynch-echo-inc.c
Asynchronous echo server (incomplete)
#undef UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stdlib.h>
#include <stdio.h>
@gene9
gene9 / InheritGenericClass.cs
Created April 27, 2016 13:17 — forked from TryJSIL/InheritGenericClass.cs
Generic Inheritance
using System;
public class GenericClass<T> {
public virtual void Method (T value) {
Console.WriteLine("GenericClass<{0}>.Method({1})", typeof(T), value);
}
}
public class MyClass<T> : GenericClass<T> {
public override void Method (T value) {
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
server {
listen 80;
server_name konklone.com;
return 301 https://$host$request_uri;
}
# optional: the 'spdy' at the end of the listen command below turns on SPDY support.
server {
listen 443 ssl spdy;
# create stub, then run flask app in tornado on port 5000 (perhaps with supervisord config below http://supervisord.org/index.html)
#!/usr/bin/env python
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from myflaskapp import app
http_server = HTTPServer(WSGIContainer(app))
@gene9
gene9 / getopt.c
Created October 22, 2015 18:43 — forked from ashelly/getopt.c
"Port of GNU getopt() to Win32 for anyone who's tired of dealing with getopt() calls in Unix-to-Windows ports." Ported by Pete Wilson. Recovered from the Internet Archive's snapshot of www.pwilson.net/sample.html.
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to drepper@gnu.org
before changing it!
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001
Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@gene9
gene9 / minimial-cedet-config.el
Created October 31, 2012 02:56 — forked from alexott/minimial-cedet-config.el
Working configuration for CEDET from bzr & GNU Emacs (with working C++ & Java name completion)
;;; minimial-cedet-config.el --- Working configuration for CEDET from bzr
;; Copyright (C) Alex Ott
;;
;; Author: Alex Ott <alexott@gmail.com>
;; Keywords: cedet, C++, Java
;; Requirements: CEDET from bzr (http://cedet.sourceforge.net/bzr-repo.shtml)
;; Do checkout of fresh CEDET, and use this config (don't forget to change path below)
@gene9
gene9 / clojure-match.clj
Created September 4, 2012 20:38 — forked from ckirkendall/clojure-match.clj
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@gene9
gene9 / gist:2931885
Created June 14, 2012 18:09 — forked from SamSaffron/gist:893878
mini orm
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Reflection.Emit;
using System.Collections.Concurrent;
using System.Data;
using System.Reflection;
@gene9
gene9 / gist:2714357
Created May 16, 2012 22:06 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])