Skip to content

Instantly share code, notes, and snippets.

View MadFaill's full-sized avatar

Nikolay MadFaill

View GitHub Profile
@MadFaill
MadFaill / app.py
Last active August 29, 2015 14:16 — forked from miku/app.py
#!/usr/bin/env python
# http://stackoverflow.com/questions/14180179/eventlet-spawn-doesnt-work-as-expected/14180227#14180227
from flask import Flask
import time
import eventlet
eventlet.monkey_patch()
app = Flask(__name__)
======================================
Setting up Nginx, uWSGI and Python3
======================================
First off, I'm traditionally a PHP developer, but am looking at moving across to Python. I really struggled to find decent documentation on how to get a server up and running for deploying Python web applications from the point of view of someone coming from PHP. The main problems I came across with documentation were:
1) Only showed you how to run the server for a single web application.
2) Only showed you how to configure the app, not the server it was running on.
My preferred workflow for development is by setting up a new VM in VMware Fusion and then forwarding through all requests to that VM via /etc/hosts. This might not be the optimal way to get things up and running, but it works for me.
@MadFaill
MadFaill / _chi2.c
Last active August 29, 2015 14:25 — forked from dfm/_chi2.c
How to wrap C code in Python
#include <Python.h>
#include <numpy/arrayobject.h>
#include "chi2.h"
/* Docstrings */
static char module_docstring[] =
"This module provides an interface for calculating chi-squared using C.";
static char chi2_docstring[] =
"Calculate the chi-squared of some data given a model.";
@MadFaill
MadFaill / README.md
Last active October 21, 2015 11:33
python ext example

python ext example

  • sudo apt-get update
  • sudo apt-get install python-dev -y
  • python setup.py install
  • python foo_test.py
@MadFaill
MadFaill / composer.json
Last active August 29, 2015 14:28 — forked from 256cats/composer.json
Web scraping ReactPHP Curl Proxies, curl multi example, scraping news ycombinator, explanation here: http://256cats.com/fast-scraping-with-reactphp-curl-proxies/
{
"require": {
"khr/react-curl": "~2.0",
"sunra/php-simple-html-dom-parser": "~1.5"
}
}
@MadFaill
MadFaill / _config.yml
Last active September 1, 2015 09:49 — forked from adamjspooner/_config.yml
A Jekyll plugin to convert .styl to .css.
stylus:
compress: true
path: ./path/to/styl
@MadFaill
MadFaill / app.php
Created October 6, 2015 21:50
Прикручивание Donctrine ORM к сайлекс без сервиса
<?php
require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/boot.php';
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Synfony\Component\HttpFoundation\Response;
$app = new Application();
@MadFaill
MadFaill / silex-sf2-controllers.rst
Created October 9, 2015 23:55 — forked from kix/silex-sf2-controllers.rst
How to use controllers like in Symfony2 framework

How to use controllers like in Symfony2 framework

In Silex, the most common way to define the controller of a route is with a closure. But when your project gets bigger, you want to organize your code in classes. You can use the syntax ClassName::methodName in your route definition instead of a function () { ... } but you have to inject the Silex\Application $app as a parameter on each method of your controller class, which can become quite boring.

@MadFaill
MadFaill / echo.go
Created January 22, 2016 17:50 — forked from paulsmith/echo.go
A simple echo server testing a few interesting Go language features, goroutines and channels.
// $ 6g echo.go && 6l -o echo echo.6
// $ ./echo
//
// ~ in another terminal ~
//
// $ nc localhost 3540
package main
import (