This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add this file in your /home/<username>/ dir. | |
#You can add extra aliases if you want. | |
#Run this command on shell after adding a alias: $ . /home/<username>/.bash_aliases | |
alias git-log='git log --decorate --stat --graph --pretty=format:"%Cgreen%h%Creset (%ar - %Cred%an%Creset), %s%n"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_now(users, label, extra_context=None, on_site=True, context=None): | |
""" | |
Creates a new notice. | |
This is intended to be how other apps create new notices. | |
notification.send(user, 'friends_invite_sent', { | |
'spam': 'eggs', | |
'foo': 'bar', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def page_management(request, items, num_items): | |
""" | |
Gets the page data from the post of a request. | |
Returns a dict with the actual page information. | |
""" | |
page_change = request.POST.get('quiz_page_change', '') | |
paginator = Paginator([item for item in items], num_items) | |
if page_change == 'Previous': | |
page_to_render = request.POST.get('prev_page', '1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dummy(object): | |
def __getattribute__(self, name): | |
f = lambda: 'hola con %s'%name | |
return f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.db.models import Count | |
ul = User.objects.annotate(Count('_message_set')) | |
for u in ul: | |
print '%s: %s'%(u.username, u._message_set__count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JSONResponseHandler implements ResponseHandler<Object>{ | |
final static String TAG = "JSONResponseHandler"; | |
@Override | |
public Object handleResponse(HttpResponse response) | |
throws HttpResponseException, IOException { | |
StatusLine statusLine = response.getStatusLine(); | |
HttpEntity entity = response.getEntity(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install latest version of postgresql | |
sudo apt-get install postgresql | |
# Access the console with the postgres role to the postgres database | |
sudo -u postgres psql postgres | |
# Create rol YourAppName | |
create role YourAppName with createdb login password 'YourAppRolePassword'; | |
# Verify that the rol has been created |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You should not to restart nginx after applying new configuration. | |
ps aux | egrep '(PID|nginx)' | |
and kill the PID | |
kill -HUP PID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :rvm_ruby_string, '1.9.3-p0@ccepreb' | |
set :rvm_install_type, :stable | |
set :rvm_install_ruby, :install | |
require "rvm/capistrano" | |
# server details | |
default_run_options[:pty] = true | |
set :application, "your_app" | |
server "ip_or_domain", :app, :web, :db, :primary => true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name juegoaprendo.hn www.juegoaprendo.hn ccepreb.hn www.ccepreb.hn ccepreb.fernandoirias.com; | |
root /opt/projects/ccepreb/current/public; # <--- be sure to point to 'public'! | |
passenger_enabled on; | |
client_max_body_size 50M; | |
} |
OlderNewer