Skip to content

Instantly share code, notes, and snippets.

View airsoull's full-sized avatar

Cristian Sepúlveda airsoull

View GitHub Profile
@gourneau
gourneau / tasty_put.py
Created April 8, 2011 20:56
PUT to a tastypie API
#This is a little example of how to make a PUT request (see http://microformats.org/wiki/rest/urls )
#To a API written with tastypie (https://github.com/toastdriven/django-tastypie )
# import the standard JSON parser
import json
# import the REST library (from http://code.google.com/p/python-rest-client/)
from restful_lib import Connection
#site url
base_url = "http://IP/api/v1"
@sleekslush
sleekslush / formset_updateview_example.py
Created January 6, 2012 06:42
An example of extending UpdateView to use a formset instead of a form
class UserUpdateView(AuthenticatorViewMixin, UpdateView):
model = User
template_name = 'manager/authenticator/user_list.html'
def get_form_class(self):
return modelformset_factory(User, extra=0)
def get_form_kwargs(self):
kwargs = super(UserUpdateView, self).get_form_kwargs()
kwargs['queryset'] = kwargs['instance']
@kevinSuttle
kevinSuttle / meta-tags.md
Last active May 1, 2025 21:56 — forked from lancejpollard/meta-tags.md
List of Usable HTML Meta and Link Tags
@raliste
raliste / gist:4091897
Created November 16, 2012 23:31
Joldit's Webpay Plus (Django)
## views.py
import tempfile
import os
import commands
import cgi
from django import http
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render
@avoiney
avoiney / FileField_manual_initialisation.py
Last active June 12, 2021 12:46
Manually associate an existing file to a model FileField
# Assuming you have a Article Model like this
# class Article(models.Model):
# ... Some field
# media = models.FileField(upload_to="path_to_inner_media_folder", blank=True)
from django.core.files.base import ContentFile
import os
# Create an article with the associated model
new_article = Article()
@neara
neara / forms.py
Last active June 10, 2024 15:30
Django Class Based Views and Inline Formset Example
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from models import Sponsor, Sponsorship
class SponsorForm(ModelForm):
class Meta:
model = Sponsor
@bradmontgomery
bradmontgomery / install-comodo-ssl-cert-for-nginx.rst
Last active March 20, 2025 17:17
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@antoniolg
antoniolg / SwipeRefreshActivity.java
Last active July 29, 2019 11:59
An activity that uses a SwipeRefreshLayout as a container for the layout of the classes that extend it.
/*
* Copyright (C) 2014 Antonio Leiva Gordillo.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 8, 2025 09:19
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Shywim
Shywim / CursorRecyclerAdapter.java
Last active February 28, 2025 09:59
A custom Adapter for the new RecyclerView, behaving like the CursorAdapter class from previous ListView and alike. Now with Filters and updated doc.
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Matthieu Harlé
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is