Deploy web.py applications with pip requirements on Heroku


Running and deploying python apps on Heroku is pretty easy. I usually use web.py and Jinja2 templates for a typical web server. Install heroku toolbet Login to heroku heroku login Set the environment variablesheroku config:set PORT=8080 Heroku clone the app from created path.heroku git:clone -a myapp Create Procfile to tell heroku how to run the appgedit Procfile Put this into the Procfile: (Heroku assigns some random port every time it restarts the job so don’t hardcode the port here. It is highly like that heroku will fail to bind that port. Let it use its own port.)python main.py $PORTgedit requirements.txt Example content of requirements.txt (pip based installation will be done after pushing the code before deployment by heroku) web.py==0.37 Jinja2==2.6 Werkzeug==0.8.3 gunicorn==0.14.2 Deploy the app by using git: git add . git commit -m "Some commit" git push heroku master Visit yourapp.herokuapp.com To see the logs:heroku l...

How I store server logs in Google Spreadsheets


Disclaimer: I’m not an expert in this field. I just want to share my experiences with logs, you are welcome to give some feedback on my method.I like logs, I hate logs. I like analyzing them but I don’t like dealing with backups and everything.I have small sized projects like isimibul (job search engine for Turkey), Football Video Highlights. They have 3k-4k page views (API hits) per day. I would like to analyze some usage statistics like how many msecs it takes to handle a request or which job term is searched the most.At first I was using txt files to keep the logs. After some point it became real pain and I need some structured data. I started to log into sqlite in the server machine. However, that small sqlite file started to become something giant. As far as I observed (I might be wrong), dealing with big sqlite files increased the RAM usage of the server. So periodically I needed to back up and clean the logs (rm -rf is our friend). This system pushed me to find something more...

Got my new toy - OnePlus One


I finally got my OnePlus One after a long waiting for an invitation. I have been using it for 2 weeks.Pros Price price price. it’s a giant phablet. Gorgeous design. people are asking me all the time what phone this is. I started to like back cover. some people might not like it though. I don’t know, I fell on it from my bike and it survived with just some scratches in the back. Anyway, the back cover is replaceable, yet another +1. Camera is waaaay better than n5. It has slow mo and 4k UHD and DCI support. DCI is not supported by all 4k recorders. Cyanogenmod is awesomely awesome. They have great support. since this guy is their flagship, they are really solving problems with OTA updates. We have 2 year support from CM. Battery yes! finally. this is where I was bought in. my n5 was sufficient for everything but it’s battery was so unstable. I know it’s not gonna last long but it’s impossible to anticipate it. with opo you don’t have those things. I saw almost 5 hours screen ...

Ghost v0.5 update problem - No support for database client postgres


