Skip to content

Instantly share code, notes, and snippets.

View kyleturner's full-sized avatar

Kyle Turner kyleturner

View GitHub Profile
@alej0varas
alej0varas / forms.py
Last active April 13, 2016 11:16
Django Tastypie Base64MultiField for file upload using "application/json" Conten-Type You need a test.png file to test
import base64
from django import forms
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64MultiField(forms.MultiValueField):
def __init__(self, *args, **kwargs):
kwargs['fields'] = (
forms.CharField(),
@rigoneri
rigoneri / compress_s3_images.py
Created February 5, 2013 19:26
Simple python code to compress (jpeg/png) images uploaded to S3. In this use case I want to compress down all images that are over 500 KB down to 80% quality which brings the images down to about 100KB. Feel free to muck with the values.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from boto.s3.connection import S3Connection
from cStringIO import StringIO
from PIL import Image as pil
AWS_KEY = '[AWS KEY HERE]'
@bricef
bricef / AES.c
Last active March 4, 2023 11:29
A simple example of using AES encryption in Java and C.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* MCrypt API available online:
* http://linux.die.net/man/3/mcrypt
*/
#include <mcrypt.h>
@rca
rca / ajax_setup.js
Created January 29, 2012 00:27
Setup Django CSRF token in JQuery AJAX requests
/**
* setup JQuery's AJAX methods to setup CSRF token in the request before sending it off.
* http://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request
*/
function getCookie(name)
{
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');