Skip to content

Instantly share code, notes, and snippets.

View xpostudio4's full-sized avatar

Leonardo xpostudio4

View GitHub Profile
@xpostudio4
xpostudio4 / index.md
Last active September 19, 2015 08:59 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@xpostudio4
xpostudio4 / example2a.java
Created October 4, 2016 17:10
Refactoring: Growing Software like a Gardener
class Person..
public String getName(){
return _name;
}
public String getTelephoneNumber() {
return ("(" + _officeAreaCode + ")" + _officeNumber);
}
public getOfficeAreaCode(){
@xpostudio4
xpostudio4 / extending0.py
Last active October 4, 2016 17:53
Refactoring: Growing Software like a Gardener
class SimpleGradebook(object):
def __init__(self):
self.__grades = {}
def add_student(self, name):
self._grades[name] = []
def report_grade(self, name, score):
self._grades[name].append(score)
@xpostudio4
xpostudio4 / original.py
Created October 4, 2016 18:48
Refactoring: Growing Software like a Gardener
@login_required(redirect_field_name="/")
def uploaded_pictures(request):
pictures = AdPicture.objects.filter(user=request.user, ad__isnull=True)
json_pics = [{'name': pic.picture.name.split("/")[-1],
'uuid': pic.uuid,
'size': pic.picture.size,
'thumbnailUrl': pic.picture.url} for pic in pictures]
return JsonResponse(json_pics, safe=False)