Steps with explanations to set up a server using:
- virtualenv
- Django
- nginx
- uwsgi
# Simple version for Python 2.7+ | |
my_ordered_dict = json.loads(json_str, object_pairs_hook=collections.OrderedDict) | |
# Or for Python 2.4 to 2.6 | |
import ordereddict | |
my_ordered_dict = json.loads(json_str, object_pairs_hook=ordereddict.OrderedDict) |
#include <iostream> | |
using namespace std; | |
class Nodo | |
{ | |
public: | |
Nodo(int numero, Nodo *siguiente = NULL) | |
{ | |
this->numero = numero; | |
this->siguiente = siguiente; |
require 'rubygems' | |
require 'bcrypt' | |
require 'haml' | |
require 'sinatra' | |
enable :sessions | |
userTable = {} | |
helpers do |
require 'rubygems' | |
require 'sinatra' | |
set :username,'Bond' | |
set :token,'shakenN0tstirr3d' | |
set :password,'007' | |
helpers do | |
def admin? ; request.cookies[settings.username] == settings.token ; end | |
def protected! ; halt [ 401, 'Not Authorized' ] unless admin? ; end |
ActiveSupport::Inflector.inflections do |inflect| | |
inflect.plural /([aeiou])([A-Z]|_|$)/, '\1s\2' | |
inflect.plural /([rlnd])([A-Z]|_|$)/, '\1es\2' | |
inflect.plural /([aeiou])([A-Z]|_|$)([a-z]+)([rlnd])($)/, '\1s\2\3\4es\5' | |
inflect.plural /([rlnd])([A-Z]|_|$)([a-z]+)([aeiou])($)/, '\1es\2\3\4s\5' | |
inflect.singular /([aeiou])s([A-Z]|_|$)/, '\1\2' | |
inflect.singular /([rlnd])es([A-Z]|_|$)/, '\1\2' | |
inflect.singular /([aeiou])s([A-Z]|_)([a-z]+)([rlnd])es($)/, '\1\2\3\4\5' | |
inflect.singular /([rlnd])es([A-Z]|_)([a-z]+)([aeiou])s($)/, '\1\2\3\4\5' |
Rails 3.1 gives us a really easy way to authenticate users in our app: http_basic_authenticate_with
. Using it, all we need to do is create a model for the user (certainly, User model :P) with an attribute called password_digest and some views feature for login and register users. After all, let's relax and let Rails do the hard work.
gem 'bcrypt-ruby', '~> 3.0.0'
First at all, an User model which we can generate by following:
rails g model user email:string password_digest:string
and then add the following methodo call to generated class:
has_secure_password
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
__author__ = 'efrenfuentes' | |
MONEDA_SINGULAR = 'bolivar' | |
MONEDA_PLURAL = 'bolivares' | |
CENTIMOS_SINGULAR = 'centimo' |
module NumeroALetras | |
module Numeric | |
def self.included(recipiente) | |
recipiente.extend(ClassMethods) | |
recipiente.class_eval do | |
include InstanceMethods | |
end | |
end | |
end | |
from elixir.statements import Statement | |
from sqlalchemy.orm.mapper import MapperExtension | |
import types | |
def proxy_to_instance(name): | |
def new_func(self, mapper, connection, instance): | |
if hasattr(instance, name) : getattr(instance, name)() | |
return new_func |