Notes and anecdotes

Techstuff rambling

Build screen bootup

I have a “stupid computer” whos job is only to show a build screen. Its a debian, and I’d like for it to automatically reload the build page every 5 minutes, as well as enter the build screen in case of a reboot. Here’s one way to do it.

git cheatsheet

git is genious. Hands down brilliant. Every 6 months or so, I come across another command I didn’t know I needed before I needed it. And those regular ones I type all the time. So here’s a small collection of handy git aliases that saves some typing and/or remembering.

grep middle of file (unix)

How to grep tails and head

curl headers only

How to grep only the response headers

Django + Heroku bootstrap

It has happened on more than one occasion that I want a new Django project, with Grunt, jQuery, Bootstrap, Font-Awesome etc, deployed on Heroku. So I decided to write down the steps, and made a bash script to automate it all for me.

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

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

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

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

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 http://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch

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