Skip to content

Instantly share code, notes, and snippets.

View FernandoEscher's full-sized avatar
🏠
Working from home

Fernando Irias Escher FernandoEscher

🏠
Working from home
  • Tegucigalpa, Honduras
View GitHub Profile
Febrero 2010
http://www.laprensa.hn/honduras/505754-97/mario-zelaya-nuevo-director-del-seguro
Junio 2010
http://archivo.elheraldo.hn/Ediciones/2010/06/29/Noticias/Lobo-analiza-pago-de-1-523-millones-al-IHSS
Agosto 2010
http://old.latribuna.hn/2010/08/11/doctor-mario-zelaya/
Enero 2011
@FernandoEscher
FernandoEscher / curl-succeeds.sh
Last active August 29, 2015 14:18
Run curl until the request succeeds
until [ $? -eq 0 ]; do curl -I --fail example.com; done
#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"'
@FernandoEscher
FernandoEscher / gist:650909
Created October 28, 2010 08:30
Notification HTML emails
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',
)
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')
@FernandoEscher
FernandoEscher / gist:792865
Created January 24, 2011 05:12
Atributos dinámicos en Python
class Dummy(object):
def __getattribute__(self, name):
f = lambda: 'hola con %s'%name
return f
@FernandoEscher
FernandoEscher / gist:810594
Created February 4, 2011 01:38
Conteo de mensajes por cada usuario
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)
@FernandoEscher
FernandoEscher / JSONResponseHandler.java
Created November 26, 2011 09:53
Android JSONResponseHandler
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();
@FernandoEscher
FernandoEscher / gist:2691561
Created May 14, 2012 03:10
Configuración de Postgresql para Rails
# 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
@FernandoEscher
FernandoEscher / gist:2727188
Created May 18, 2012 19:25
Kill Nginx process
You should not to restart nginx after applying new configuration.
ps aux | egrep '(PID|nginx)'
and kill the PID
kill -HUP PID