Error line from logs:ERROR: No support for database client postgresIf you are using postgres (usually for heroku users), just change your config.js file from:production: { url: 'http://hakanu.net', mail: {}, database: { client: 'postgres', toproduction: { url: 'http://hakanu.net', mail: {}, database: { client: 'pg',Redeploy your ghost.

Use third party python packages in Google App Engine


My hacky solution of usage of 3rd party packages in python. If you have a better method, leave a comment!Let’s start with flask example package by google. git clone https://github.com/GoogleCloudPlatform/appengine-python-flask-skeleton.git cd appengine-python-flask-skeleton pip install -r requirements.txt -t lib dev_appserver.py . Visit localhost:8080There is this lib folder with all of the dependencies in it like flask, jinja2, markupsafe etc. And in the code they are used like this:from flask import FlaskSo, to import your stuff: Download the package from pypi. For this example, I’m going to go through markdown package. Extract it somewhere, copy the folder and paste into lib/ folder. Preserve the name of the package like Markdown-2.4.1 in my case. Go inside the folder and cut the markdown folder and paste under lib/ folder. In the code, you can use it like:import markdownmarkdown.markdown(content)Also check this if you are interested in how to use markdown in flask.Defa...

Deploying Meteor and high cpu usage on production


Meteor is an open source javascript framework which gives developers to create real time Web apps without dealing with server code. From my side it’s a lot like firebase. However there are slight differences between them. Firebase also supports server side data synchronisation.Even though I don’t really like nodejs, I tried to play with meteor. The reason why I dislike Nodejs is because I hate npm. It never works perfectly, there is always something missing etc. I need to a lot of stackoverflowing to understand the errors. Same here again, I’ve faced a couple of problems but at the end I made the app run. Everything was good until I deployed the app to a production environment. By the way I will talk about painful deployment process as well.First of all you need to have these two installed in your machine to make meteor apps run: Meteor curl https://install.meteor.com/ | sh Meteorite: npm install -g meteoriteIf the code above does not work, try this (welcome to nodejs world):sudo ...

A small package of happiness aka SSD


I bought a small package of happiness from amazon.Little, fast, silent, light, beautiful…It’s an SSD, Samsung 840 EVO which has really aggressive pricing.I used this site to decide what to buy:http://ssd.userbenchmark.com/You should not really care about this 6gb/s thingy. You should divide it by 8 (1 byte=8 bits and it’s 6gbit not 6gbyte); so this is the speed of your sata3. Old sata2 ones have around 3gb/s. 6gb/s ~= 750mb/sDifference between read/write speeds and gb/s speedFun part: BenchmarksMy old companion who is still awesome! (1tb, 7200 RPM)** Just a side note, this hdd is connected to computer via a USB3.0 box, tests are not done by connecting it to the mainboard.Aaand this is the beast:Windows benchmark of the beast:

My first Android app which does something: World Cup Fan!


When the world cup first started, I knew that I won’t be able to watch all of the games and I was going to look for highlight videos and goals after the games desperately on youtube, dailymotion, google etc. So I created this simple android app which collects the match video links from the sites like rutube and plays within the app.Although I was not expecting much download, after one month of the launch, I received: 2,664 unique users 53,576 screen views 73% returning users 01:40 avg session duration Downloaded from 120 different countries/territoriesInteresting point is that there is no advertisement or branding for it. They are all organic downloads.There are also additional information like: Fixtures Groups Football club information Player databaseIt’s updated pretty quickly. After 1-2 hours of the each game’s final whistle, you can see that game and its highlights in the home tab.I know you are saying that this app is going to die in 2-3 weeks. However, I also show the...

Migrated my blog from Wordpress to Ghost


Yay, happy days. It has been in my todo list since I saw ghost’s kickstarter campaign. They pledged ~200k pounds while expecting 25k.Whatever, first I set up a free account from ghost’s official website and then tried to write my first blog post. I was amazed with the typing experience. Admin side was extremely clean; markdown was simply beautiful and fun to write.Don’t get me wrong, I really like wordpress as other 60% of the websites on the internet. The problem is that I don’t like php and I don’t like my hosting company. Although it’s easy to find a php hosting company, I lose all of the control. Wordpress is so complicated to manage. I also have a lot of historical problems from earlier versions of wp. I should start with a clean slate. Ghost’s simplicity hit me in the heart.Ok, so here are the basic steps: Find a hosting company for nodejs (eg heroku). Or setup your own environment by creating a VM using amazon’s free tier account or digital ocean’s basic plan which is $5 per...

Blogging for free with Ghost blog on Amazon EC2 Instance with your domain


I will walkthrough the steps of blogging for free with Ghost blog on Amazon EC2, well sort of. No, it’s not tumblr.Ghost is a nodejs based simple blogging platform. It was born in kickstarter.I really like it. It’s simple yet beautiful.There are two ways to use ghost, first one is that just go to their site and create an account, after that you will have a blog with a domain <your_name>.ghost.io; second option is to download the source code from the site and host in your instance. Second option is more geeky. So I have gone for it.Here is a list of things I needed to do in order to setup your own ghost instance: Create an aws account, no credit card needed. Go to EC2 and create an Ubuntu (I use ubuntu at home so easier for me. However nodejs can run on any platform) instance and run it Get the IP address of the instance Connect with ssh (Don't forget to download your security group key value pair.) Forward your ports for outer connections for example: 80 which is default HTTP ...


subscribe via RSS