Facebook: Ignoring privacy settings for ads shown by third parties

So one day I was reading an article on Engadget and noticed something on the right side column...


Yep, Facebook activity! Creepy stuff... But I do vaguely remember taking the time to go through all my privacy options at once stage to disabling these sorta things.

So yet again I ventured off searching through the labyrinth. When I finally found the settings for friends and third party...

image http://www.facebook.com/settings?tab=ads&section=social



As expected, my settings were actually correct. Unsurprisingly, Facebook has decided to simply ignore the settings.

Fuck them cunts! I've had it!

I've removed or falsified the majority of my personal information, unliked/unlinked pages, uninstalled apps/games and removed interests.

If they're gonna just sell my shit off without respecting privacy options then I'll do my best to make it harder for them.

Considered closing my account, but I've some dev related things tied to it...

Fuck them cunts.

Android SDK: Move the location of virtual machines

Holy cow, because Windows Vista/7 keeps eating up my space on C:, I had to look for what was eating up my space.

To my surprise, "C:\Users\twig\.android\" was also taking up quite a bit of space also.

So, I decided to move it.

By default, the environment variable ANDROID_SDK_HOME points to "C:\Users\twig\" (Windows Vista/7, should be different for XP).

To change yours (on Windows 7):

  • Right click "My computer"
  • "Properties"
  • "Advanced system settings"
  • "Environment Variables"
  • Make sure that the Android SDK is not currently open
  • Now you can change it to what you want. I wanted to move it to "D:\Android\"
  • Now move your ".android" folder from "C:\Users\twig" to "D:\Android\"
  • Open up all the ".ini" files in the ".android\avd" folder
  • And finally, change the "path=" variable to work with the new path you've chosen.

That should be it! You can now fire it up and give it a test run.

Behold - the power of moving things around!


Linux/Ubuntu/LinuxMint: Set up a swap file

I forgot to set up a swap partition during setup, so figured I'd use a swap file instead, in case I messed up the Mac OSX boot partition.

First, create an empty file. To know how much you need, see here. In this example, I'm using a 1GB (1024mb) swap file. Use the following command to make it:

sudo mkdir /swapfile

sudo dd if=/dev/zero of=/swapfile/1024mb.swap bs=1024 count=1048576

Now convert it into a swapfile by typing:

sudo mkswap /swapfile/1024mb.swap

Now to install it!

sudo swapon /swapfile/1024mb.swap

Check if it works. The file should now be listed after typing:

swapon -s

And lastly, automate it so it's used after ever reboot.

sudo vi /etc/fstab

Add in the following line at the end (each part is separated by tabs)

/swapfile/1024mb.swap    none    swap    sw    0    0

You now have more power! 


Vim: Change the default color scheme/theme

You can set this manually in the editor by entering the command ":colorscheme murphy".

Or you can automate it by editing "~/.vimrc" and adding a line
"colorscheme murphy".


This post seems too short, so here's a random GIF to go with it =)

SSH: Slow connection times when entering username and password

For some obscure reason, my SSH login was taking a long time to verify. At first I didn't realise because I've been using my Android phone the whole time, but then I tried it on a LAN connection and it still had the same issue.

The problem would go like this:

  • Connect to OpenSSH server
  • Enter in username
  • Wait approximately 3 seconds
  • Enter in password
  • Wait approximately 5 seconds
  • Login success

This is pretty darn slow, especially since I'm connected via a gigabit LAN connection and Wireless N300.

So something had to give.

Thankfully the first few results on Google did the trick.

Open up a terminal window and edit the OpenSSH config file.

sudo vi /etc/ssh/sshd_config

At the end, paste this in:

# Fix slow login times
UseDNS no

Save and exit.

Now restart your OpenSSH daemon. You can do it while connected via SSH.

sudo /etc/init.d/ssh restart

That's it! It should now connect almost immediately.

