Notes and anecdotes

Techstuff rambling

Running Django with nginx (on webfaction)

Case: You’re using virtualenv and have used apache with a config somewhat like this. Problem: Apache ‘goes to sleep’ Apache caches your wsgi application, and if it’s not used within a certain amount of time, it has to reload. And this takes like.. 10-15 seconds. Solution: Use nginx instead: Set up a custom application, and install nginx + uwsgi to point to…

Continue Reading

Get python, pip, virtualenv without sudo

Case: You don’t have sudo and life is awful on a cheap VPS or similar. Step 1: Get your desired python version Python 2.7 cd mkdir python cd python mkdir src cd src wget tar xvfz Python-2.7.3.tgz cd Python-2.7.3 mkdir ~/python/python27 ./configure -prefix=/home/username/python/python27 make make install cd echo “export PATH=$HOME/python/python27/bin” >> .bashrc source .bashrc…

Continue Reading

No module named ‘_sqlite3’

TLDR: Try sudo apt-get install python-dev sudo apt-get install libsqlite3-dev And recompile python (see own post) Long version So, I was starting a django app (1.7.1 with Python 3.4), python migrate when i encountered django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named ‘_sqlite3’ Did not expect this. I have…

Continue Reading

pip on python3: Can’t decompress data; zlib not available

Getting pip3.4 to work Want Python3.4 on your debian with virtualenv and pip? That’s what I wanted. However, I didn’t get pip automatically, and when I tried to install it, python gave me “Can’t decompress data; zlib not available” Spent a whole lot of time on this. Seems like installing 3.4 properly (with –with-zlib parameter when configuring) makes…

Continue Reading

Using FreshDesk API

After starting to write this note, I realize Freshdesk have ridiculously good guides on this. This page does not serve much purpose except this link, as well as this link to JavaScript Freshdesk API repo. How to use Freshdesk API 1. Get your API-key It’s on your profile settings pane (click on your profile picture). The actions done with that API-key,…

Continue Reading

Building a better bootstrap

These are my notes from Build a Better Bootstrap, by Tim G. Thomas. It’s a good talk. Just not good notes. Overflow: hidden; (Or clear:both?) Can help with those fesky times where an outer container doesn’t wraps around the inner elements. box-sizing: border-box; What this does, is include padding and border in the width of an…

Continue Reading

Grunt: Don’t worry about webkit-*, moz-* when typing css

Would you like to skip having to think about vendor prefixes when typing css? Wouldn’t we all. We could skip it though, with grunt autoprefixer.  

fork: retry: Resource temporarily unavailable

I got this error on webfaction. Seems it was do to too many open files (file descriptors). Edit: Which is not really my fault, since I’m on a shared server… which is mostly because I’m cheap. So it IS kind of my fault. Anyhow.. How do I check max allow amounts of file descriptors? ulimit -Hn…

Continue Reading

7 ineffective coding habits

Notes from Seven Ineffective Coding Habits of Many Programmers by Kevlin Henney 1. We clutter our code (with comments) Comments are ignored by the compiler. They are also ignored by programmers. So who’s the audience? Reading comments is like a sign of defeat, so it might be useful if your code is uncomprehensable in the first place. But then,…

Continue Reading

Clean Code III: Functions

This post is an my interpretation of the teachings in Robert C. Martins Clean Code III: Functions. Functions should do one thing You can tell that a function is doing more than one thing if you can extract a function from it with a meaningful name that is not merely a restatement of its implementation. Make…

Continue Reading

bash backup of webserver (FTP and SQL)

Quick and dirty backup from remote SQL and FTP server Introduction The following is a quick and dirty, simple implementation of a backup from mysql-db and ftp-available file area that . It uses git (though this is not really how git ought to be used), and transfers files securely, but not the database-dump. In other…

Continue Reading

Git repo on FTP-server

Often, you have to deal with limited web hotels that only provide a customly made (and usually poor) administration page, FTP- and SQL-access. How can you, on a cheap web hotel, use git without ssh access? If you’re comfortable giving your git-password and ftp-password to a third party, using deployhq is a simple and better alternative to…

Continue Reading

Mount FTP-server in debian using curlftpfs

Mounting remote ftp The following will mount your remote FTP-location in /mnt/my_ftp. Note that FTP is not secure, and you should combine this with a secure session. sudo curlftpfs -o allow_other ftp-user:ftp-pass@server_ip /mnt/my_ftp/ Unmounting ftp You’ll probably have to sudo this, depending on who mounted it where. fusermount -u /mnt/my_ftp_folder

Automatic MySQL and FTP backup

Want to backup Case: I have a WordPress page that stores stuff in MySQL database. I want to schedule a backup of the page, so that I am able to restore the page even if the file area is blanked out and the database has mysteriously disappeared. I want the schedule to run, say, every…

Continue Reading

Facebook: Invite all friends to event

So you have created an event, and wish to invite all your friends (or all friends in a circle), but don’t want to manually click all of them? Open the event in Chrome Click invite Friends and select the group (or let it stay in search for all) Scroll down to the end of the…

Continue Reading

Track custom events with google analytics

Requirements: You have an existing google analytics account You have a webpage to track events with How: Edit: If you’re on ES6 with webpack or similar, checkout this Github Gist instead. 1. You include google analytics in your page (function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,’script’,’//’,’ga’); // Replace UA-XXXXXXX-X with your google analytics user key ga(‘create’, ‘UA-XXXXXXX-X’, ‘’);…

Continue Reading

Web Icon Fonts

So you want font-icons for your page? How about icomoon? How about font awesome? How about glyphicons? How about entypo?

git: Replace master branch

So, you have a branch BESTBRANCH and you have basically made it your master branch? (Bad!) If you want to get back on track, and make BESTBRANCH the master, do this git checkout BESTBRANCH git merge -s ours master git checkout master git merge BESTBRANCH

git: Pull and checkout a remote branch

Say you have a branch on github, and you want pull it down onto your own machine? ok git checkout -b branch_name origin/branch_name It works fine just checking out a new branch with a matching name, given you have the appropriate (default) matching setting, and you have pulled since the branch was created on origin. git…

Continue Reading

Cron tabs: create and delete

Cron jobs run as root can be created with sudo crontab -e Cron jobs run as logged in user can be created with crontab -e Existing cron jobs can be viewed by writing sudo crontab -u username -l Deleting all cron jobs on a user can be done by typing sudo crontab -u username -r…

Continue Reading

1 2 3 4 5