Skip to content

Instantly share code, notes, and snippets.

View aaronromeo's full-sized avatar
:shipit:

Aaron Romeo aaronromeo

:shipit:
View GitHub Profile
@aaronromeo
aaronromeo / gist:9892066
Created March 31, 2014 13:17
Dealing with multiple models in a Django CBVs and ModelForms
class UserProfile(models.Model):
user = models.OneToOneField(User)
avatar = models.ImageField(upload_to='profile_images', blank=True)
def __unicode__(self):
return self.user.username
class RegistrationForm(forms.Form):
@aaronromeo
aaronromeo / models.py
Created May 3, 2014 13:07
Storing images on S3 with Django

You'll need these libraries

  • pip install Pillow
  • pip install django-storages
  • pip install boto
@aaronromeo
aaronromeo / gist:3b701a02cbbd139465b6
Created June 12, 2014 14:21
New Django DB Creation
#!/bin/bash
createuser -d -A -P $DB_USER
createdb -U $DB_USER -E utf8 -O $DB_USER $DB_NAME -T template0

Keybase proof

I hereby claim:

  • I am aaronromeo on github.
  • I am aaronromeo (https://keybase.io/aaronromeo) on keybase.
  • I have a public key whose fingerprint is 7B74 D603 0775 0C76 53DC 522E 3D2C DFF9 58B0 7091

To claim this, I am signing this object:

@aaronromeo
aaronromeo / gist:7969396f107ffea4e298
Last active August 29, 2015 14:04
Useful commands for initial Ubuntu server setup

Update the default editor so we aren't living in squalor

> sudo update-alternatives --config editor

Update the root password and add the hotstuff user

> passwd
> adduser hotstuff
> visudo

Working though some stuff with shell plus I had a multi-line function that I needed to debug. I came across %cpaste which is a handy magic function exposing the capability to be able to drop a block of code into ipython or shellPlus.

@aaronromeo
aaronromeo / gist:cf0f613248cd38b3a4ed
Last active August 29, 2015 14:09
Using Mandrill headers with Django's email framework
from django.core.mail import EmailMessage
email = EmailMessage(
# subject='',
# body='',
from_email='from@example.com',
to=['to+1@example.com', 'to+2@example.com'],
bcc=['bcc@example.com'],
headers={
'X-MC-Template': 'template-slug',
@aaronromeo
aaronromeo / gist:23e133a6689d7c1a47b1
Created November 22, 2014 17:32
Django Rest Framework notes

Django Rest Framework notes

Field conversion using the django rest framework has not been overly intuitive. This might help

  • to_native - Object -> End User (json)
    • This is used to convert a complex object to a primitive Python types
  • from_native - End User (json) -> Object
    • This is used to convert primitive Python types to a complex object

Also see this example from the documentation.

@aaronromeo
aaronromeo / setup.md
Last active March 29, 2017 22:00
Setting up Protractor tests for Ionic on CodeShip

Under Test Settings

'Select your technology to prepopulate basic commands' as Node.js

Setup Commands

# By default we use the Node.js version set in your package.json or the latest
# version from the 0.10 release
#
# You can use nvm to install any Node.js (or io.js) version you require.
@aaronromeo
aaronromeo / 0_reuse_code.js
Created January 22, 2016 14:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console