Skip to content

Instantly share code, notes, and snippets.

View mmahesh's full-sized avatar

Mahesh Chandra Mukkamala mmahesh

View GitHub Profile
#Python code
import base64
json_body = json.loads(request.body)
my_file = json_body.get('imageInput')
my_filename = "akash_image.JPG"
imgdata = base64.b64decode(my_file)
saved_file = "akash_image.JPG"
with storage.open(saved_file, 'wb+') as destination:
destination.write(imgdata)
@mmahesh
mmahesh / debug
Last active August 29, 2015 14:02
*:80 is a NameVirtualHost
default server ip-something.us-west-2.compute.internal (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost ip-something.us-west-2.compute.internal (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost www.something-west-2.compute.amazonaws.com/url1 (/etc/apache2/sites-enabled/DOMAIN:3)
port 80 namevhost www.something.compute.amazonaws.com/url2 (/etc/apache2/sites-enabled/DOMAIN:28)
Syntax OK
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.DOMAIN.com/url1
ServerAlias DOMAIN.com/url1
ServerAlias *.DOMAIN.com/url1
DocumentRoot /home/ubuntu/url1
Alias /robots.txt "/home/ubuntu/url1/public/robots.txt"
#Templates
<input type="file" class="btn btn-default" id="dish_file" name="dish_file">
#Views
def some_view(request):
# some check over here
# the following code is to copy the uploaded file but these doesnt seem to be working
import multiprocessing
def worker(num):
"""thread worker function"""
print 'Worker:', num
return num
if __name__ == '__main__':
jobs = []
for i in range(5):
# Views
import logging
logger = logging.getLogger(__name__)
# Settings
LOGGING = {
'version': 1,
import unittest
def check_in_range(a):
if a>=0 and a<5:
return True
else:
return False
def find_matrix(blocker):
a = [[1,0,1,1,1],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[1,1,1,0,1]]
if not blocker:
@mmahesh
mmahesh / gist:7498548
Created November 16, 2013 10:23
My html
<!doctype html>
<html ng-app="project" ng-init="users=[&#34;mahesh&#34;, &#34;hari&#34;];;">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular-resource.min.js">
</script>
</head>
<body>
<div >
@mmahesh
mmahesh / gist:7479353
Last active May 27, 2023 04:56
Alembic commands
Installation : easy_install alembic or pip install alembic
Changing the dialect of database in alembic.ini to your own local database
In alembic folder change the env.py folder's settings as
from myapp.models import Base
target_metadata = Base.metadata
Now run command : alembic upgrade head
@mmahesh
mmahesh / gist:7245561
Created October 31, 2013 07:29
models
users_tags_table = Table('users_tags', Base.metadata,
Column('users_id', Integer, ForeignKey('users.id')),
Column('tags_id', Integer, ForeignKey('tags.id'))
)
users_tags_table = Table('users_groups', Base.metadata,
Column('users_id', Integer, ForeignKey('users.id')),
Column('groups_id', Integer, ForeignKey('groups.id'))
)
class Users(Base):