Skip to content

Instantly share code, notes, and snippets.

Avatar
🧿
Working from home

Mohindharan Mohindharan

🧿
Working from home
  • price.com
  • India
View GitHub Profile
@iraycd
iraycd / msg91.py
Last active Dec 23, 2020
MSG91 - Django SendSMS
View msg91.py
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):
@stephenash
stephenash / README.md
Created Oct 22, 2014
Django on ElasticBeanstalk - HTTP to HTTPS redirects
View README.md

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
@kscottz
kscottz / mp32np.py
Created Jul 1, 2013
Convert mp3 to numpy array. Ugly, but it works.
View mp32np.py
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