digitaldreamer blog postshttp://digitaldreamer.net/blog/bits and bytesen-usMon, 21 Jan 2019 17:03:45 -0000Find process that is bound to a port
http://digitaldreamer.net/blog/2017/3/6/find-process-bound-port/<p>&#160;Sometimes when developing you'll lose control of a process that binds to a specific port. When that happens you can no longer start up another process until you kill the running process that controls the port you want to use.</p><p>You can find and kill the process that is controlling the port with the following commands</p><pre>lsof -i tcp:8000
kill &lt;pid&gt;</pre>
http://digitaldreamer.net/blog/2017/3/6/find-process-bound-port/Mongo setting global admin user
http://digitaldreamer.net/blog/2017/3/6/mongo-setting-global-admin-user/<p>Auth is turned off by default for Mongo. To set a global admin you need to create an admin user and turn on auth.</p><p>If you want to additionally allow external connections you can change the bind ip from 127.0.0.1 that only allows for local connections.</p><pre>/etc/mongod.conf
bind_ip = 0.0.0.0
port = 27017
auth = trueuse admin
db.addUser({user: "user", pwd: "pass", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})</pre>
http://digitaldreamer.net/blog/2017/3/6/mongo-setting-global-admin-user/install the latest golang on ubuntu
http://digitaldreamer.net/blog/2017/3/4/install-latest-golang-ubuntu/<p>&#160;You can install golang in ubuntu through apt-get, but it tends to be out of date by a few versions. Luckily, it's easy to install the latest version on any system.</p><p>Head to the golang download page:&#160;<a href="https://golang.org/dl/">https://golang.org/dl/</a> and grab the download link. Then back on the server run the following:</p><pre>wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
tar -xvzf go1.8.linux-amd64.tar.gz
sudo mv go /usr/local/go</pre><p>Next, you just need to set up your envars:</p><pre>export GOROOT=/usr/local/go
export GOPATH=~/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
# check that it installed correctly
go version
go env</pre><p>That's it!</p>
http://digitaldreamer.net/blog/2017/3/4/install-latest-golang-ubuntu/get rid of the low battery warning for bluetooth devices on macs
http://digitaldreamer.net/blog/2013/9/14/get-rid-low-battery-warning-bluetooth-devices-macs/<p>I find that the low battery warnings turn on way too early on Macs and I'm left with months of staring at a blinking bluetooth indicator. I have yet to find a way to lower the threshold but I did discover how to remove the blinking indicator. I just copy over the low battery image in the system folder like so. The images are still being swapped out but since they're now the same it won't be noticeable. You'll still get the low battery alerts but at least the icon won't blink anymore.</p><pre>cd /System/Library/CoreServices/Menu\ Extras/Bluetooth.menu/Contents/Resources/
sudo cp lowbatt.pdf lowbatt.backup.pdf
sudo cp Bluetooth_Low_Battery.pdf Bluetooth_Low_Battery.backup.pdf
sudo cp BlueTooth_Connected.pdf Bluetooth_Low_Battery.backup.pdf
sudo cp BlueTooth_Connected.pdf lowbatt.pdf</pre>
http://digitaldreamer.net/blog/2013/9/14/get-rid-low-battery-warning-bluetooth-devices-macs/have nginx proxy properly pass ssl/https to apache mod_wsgi url_scheme for django/pyramid/flask etc ...
http://digitaldreamer.net/blog/2013/8/9/nginx-proxy-ssl-https-mod_wsgi-apache-django/<p>I've had problems getting mod_wsgi to properly set the url_scheme to https when running under SSL. This causes references to fully-qualified urls in statements like redirects and static file locations resolve incorrectly to http when I am viewing the ssl page through https.</p><p>I have an nginx web server hosting static files and proxy apache mod_wsgi for the python applications which includes any combination of django, pyramid, and flask frameworks, although this will also work for any mod_wsgi app running under the nginx/apache stack.</p><p>I've seen examples of how to set up the apache config, and other examples of how to set up the nginx config, but I have yet to see someone explain how to set up the two together nor has anyone explained what is actually going on.</p><p>I am not a server admin so it's a struggle for me to wrangle things like this. I am by no means an expert on this subject but I am documenting my process on what I have found to work in hopes that it'll help others save some pain and frustration that I went through.</p><h1>Short Version</h1><p>Add set_proxy_header to the nginx settings after the proxy_pass statement in the server location directive.</p><pre>proxy_set_header X-Forwarded-Protocol $scheme;</pre><p>Add the SetEnvIf statement to set the HTTPS environment variable in the apache settings to pass to the wsgi process.</p><pre>SetEnvIf X-Forwarded-Protocol https HTTPS=1</pre><h1>Long Version</h1><p>My nginx site config typically looks similar to:</p><pre>upstream example_backend {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443;
server_name example.com;
ssl on;
ssl_certificate /path/to/example_combined.crt;
ssl_certificate_key /path/to/example.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/example.access.log;
error_log /var/log/nginx/example.error.log;
location / {
# auth_basic "Restricted";
# auth_basic_user_file /path/to/htpasswd;
proxy_pass http://example_backend;
include /etc/nginx/proxy.conf;
# set a proxy header to pass tell apache if we're operating under ssl
proxy_set_header X-Forwarded-Protocol $scheme;
# you can use this header instead, or anyone you want, but coordinate it with the apache config
# proxy_set_header X-Forwarded-HTTPS on;
}
location ~ ^/(media|static)/ {
root /path/to/html/root;
#index index.html index.htm;
}
}</pre><p>My /etc/nginx/proxy.conf file contains:</p><pre>proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;</pre><p>The key entry is the proxy header:</p><pre>proxy_set_header X-Forwarded-Protocol $scheme;</pre><p>This sets the X-Forwarded-Protocol header to http or https depending on the scheme. Since you're under SSL it should be set to https. An alternative is you can set a pre-defined header instead like:</p><pre>proxy_set_header X-Forwarded-HTTPS on;</pre><p>Choose one or the other, not both. You will check the header value in the apache config and set the HTTPS environment variable to pass to the mod_wsgi process which will set the wsgi.url_scheme variable for the wsgi app.</p><p>My apache config typically looks similar to:</p><pre>WSGIPythonHome /path/to/virtualenv
WSGIPythonPath /path/to/virtualenv/lib/python2.7/site-packages
&lt;VirtualHost *:8000&gt;
ServerAdmin user@example.com
ServerName example.com
# ServerAlias www.example.com
#DocumentRoot /path/to/html
WSGIDaemonProcess example user=example group=example processes=4 threads=4
WSGIApplicationGroup %{GLOBAL}
WSGIProcessGroup example
WSGIPassAuthorization on
WSGIScriptAlias / /path/to/production.wsgi
# check the proxy header passed to us from nginx to set the HTTPS environment variable
SetEnvIf X-Forwarded-Protocol https HTTPS=1
# use this alternative if it was set in nginx
# SetEnvIf X-Forwarded-HTTPS on HTTPS=1
# use this if you do not want to check the headers with SetEnfIf (not recommended)
# SetEnv HTTPS 1
&lt;Directory /path/to/wsgi/folder&gt;
Order deny,allow
Allow from all
&lt;/Directory&gt;
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
ErrorLog /var/log/apache2/example.error.log
CustomLog /var/log/apache2/example.access.log combined
&lt;/VirtualHost&gt;</pre><p>You need to make sure the setenvif apache mod is enabled (on Ubuntu it is on by default). The key line here is making sure you're setting the HTTPS environment variable:</p><pre>SetEnvIf X-Forwarded-Protocol https HTTPS=1</pre><p>If you set X-Forwarded-HTTP on in the nginx as an alternative you should alter the conditional accordingly:</p><pre>SetEnvIf X-Forwarded-HTTPS on HTTPS=1</pre><p>Again,you should be using one or the other, not both.</p><p>If you want to force HTTPS onto mod-wsgi without checking for the proxy header for testing then you can manually set the variable:</p><pre>SetEnv HTTPS 1</pre><p>This is highly not recommended as it's a potential security hole.</p>
http://digitaldreamer.net/blog/2013/8/9/nginx-proxy-ssl-https-mod_wsgi-apache-django/curl post with json
http://digitaldreamer.net/blog/2013/7/25/curl-post-json/<pre>curl -X POST -H "Content-Type: application/json" -d '{"username":"xyz","password":"xyz"}' http://localhost:8000/api/login</pre>
http://digitaldreamer.net/blog/2013/7/25/curl-post-json/continuously print lines of a file as they are added
http://digitaldreamer.net/blog/2013/7/8/continuously-print-lines-file-they-are-added/<p>Use `-f` flag on `tail` to continuously output lines of a file as they are added in the terminal:</p><pre>tail -f &lt;file&gt;</pre><p>CTRL-C to stop the process.</p>
http://digitaldreamer.net/blog/2013/7/8/continuously-print-lines-file-they-are-added/reset auto increment counter in postgres
http://digitaldreamer.net/blog/2013/6/11/reset-auto-increment-counter-postgres/<p>postgres uses something called a sequence to keep track of the auto increment counts. To list the sequences us:</p><pre>\ds</pre><p>The sequence name is in the format of ${table}_{variable}_seq</p><p>You can reset the counter using the function</p><pre>setval('product_id_seq', 1453);
or
select setval('product_id_seq', (SELECT MAX(id) FROM product));
</pre><p>If you do not know the name you can use the pg_get_serial_sequence function on the table&#160;</p><pre>select pg_get_serial_sequence('product', 'id');</pre><p>You can also manually update the sequence with the command:</p><pre>ALTER SEQUENCE product_id_seq RESTART WITH 1453;</pre>
http://digitaldreamer.net/blog/2013/6/11/reset-auto-increment-counter-postgres/remove domain from ssh known_hosts file
http://digitaldreamer.net/blog/2013/6/11/remove-domain-ssh-known_hosts-file/<pre>ssh-keygen -R &lt;domain&gt;
ssh keygen -R example.com
ssh-keygen -R [localhost]:22</pre>
http://digitaldreamer.net/blog/2013/6/11/remove-domain-ssh-known_hosts-file/recursively chmod only files or directories
http://digitaldreamer.net/blog/2013/3/6/recursively-chmod-only-files-or-directories/<p>recursively chmod directories only</p><pre>find . -type d -exec chmod 755 {} \;</pre><p>recursively chmod files only</p><pre>find . -type f -exec chmod 644 {} \;</pre>
http://digitaldreamer.net/blog/2013/3/6/recursively-chmod-only-files-or-directories/download website with wget
http://digitaldreamer.net/blog/2013/1/18/download-website-wget/<pre>wget --mirror -p --convert-links -P /path/to/download/directory example.com</pre>
http://digitaldreamer.net/blog/2013/1/18/download-website-wget/pretty print json in python
http://digitaldreamer.net/blog/2013/1/15/pretty-print-json-python/<pre>import json
mydata = json.loads(output)
print json.dumps(mydata, indent=4)</pre>
http://digitaldreamer.net/blog/2013/1/15/pretty-print-json-python/ordinal number in python
http://digitaldreamer.net/blog/2013/1/15/ordinal-number-python/<pre>## {{{ http://code.activestate.com/recipes/576888/ (r10)
#!/usr/bin/env python
def ordinal(value):
"""
Converts zero or a *postive* integer (or their string
representations) to an ordinal value.
&gt;&gt;&gt; for i in range(1,13):
... ordinal(i)
...
u'1st'
u'2nd'
u'3rd'
u'4th'
u'5th'
u'6th'
u'7th'
u'8th'
u'9th'
u'10th'
u'11th'
u'12th'
&gt;&gt;&gt; for i in (100, '111', '112',1011):
... ordinal(i)
...
u'100th'
u'111th'
u'112th'
u'1011th'
"""
try:
value = int(value)
except ValueError:
return value
if value % 100//10 != 1:
if value % 10 == 1:
ordval = u"%d%s" % (value, "st")
elif value % 10 == 2:
ordval = u"%d%s" % (value, "nd")
elif value % 10 == 3:
ordval = u"%d%s" % (value, "rd")
else:
ordval = u"%d%s" % (value, "th")
else:
ordval = u"%d%s" % (value, "th")
return ordval
if __name__ == '__main__':
import doctest
doctest.testmod()
## end of http://code.activestate.com/recipes/576888/ }}}
</pre>
http://digitaldreamer.net/blog/2013/1/15/ordinal-number-python/ordinal number in javascript
http://digitaldreamer.net/blog/2013/1/15/ordinal-number-javascript/<p>Here's a slick way to create ordinal numbers in javascript that I found.</p><pre>function getGetOrdinal(n) {
var s=["th","st","nd","rd"],
v=n%100;
return n+(s[(v-20)%10]||s[v]||s[0]);
}</pre>
http://digitaldreamer.net/blog/2013/1/15/ordinal-number-javascript/mount virtualbox shared folder in ubuntu
http://digitaldreamer.net/blog/2013/1/15/mount-virtualbox-shared-folder-ubuntu/<p>on virtualbox settings share a folder and don't auto mount</p><p>inside vm check uid/gid</p><pre>id</pre><p>create empty dir</p><pre>mkdir share_folder</pre><p>edit file</p><pre>/etc/fstab</pre><p>enter line</p><pre>share_folder /path/to/mount vboxsf uid=1000,gid=1000 0 0</pre>
http://digitaldreamer.net/blog/2013/1/15/mount-virtualbox-shared-folder-ubuntu/change an existing model, auth_user.username, max_length in django
http://digitaldreamer.net/blog/2012/7/6/change-existing-model-auth_userusername-max_length/<p>So lets say I had a model an an app that I didn't create that I wanted to change. Well, I would like to avoid going to that app and adjusting the code on the fly. Instead I would rather make the change in my custom application in order to keep the integrity of the code strong.</p><p>In my personal case I typically need to increase the max_length of the username in the django.contrib.auth package. You can perform the change by using the class_prepared signal:</p><pre># models.py
from django.db.models.signals import class_prepared
def longer_username(sender, *args, **kwargs):
# you can't just do `if sender == django.contrib.auth.models.User`
# because you have to import the model
if sender.__name__ == 'User' and sender.__model__ == 'django.contrib.auth.models.User':
sender._meta.get_field('username').max_length = 100
class_prepared.connect(longer_username)</pre><p>You might need to change any help_text and forms.</p><p>This code will not update the underlying database. In order to make the update in the database I add a South schema migration.</p><pre>import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def fowards(self, orm):
db.alter_column('auth_user', 'username', models.CharField(max_length=100))
def backwards(self, orm):
db.alter_column('auth_user', 'username', models.CharField(max_length=35))
# copy the rest of the file from the previous migration
# update the value for auth.user / username / maxlength</pre><p>I don't think I need to say this, but this is hackish and should be used with great caution.</p>
http://digitaldreamer.net/blog/2012/7/6/change-existing-model-auth_userusername-max_length/html5 django form fields
http://digitaldreamer.net/blog/2012/7/6/html5-django-form-fields/<p>If you're ever developing for mobile it's really handy to use the HTML5 form inputs for things like email and url to bring up the contextual keyboard layouts.</p><p>An easy way to create the HTML5 input elements is to extend the Input widget input_type.</p><pre>from django import forms
from django.widgets import Input
class Html5EmailInput(Input):
input_type = 'email'
class Html5URLInput(Input):
input_type = 'url'
class CustomForm(forms.Form):
email = forms.CharField(widget=Html5EmailInput())
url = forms.CharField(widget=Html5URLInput())
</pre>
http://digitaldreamer.net/blog/2012/7/6/html5-django-form-fields/removing a passphrase from an SSL Key
http://digitaldreamer.net/blog/2012/7/6/removing-passphrase-ssl-key/<p>This is taken from&#160;<a href="http://www.mnxsolutions.com/apache/removing-a-passphrase-from-an-ssl-key.html">http://www.mnxsolutions.com/apache/removing-a-passphrase-from-an-ssl-key.html</a></p><p>The typical process for creating an SSL certificate is as follows:</p><pre># openssl genrsa -des3 -out www.key 2048</pre><p>Note: When creating the key, you can avoid entering the initial passphrase altogether using:</p><pre># openssl genrsa -out www.key 2048</pre><p>At this point it is asking for a PASS PHRASE (which I will describe how to remove):</p><p>&#160;Enter pass phrase for www.key:</p><pre> # openssl req -new -key www.key -out www.csr</pre><p>Next, you will typically send the www.csr file to your registrar. In turn, your registrar will provide you with the .crt (certificate) file.</p><p>From a security standpoint utilizing a passphrase, is a good thing, but from a practical standpoint not very useful.</p><p>For instance, what happens when your server reboots/crashes at 3am? Or better, what happens in 6 months when you reboot your machine, and you don’t remember the password? Well, one thing is for sure, your web server will not be online.</p><p>I suggest removal of the passphrase, you can follow the process below:</p><p>Always backup the original key first (just in case)!</p><pre># cp www.key www.key.orig</pre><p>Then unencrypt the key with openssl. You’ll need the passphrase for the decryption process:</p><pre># openssl rsa -in www.key -out new.key</pre><p>Now copy the new.key to the www.key file and you’re done. Next time you restart the web server, it should not prompt you for the passphrase.</p>
http://digitaldreamer.net/blog/2012/7/6/removing-passphrase-ssl-key/bind a model&#39;s .change() trigger to a view&#39;s .render() function in backbone
http://digitaldreamer.net/blog/2012/7/6/bind-models-change-trigger-views-render-function-b/<p>You can bind a Model's .change() trigger to a View's .render() function in Backbone by using the bindAll method to make sure the render method is always bound to the view.</p><pre>MyView = Backbone.View.extend({
initialize: function() {
_.bindAll(this, "render");
this.model.bind('change', this.render);
},
render: function() {
this.model.$el.html(this.template(this.model.toJSON()));
return this;
}
});</pre>
http://digitaldreamer.net/blog/2012/7/6/bind-models-change-trigger-views-render-function-b/adding paths to the lessc compiler
http://digitaldreamer.net/blog/2012/7/6/adding-paths-lessc-compiler/<p>So you need to compile your less files but you've put the files somewhere else in your directory structure and need to add paths for lessc to search.</p><p>There is an undocumented option include-path that does just this. The source code looks like:</p><pre> case 'include-path':
options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
.map(function(p) {
if (p) {
return path.resolve(process.cwd(), p);
}
});
break;</pre><p>which if you read it carefully tells you it can accept one or more directories separated by ":" or ';' if you're on windows. So, to include new paths for lessc to search you can pass in the directories like so:</p><pre>lessc --include-path="/path/to/directory/" styles.less
lessc --include-path="/path/to/directory/:/path/to/another/directory/" main.less &gt; styles.css</pre>
http://digitaldreamer.net/blog/2012/7/6/adding-paths-lessc-compiler/display the value of a django form field in a template
http://digitaldreamer.net/blog/2012/7/6/display-value-django-form-field-template/<p>Sometimes you need to get at the raw value of a field in a django form. This is easily done in 1.3 using the following:</p><pre>{{ form.field_name.value }}</pre><p>If you're running a version lower than 1.3 you can get at the value with:</p><pre>{% if form.instance.field_name %}
{{ form.instance.field_name }}
{% else %}
{{ form.data.field_name }}
{% endif %}</pre>
http://digitaldreamer.net/blog/2012/7/6/display-value-django-form-field-template/accessing the object inside a django admin change_form.html template
http://digitaldreamer.net/blog/2012/7/6/accessing-object-inside-django-admin-change_formht/<p>When overriding the change_form.html template sometimes I need access to the object that is being edited. The change_view method provides the original object in the 'original' context variable.</p><p>You can access the object in the template using the original variable:</p><pre>{{ original }}</pre>
http://digitaldreamer.net/blog/2012/7/6/accessing-object-inside-django-admin-change_formht/manually/force eject a stuck cd/dvd on and apple mac
http://digitaldreamer.net/blog/2012/2/1/manually-force-eject-stuck-cddvd-and-apple-mac/<p>It doesn't happen a lot, but sometimes a CD or DVD gets stuck in my mac and it won't eject using the keyboard or dragging it into the trashcan.</p><p>When this happens I just open the terminal and type the following command, which usually overrides whatever is blocking the disc to eject:</p><pre>drutil tray eject</pre><p>Although I'm not sure when I'd ever use it there's also a close command.</p><pre>drutil tray close</pre>
http://digitaldreamer.net/blog/2012/2/1/manually-force-eject-stuck-cddvd-and-apple-mac/including site packages in virtualenv 1.7
http://digitaldreamer.net/blog/2012/1/13/including-site-packages-virtualenv-17/<p>So if you're using virtualenv 1.7 and are wondering why you can no loger see your global Python site-packages directory it's because the default behavior has changed.</p><p>Now the default install for virtualenv is to hide site packages;&#160;equivalent&#160;to passing the old --no-site-packages command:</p><pre>virtualenv --no-site-packages &lt;env&gt;</pre><p>Since this option is now default it's no longer needed, and the new command to see the global site packages is --system-site-packages:</p><pre>vitualenv --system-site-packages &lt;env&gt;</pre><p>Hopefully this saves you some confusion as it's not clear what's happening when your new install now suddenly is breaking.</p>
http://digitaldreamer.net/blog/2012/1/13/including-site-packages-virtualenv-17/random integer with a range in python
http://digitaldreamer.net/blog/2011/12/14/random-integer-range-python/<p>To create a random integer within a range you can use the following command:</p><pre>import random
# random integer between 1 and 100
RANDOM_INTEGER = random.randint(1, 100)</pre>
http://digitaldreamer.net/blog/2011/12/14/random-integer-range-python/remove domain dns key entry in known_hosts for ssh
http://digitaldreamer.net/blog/2011/11/22/remove-domain-dns-key-entry-known_hosts-ssh/<p>Sometimes I re-key or move the domain of a server and need to reset the key so RSA doesn't complain. Technically you can just open ~/.ssh/known_hosts file and remove the entry for the dns, but the names are hashed which makes the entry difficult to find.</p><p>I used to just reset the entire known_hosts file, but that's not necessary. You can remove the domain entry with the simple command:</p><pre>ssh-keygen -R example.com</pre><p>Next time you try to ssh you'll be prompted to add the key as if you're visiting the site the first time. I hope this helps.</p>
http://digitaldreamer.net/blog/2011/11/22/remove-domain-dns-key-entry-known_hosts-ssh/showing a foreign key value in a django admin list display
http://digitaldreamer.net/blog/2011/11/7/showing-foreign-key-value-django-admin-list-displa/<p>say you have two models like so:</p><pre># models.py
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.ForeignKey("Author")
class Author(models.Model):
name = models.CharField(max_length=100)</pre><p>In this case it would be handy if we could list the author in the list_display of the book admin, but Django gives an error if we list foreign keys like so:</p><pre># admin.py
class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'author__name')
admin.register(Book, BookAdmin)</pre><p>Luckily we can easily fix this by adjusting how we link into the author foreign key. We just need to add a method to the Book ModelAdmin and return the desired string.</p><pre># admin.py
class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'author_name')
def author_name(self, instance):
return instance.author.name</pre><p>Be careful though as gratuitous additions of foreign key field can greatly increase the load time of the admin page for the list view of the model: use this judiciously.</p>
http://digitaldreamer.net/blog/2011/11/7/showing-foreign-key-value-django-admin-list-displa/ignoring files generated by eclipse for git
http://digitaldreamer.net/blog/2011/10/18/ignoring-files-generated-eclipse-git/<p>If you're developing in Eclipse, like I am for Android, and you use version control you're going to want to ignore the default project files that are generated by Eclipse. You should update your .gitignore with the following list:</p><pre>.project
.classpath
.settings/
bin/</pre>
http://digitaldreamer.net/blog/2011/10/18/ignoring-files-generated-eclipse-git/create/generate qr code with qrencode in ubuntu
http://digitaldreamer.net/blog/2011/10/14/creategenerate-qr-code-qrencode-ubuntu/<p>You can create qr codes easily in Ubuntu using qrencode. You can install it like so:</p><pre>sudo apt-get install qrencode</pre><p>and then create the qr code with the following command:</p><pre>qrencode -o /path/to/qrcode.png -s 10 'http://example.com'</pre><p>the `-s` option flag is the size of dot (pixel). The default is 3.</p>
http://digitaldreamer.net/blog/2011/10/14/creategenerate-qr-code-qrencode-ubuntu/how to rename a database in postgresql
http://digitaldreamer.net/blog/2011/10/12/how-rename-database-postgresql/<p><a href="http://www.postgresonline.com/journal/archives/40-How-do-you-rename-a-database.html">http://www.postgresonline.com/journal/archives/40-How-do-you-rename-a-database.html</a></p><p>First kick the users out of the database, you can find the users with the following command.</p><pre>SELECT *
FROM pg_stat_activity
WHERE datname = 'myolddbname_goes_here'</pre><p>now run the following:</p><pre>ALTER DATABASE myolddbname_here RENAME TO mynewdbname_here</pre>
http://digitaldreamer.net/blog/2011/10/12/how-rename-database-postgresql/