[ Source: http://unsharptech.com/2009/04/11/fix-slow-connections-to-ubuntu-ssh-servers/ ]

Django: Using regroup template tag to group a list by letter

Sometimes the easy part is pulling data out but the hard part is actually displaying it nicely.

On some index pages, you can often categorise the list by the first letter of the name. This makes it a lot easier to find the information you're after.

For example, displaying a list of apps in an index page.

We use the built-in tag "regroup" to do this.

{% regroup apps by name.0 as apps_by_letter %}

The list of apps is contained in the variable "apps". We group it by "name.0", which is the first letter of the name into a new context variable called "apps_by_letter".

Note: Make sure that "apps" is sorted by name prior to calling regroup! Otherwise your list is going to be scattered.

<div id="apps_section_list">
{% for letter_apps in apps_by_letter %}
<div class="letter"><b>{{ letter_apps.grouper }}</b></div>

{% for app in letter_apps.list %}
<a class="image" href="{{ app.url }}"><img src="{{ app.image }}"></a>
<a href="{{ app.url }}">{{ app.name }}</a>
{% endfor %}
{% endfor %}

We then proceed to loop each item in "apps_by_letter" as "letter_apps", which gives us the first letter which contains apps and the list of apps in this group.

The category label is stored in "letter_apps.grouper" while the list of apps is stored in "letter_apps.list".

See also a more advanced tutorial about grouping by date.

Python: Simplest method for zero-padding a number

Harley provides an awesome method for zero padding a number in a string.

If the number is provided in string format:

n = '4'
print n.zfill(3)

And for integer format:

n = 4
print '%03d' % n


Django: Filter to get linked object from comment

While I'm on the topic of linking objects to comments, a handy filter to have is the ability to convert an object into the linked object.

def get_comment_object(comment):
This is the reverse, it gets an object from the comment
return comment.content_type.get_object_for_this_type(pk = comment.object_pk)

To use it, just call:

{{ comment|get_comment_object }}

Django: Link comments to objects for use with ORM QuerySet and filters

For a long time I've been meaning to find a more convenient way to filter comments. I really disliked the way we had to retrieve them through a tag, which either retrieved "all or nothing".

Sometimes it's necessary to retrieve comments from a subset of objects, such as comments for all blog posts "in category Cars".

To do this efficiently with minimal changes to the database, we'll need a proxy model. This proxy model has no table in the database but allows us to tweak the manager.

Firstly, define the proxy class and manager.

from django.conf import settings
from django.contrib.comments.managers import CommentManager
from django.contrib.comments.models import Comment

class CommentObjectManager(CommentManager):
def comments_for_objects(self, objects):
This is the magic query that links the `django_comments` table to the selected range of objects.
The reason why we have to do this is because the django_comments.object_pk field is stored as an string.
By casting it to an integer, we can then link it back to the original model without errors.
It's a bit hackish, but it's the cleanest way I found find to get it working.
# The usual filters for comments
qs = self.for_model(objects.model)
qs = qs.filter(site = settings.SITE_ID, is_public = True, is_removed = False)

# Link objects to the comments table
# This is for PostgreSQL. I'm sure there's a matching cast for MySQL and such.
extra_where = 'CAST(django_comments.object_pk AS int) IN (%s)' % ','.join([ '%s' % obj.pk for obj in objects ])

return qs.extra(where = [extra_where]).order_by('-submit_date')

class CommentObject(Comment):
This dummy proxy class allows you to filter comments by certain objects.
class Meta:
proxy = True

objects = CommentObjectManager()

Now that the hard part is done, we just need a way to use it.

def for_posts_in_category(self, category, limit = 1500):
Example: Returns comments for the latest 1500 posts in the category given.
restriction = BlogPost.objects.all_in_category(category)[:limit]
return CommentObject.objects.comments_for_objects(restriction)

Ohhhhhhhh yeah~ time to celebrate!

Android: Downloading adb without the SDK

A lot of Android guides refer to a program called "adb", which comes from the Android software development kit.

The development kit contains all tools and software required to begin creating your own Android applications.

However, it is roughly 30mb in size and that's a whole heap of useless junk if you're only after "adb", which is 3 files and 718kb in size.

  • Firstly, you'll need a program that can partially download contents of zip files from the internet.
  • Once that's set up, go to the SDK download page and grab the link to the SDK.
  • In the zip file, navigate to "android-sdk-windows\tools"
  • From there, select only "adb.exe", "AdbWinApi.dll" and "AdbWinUsbApi.dll"
  • Download.
  • That's it!

I'm making this post so people can learn how to do this themselves, rather than rely on others to post up zip files on sites like MediaFire (which may or may not take it down in a year's time).

The usual case of teach a man to fish.


Firefox 4: Disable switch-to-tab

The "switch to tab" feature is one of those improvements I believe didn't need to happen.

It has our best interests at heart but does a sloppy job of helping out.

What I sometimes do is load a dev page in one tab and keep it open. Then I make some changes and open a new tab to compare the changes.

The "switch to tab" feature makes it impossible for me to do this! A "feature" that prevents me from doing my job efficiently just has to go.

There is a bloody long discussion about this feature in the mozillazine forums but to be honest, it's too long and I didn't bother reading the whole thing.

Add-on solution

If you want to disable this feature permanently, there are 2 add-ons that will do it for you. I'm unaware of how they work or how compatible they are with Firefox 5. See addons below in the sources section.

Non-addon solution

Personally, I didn't know but you can simply hold "Shift" while hovering your mouse over the "switch to tab" item.

It'll hide the switch-to-tab items and display the URLs as normal.



Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog