Skip to content

Instantly share code, notes, and snippets.

View Mohindharan's full-sized avatar
👀
I may be slow to respond.

Mohindharan Mohindharan

👀
I may be slow to respond.
  • India
  • 02:06 (UTC +05:30)
View GitHub Profile
@stephenash
stephenash / README.md
Created October 22, 2014 21:00
Django on ElasticBeanstalk - HTTP to HTTPS redirects

I needed a way to have my Django ElasticBeanstalk application automatically redirect HTTP requrests to HTTPS. Rick Christianson wrote a post [1] about how to do this by overwriting the wsgi.conf file with one that was slightly modified to support the HTTP to HTTPS redirect.

Building off the shoulders of giants, I wanted to do the same, but not have to keep a copy of the config file in my local source directory. Christianson even points out in his post that if ElasticBeanstalk ever changes it's template for the wsgi.conf file, those updates would not be overwritten and you wouldn't get their benefits. To get around that problem, I used sed to insert the new lines into the wsgi.conf file.

References

  1. http://rickchristianson.wordpress.com/2013/11/02/updating-wsgi-automatically-in-amazon-aws/
  2. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands
@iraycd
iraycd / msg91.py
Last active December 23, 2020 23:45
MSG91 - Django SendSMS
from sendsms.backends.base import BaseSmsBackend
from django.conf import settings
import urllib
import urllib2
MSG91_AUTHKEY = getattr(settings, 'MSG91_AUTHKEY', '')
MSG91_ROUTE = getattr(settings, 'MSG91_ROUTE', '')
class Msg91SmsBackend(BaseSmsBackend):
@kscottz
kscottz / mp32np.py
Created July 1, 2013 04:29
Convert mp3 to numpy array. Ugly, but it works.
import os
import scipy.io.wavfile as wav
# install lame
# install bleeding edge scipy (needs new cython)
fname = 'XC135672-Red-winged\ Blackbird1301.mp3'
oname = 'temp.wav'
cmd = 'lame --decode {0} {1}'.format( fname,oname )
os.system(cmd)
data = wav.read(oname)
# your code goes here