Skip to content

Instantly share code, notes, and snippets.

@amaudy
amaudy / settings.py
Created June 23, 2013 03:10
Django settings
import os
import django
DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
STATIC_ROOT = 'static'
# URL prefix for static files.
@amaudy
amaudy / laravel3-controller-action.md
Created October 3, 2013 03:59
Get Controller name and action name in Laravel 3

Request::$route

echo "<pre>";
print_r(Request::$route);
echo "</pre>";

Request::$route->controller

@amaudy
amaudy / README.md
Created November 19, 2013 13:39 — forked from rduplain/README.md

This demonstrates that you can configure a Flask application through Flask-Script, without having to create a Flask instance or deal with circular dependencies. Note that Flask-Script's Manager accepts a factory function in place of a Flask app object.

Running:

python manage.py runserver

gives "Hello, world!" on http://localhost:5000/, while running:

python manage.py runserver -c development.cfg
@amaudy
amaudy / flask-logging-file.py
Created December 1, 2013 04:40
File logging example for Flask
import logging
from logging.handlers import RotatingFileHandler
from flask import Flask
app = Flask(__name__)
@app.route('/')
def foo():
app.logger.warning('Some warning occurred (%d things)', 42)
@amaudy
amaudy / Makefile
Last active December 30, 2015 03:29
1. Create file "Makefile" inside project directory 2.
help:
@echo "make si setup all requirements"
@echo "make love switch to virtual environment"
@echo "make up Run the server"
si:
pip install -r requirements.txt
@amaudy
amaudy / webfaction-ssh.md
Last active January 1, 2016 19:39
add public keys to webfaction server.

The procedure for setting up automatic private/public key login on our servers is as follows:

  • On your own machine, go to $HOME/.ssh and type: ssh-keygen -t dsa
  • When prompted for it, leave the default location for the file and enter passphrase as you want
  • Copy the content of the id_dsa.pub file that just got created into the $HOME/.ssh/authorized_keys and authorized_keys2 on our machine.

Set the following permissions:

chmod 644 $HOME/.ssh/authorized_keys*
#!/bin/bash
# passwordless sudo
echo "%sudo ALL=NOPASSWD: ALL" >> /etc/sudoers
# public ssh key for vagrant user
mkdir /home/vagrant/.ssh
wget -O /home/vagrant/.ssh/authorized_keys "https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub"
chmod 755 /home/vagrant/.ssh
chmod 644 /home/vagrant/.ssh/authorized_keys
@amaudy
amaudy / ningx.sh
Created February 9, 2014 08:13
Nginx init script for Openresty on Ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d dash script for Ubuntu <=9.10.
# Description: nginx init.d dash script for Ubuntu <=9.10.
### END INIT INFO
@amaudy
amaudy / .htaccess
Created February 14, 2014 08:55
Turn php short_open_tag on
<IfModule mod_php5.c>
php_value short_open_tag 1
</IfModule>