How To FULLY Disable Spotlight in Leopard

By Ali Karbassi | May 12th, 2009 | How To, OS X | Comments

extra-spotlight

Warning: This is changing system settings that may or may not be attached to other tools. After an extensive search on the internet, one of these tools affected by the following steps is TimeMachine/TimeCapsule. If you are using them, I would not follow these steps. Rule of thumb: if you think it will mess up your system and you don’t want to worry about that, don’t do it.

Quick way

To disable:

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
launchctl unload /System/Library/LaunchAgents/com.apple.Spotlight.plist
sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.Spotlight.plist

To re-enable:

sudo launchctl load /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
launchctl load /System/Library/LaunchAgents/com.apple.Spotlight.plist
sudo launchctl load -w /System/Library/LaunchAgents/com.apple.Spotlight.plist

Explaination

  1. Stop and disable the background server:
    • Kill the Daemon:
      sudo launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
      sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
      
    • Re-enable the Daemon:
      sudo launchctl load /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
      sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
      
  2. Stop and disable the spotlight application itself:
    • Kill the Agent:
      launchctl unload /System/Library/LaunchAgents/com.apple.Spotlight.plist
      sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.Spotlight.plist
      
    • Re-enable the Agent:
      launchctl load /System/Library/LaunchAgents/com.apple.Spotlight.plist
      sudo launchctl load -w /System/Library/LaunchAgents/com.apple.Spotlight.plist
      

You may get an error on the last command; just ignore it.

What it does

  • We stop the process from running.
    sudo launchctl unload /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
  • The following line tells the system to fully disable it.
    sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
  • Now we need to stop the agent for the user and everyone else.
    launchctl unload /System/Library/LaunchAgents/com.apple.Spotlight.plist
    sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.Spotlight.plist

The re-enable Spotlight back again:

  • If you need to re-enable the process, you can run the following two lines.
    sudo launchctl load /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
    sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
  • The following two lines re-enable the Spotlight agent.
    launchctl load /System/Library/LaunchAgents/com.apple.Spotlight.plist
    sudo launchctl load -w /System/Library/LaunchAgents/com.apple.Spotlight.plist

The reason you get the error is that you are effectively executing the command as root, but the root user hasn’t any running instance of Spotlight. On the other hand, only the root user is able to disable the automatic start of Spotlight. Thus the need for the sudo command.

Done!

There’s no need to reboot your computer after following these steps.

Automatically Block Facebook Applications Updated!

By Ali Karbassi | January 22nd, 2009 | Greasemonkey | Comments

Two years later, I decided to take a look at my old, old, OLD Greasemonkey script to see if it was still working. This is after two minor updates on Facebook and one major update that changed the whole design and structure.

Surprisingly, the script works exactly like it should. I made one minor update, but after many tests, it works for me.

If you have any suggestions, comments, or concerns, be sure to comment below. If you find any situations where it doesn’t work, please leave a comment and I will check it out.

To use this script, you need Greasemonkey addon. Once you have it, just go here and click install: http://userscripts.org/scripts/show/12393.

Here’s the code:

// Auto-Block Facebook Apps
//
// Version 1.2
//
// Date Written: 2007-09-18
// Last Modified: 2009-01-22 02:18 PM (14:18)
//
// (c) Copyright 2007 Ali Karbassi.
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Auto-Block Facebook Apps", and click Uninstall.
//
// --------------------------------------------------------------------
//
// WHAT IT DOES:
// After the facebook profile page is loaded, it finds all the
// applications that your friends have invited you to and blocks them.
// Do not worry though, you can go to
// http://facebook.com/privacy.php?view=platform&tab=all and unblock
// them
//
// NOTE: This does not alter, delete, edit, add, or anything else to
//       your facebook profile. Just remove or disable this script and
//       everything will be displayed the same as it used to
// --------------------------------------------------------------------
//
// ==UserScript==
// @name        Auto-Block Facebook Apps 1.2
// @author      Ali Karbassi
// @namespace   http://www.karbassi.com
// @description This script will block app invites sent to you by friends.
//              After the facebook profile page is loaded, it finds all the
//              applications that your friends have invited you to and blocks
//              them. Do not worry though, you can go
//              http://facebook.com/privacy.php?view=platform&tab=all and
//              unblock them.
// @include     http://*facebook.tld/home.php*
// @include     http://*facebook.tld/reqs.php*
// ==/UserScript==
// Find Subdomain
var subDomain = getSubDomain();

// Get links on the front page/request page
var anchors = document.getElementsByTagName('a');
var appReqExp = /reqs\.php#confirm_(\d*)_(.*)/;

for (var i = 0; i < anchors.length; i++) {
  if (appReqExp.exec(anchors[i].href)) {
    prep(RegExp.$1, anchors[i]);
  }
}

// Remove any notifications about apps.
removeNotifications();

// Functions
// PLEASE DO NOT TOUCH IF YOU HAVE NO IDEA WHAT YOU'RE DOING.
// YOU MIGHT BREAK IT.
// Prepares everything. When things are correct, it calls BlockApp.
function prep(appID, appNode) {
  var postformMatch = /name="post_form_id" value="(\w+)"/;
  var post_form_id = 0;

  GM_xmlhttpRequest({
    method: 'GET',
    url: 'http://www.facebook.com/apps/block.php?id=' + appID
         + '&action=block',
    headers: {
      'User-Agent': window.navigator.userAgent,
      'Accept': 'text/html',
    },
    onload: function(responseDetails) {
      var searchString = 'This will not prevent you from seeing';
      if( (responseDetails.status == 200)
          && (responseDetails.responseText.indexOf(searchString) != -1) ) {

        // Show that we are working on it.
        appNode.removeAttribute('href');
        appNode.innerHTML = 'Reading confirmation page...';

        postformMatch.exec(responseDetails.responseText);

        // Calls function to block the app
        BlockApp(RegExp.$1, appID, appNode);
      }
    }
  });
}

function BlockApp(post_form_id, appID, appNode) {
  GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://' + subDomain + 'facebook.com/apps/block.php?id=' + appID
         + '&action=block',
    headers: {
      'User-Agent': window.navigator.userAgent,
      'Accept': 'text/xml',
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: 'post_form_id=' + post_form_id + '&save=1',
    onload: function(responseDetails) {
      if (responseDetails.status == 200) {
        appNode.innerHTML = 'App Blocked!'
        appNode.href = 'http://facebook.com/reqs.php';
      }
    },
    onerror: function(responseDetails) {
      appNode.removeAttribute('href');
      appNode.innerHTML = 'App Block failed!';
    }
  });
}

function removeNotifications() {
  var inputs = document.getElementsByTagName('input');
  for (var i = 0; i < inputs.length; i++) {
    if (inputs[i].value == 'Ignore') {
      for (var j = 0; j < inputs[i].attributes.length; j++) {
        if ( (inputs[i].attributes[j].nodeName == 'onclick') &&
        (inputs[i].attributes[j].nodeValue.indexOf('click_add_platform_app') != -1) ) {
          var js = (inputs[i].attributes[j].nodeValue).split(' ');
          js.shift();
          js = js.join(' ');
          location.href = 'javascript:' + js;
        }
      }
    }
  }
}

function getSubDomain() {
  var subDomainRegExp = /http:\/\/(.*\.)facebook\.com/;
  var subDomain = '';
  if (subDomainRegExp.exec(document.location) != 0) {
    subDomain = RegExp.$1;
  }
  return subDomain;
}

Twitter style text counter in jQuery

By Ali Karbassi | October 27th, 2008 | Javascript | Comments
Punch Chart on Raphaël

I. Love. jQuery. I can’t say how much I love jQuery because some people might get jealous because jQuery might out-rank them in the scale of 0 to jAWESOME!

Enough drooling and leg humping. In a recent project, we needed a counter to display the number of characters the user had left in a text area. Nothing to hard or interesting. This sort of thing has been out there for years. The problem is, all the scripts I’ve found would automatically truncate the text. That is, if the user has 100 characters and they enter 105 characters, the 101 to 105th characters are gone. This is very annoying!

Rather than control the user and annoy them, we wanted to take the method Twitter does; Warn the user, don’t allow them to submit until the warning is fixed. That is, if the text counter is negative, they cannot submit, but once it’s 0 or greater, it’s fair game.

To add to the fun, we needed visual cues, i.e. colours! After some search and no luck, I sat down and wrote this little beauty. It’s version 1 so be nice.

You can always grab a copy here: http://karbassi.com/scripts/javascript/twitterCounter.js or http://plugins.jquery.com/project/twittercounter

/*
 * twitterCounter
 *
 * Displays a counter with the remaining text.
 *
 * Example:
 *  $('#description').twitterCounter(
 *  {
 *     limit: 140,
 *     counter: '#textcounter',
 *
 *     okSize: 140,
 *     okStyle: '.ok',
 *
 *     watchSize: 20,
 *     watchStyle: '.watch',
 *
 *     warningSize: 10,
 *     warningStyle: '.warning',
 *
 *     errorSize: 0,
 *     errorStyle: '.error',
 *  });
 *
 * $Version: 2008-10-24
 * Copyright (c) 2008 Ali Karbassi
 * ali.karbassi@gmail.com
 */
jQuery.fn.twitterCounter = function(options) {
   var curSize = $(this).val().length;
   var charsLeft = options['limit'] - curSize;
   var types = ['ok', 'watch', 'warning', 'error'];
   var x = {};
   $.each(types,
   function() {
      var el = this.toString();
      x[el] = {
         'Max': options[el + 'Size'],
         'Style': options[el + 'Style'].substring(0, 1) == '.' || options[el + 'Style'].substring(0, 1) == '#' ? options[el + 'Style'].substring(1, options[el + 'Style'].length) : options[el + 'Style'],
         'Type': options[el + 'Style'].substring(0, 1) == '.' ? 'class': 'id'
      }
   });
   for (var i = 0; i < types.length; i++) {
      var el = types[i].toString(); // Last Element check
      if (i + 1 < types.length) {
         var nextEl = types[i + 1].toString();
         if (charsLeft > x[nextEl]['Max'] && charsLeft < x[el]['Max'] + 1) {
            clean();
         }
      } else {
         if (charsLeft < x[el]['Max']) {
            clean();
         }
      }
   }
   $(options['counter']).text(charsLeft); // Add an event so the counter updates when the user types.
   $(this).one('keyup',
   function() {
      $(this).twitterCounter(options);
   });
   function clean() {
      if (x[el]['Type'] == 'class') {
         $.each(types,
         function() {
            var temp = this.toString();
            if ($(options['counter']).hasClass(temp)) {
               $(options['counter']).removeClass(temp);
            }
         });
         $(options['counter']).addClass(x[el]['Style']);
      } else {
         $(options['counter']).id(x[el]['Style']);
      }
   }
};

Photo credit: Dmitry Baranovskiy

Uninstall Inquisitor and/or Glims

By Ali Karbassi | October 16th, 2008 | OS X, Uncategorized | Comments
Schoschie vs. Apple: 1 — 0

Recently I’ve given Glims a try. Even though it tries to combine what Inquisitor and Saft both do into one single free application, I was very disappointed in the ease of use and look.

Before trying Glims, I had to uninstall (remove) Inquisitor that was already running on my version of Webkit and Safari. To do this, I opened up terminal and typed the following commands (with my password that is):

sudo rm -rf /Library/InputManagers/Inquisitor/
sudo rm -rf /Library/Receipts/inquisitor*
sudo rm -rf ~/Library/Application\ Support/Inquisitor/

After couple hours of use, I wanted to switch back to Inquisitor, which meant that I had to remove Glims. To do that action, I pulled up terminal, yet again, and typed the follow:

sudo rm -rf /Library/InputManagers/Glims/
sudo rm -rf ~/Library/Application\ Support/Glims/

That should take care of everything, leaving my computer nice and clean.

Photo credit: schoschie

Primes in Ruby

By Ali Karbassi | September 10th, 2008 | Programming | Comments
26/366 Discrete Mathematical Structures

While working on some homework for a mathematics course, I ran into a problem; I needed a list of primes. I could manually produce a list of 10, maybe 20 primes but what’s the fun in that. Having my trusty MacBook near me, I loaded up TextMate and started to write a simple Ruby program to produce primes.

After a few minutes, the code turned into something much bigger than I expected. Researching to see if my formulas were correct, I continued on to create a separate file for this class. The outcome produced this:

class Primes
  attr_reader :primes

  def initialize(len = nil)
    return nil if len.nil?

    state = Numeric.new
    @primes = [2, 3]

    i = 4
    count = 0
    while count < len.abs - 2
      (2..(Math.sqrt(i).ceil)).each do
         |x|
         state = true
         if (i.divmod(x)[1] == 0)
            state = false
            break
         end
      end

      if state
        @primes << i
        count +=1
      end
      i += 1
    end

    return @primes
  end
end

p = Primes.new(10)
puts p.primes

# Output
# ------
# 2
# 3
# 5
# 7
# 11
# 13
# 17
# 19
# 23
# 29

I know this isn’t perfect, but it was a fun 20 minute side project. If you want to improve on it, just head over to my gist.

Quickly, and efficiently, mass rename files in bash

By Ali Karbassi | June 18th, 2008 | How To, Linux, OS X, Ubuntu | Comments

Quick tip for everyone who is using Mac OS X, Unix, or anything with bash. If you want to mass rename a bunch of files, there isn’t a simple way of doing it. Either you would have to do it manually1 or you could use this simple line of code.

ls ryan.* | awk '{print("mv "$1" "$1)}' | sed 's/ryan/steve/2' | /bin/sh

Let me explain it quickly. Let’s say you have a whole folder of files named ryan.*2 and you want to rename them to steve.*.

The first part displays a list of files that match the wildcard of ryan.* then it is piped to the second part ( awk '{print("mv "$1" "$1)}' ). This part prints a list of commands such as mv ryan.txt ryan.txt.

Well, that’s close but you want to move ryan.txt to steve.txt, not itself. This is where the third part comes in. What sed does in this situation is replace any instance of ryan with steve. The last part runs the whole thing as a list of shell commands.

  1. mv ryan.txt steve.txt []
  2. Such as ryan.txt, ryan.gif, ryan.php, ryan.asp, etc []

CSS Font List

By Ali Karbassi | May 27th, 2008 | Design | Comments

While designing a simple website for a friend, I noticed that I knew nothing about the different font families I could use. While I have tons of fonts on my computer, I can’t use those on the web1.

I did a quick Google search and found a small list and here it is for you.


‘American Typewriter’, ‘Courier New’, Courier, Monaco, mono
‘Arial Rounded MT Bold’, Helvetica, Arial, sans-serif
Baskerville, Georgia, Garamond, ‘Times New Roman’, Times, serif
‘Book Antiqua’, Georgia, Garamond, ‘Times New Roman’, Times, serif
‘Bookman Old Style’, Georgia, Garamond, ‘Times New Roman’, Times, serif
‘Brush Script MT’, ‘Comic Sans’, sans-serif
Chalkboard, ‘Comic Sans’, sans-serif
Didot, Georgia, Garamond, ‘Times New Roman’, Times, serif
Futura, Impact, Helvetica, Arial, sans-serif
‘Gill Sans’, ‘Lucida Grande’, ‘Lucida Sans Unicode’, Verdana, Helvetica, Arial, sans-serif
‘Helvetica Neue’, Helvetica, Arial, sans-serif
‘Hoefler Text’, Garamond, Georgia, ‘Times New Roman’, Times, serif
‘Lucida Grande’, ‘Lucida Sans Unicode’, Lucida, Verdana, Helvetica, Arial, sans-serif
‘Marker Felt’, ‘Comic Sans’ sans-serif
Myriad, Helvetica, Arial, sans-serif
Optima, ‘Lucida Grande’, ‘Lucida Sans Unicode’, Verdana, Helvetica, Arial, sans-serif
Palatino, ‘Book Antiqua’, Georgia, Garamond, ‘Times New Roman’, Times, serif
Cochin, Georgia, Garamond, ‘Times New Roman’, Times, serif
‘Goudy Old Style’, garamond, ‘book antiqua’, ‘Times New Roman’, Times, serif sequence


  1. Well, without creating images. []

Safari 3.1.1 and Saft 10.0.7

By Ali Karbassi | April 16th, 2008 | How To, OS X | Comments

Saft needs to be updated to handle Safari 3.1.1

I have always used Webkit ever since switching to Safari as my general browser. Being that I’m always getting the newest build, I know what’s coming when Safari decides to upgrade.

Since Apple updated Safari from 3.1 to 3.1.1, Saft, a wonderful “addon/plugin/what-have-you”, breaks. I know Hao Li at haoli.dnsalias.com will be updating it pretty soon, but I have found a quick fix until that is done.

  1. Quit Safari.
  2. Navigate to Applications/Saft.app
  3. Control click to show package contents.
  4. Open bundle and go to Contents, then Resources, Saft.bundle, and Contents. You’re full path should be Applications/Saft.app/Contents/Resources/Saft.bundle/Contents
  5. Double click or open Info.plist in your favorite text editor.
  6. Change SaftSupportedSafariBuild to 5525.18. This is to match the current Safari version/build.

    It will then look like this:

    <key>SaftSupportedSafariBuild</key>
    <array>
    	<string>5525.18</string>
    </array>
    		

  7. Save and relaunch Safari.

How to run Adium (AIM, Yahoo, MSN, ICQ, and GTalk)

By Ali Karbassi | April 12th, 2008 | OS X | Comments

Being that not all locations allow all ports to be accessed through their gateway to the internet, sometimes you will run into problems in connecting to your IM programs such as iChat or, even better, Adium.1

Now, we know that all internet access points (WiFi spots, hotels, etc) will allow Port 80.2

So, we’re going to switch our Adium to connect through 80 and 4433.

Adium AIM

Let’s start with the most common messenger, AIM. Set the port to 443 and the server should be the default for your application. At the time of this it is login.oscar.aol.com.

Adium YIM

For Yahoo, set the port to 80 and login server to scs.msg.yahoo.com.

Adium MSN

For MSN, set the port to 80 and the login server to messenger.hotmail.com. Also check the “Connect via HTTP” box. This allows access through port 80.

Adium GTalk

For Google Talk, or I’d imagine any Jabber network, set the Transport Layer Security. Also be sure to check “Force old-style SSL and “Require SSL/TLS. If you check “Do strict certificate checks”, you will get a message box every time you try to load up Adium to accept a certificate. I have left this on, but I do know for a fact if you uncheck this, that message will not bother you again.

Adium ICQ

Lastly, if you are still using ICQ4, you can set your port to 443 and login server to login.oscar.aol.com. I wouldn’t suggest using ICQ anymore because it’s a pretty bad service. Check out the criticisms on wikipedia.

Now, if you restart your Adium (or whatever client you are using), you should have connection to the IM protocols.

Draw backs

Some of the drawbacks to this method is that your data is being sent over an unsecure port, and therefore can be subject to any sniffers. If you are paranoid about your chats, I’d suggest using an online version such as Meebo which does go through HTTPS.

  1. The following steps should work for Pidgin. I hate Trillian because it’s a memory hog. Just my thoughts. []
  2. This is because it is the port most web servers output websites. You can see what other ports are used for on Wikipedia’s List of TCP and UDP port numbers page. []
  3. Secure HTTP, or HTTPS as most refer to it as []
  4. Did you know it is an initialism on the phrase “I seek you” and is now owned by AOL? []

Safari 3.1 and Pith Helmet

By Ali Karbassi | March 19th, 2008 | General, How To, OS X | Comments

Recently Apple updated their browser Safari to version 3.1. It does boast new features that us web developers love, but it also crashes some hacks we also love. Note that I’m not calling them “plug-ins”. Read the reasoning behind this.

Now, one of my favorite Safari hacks has been Pith Helmet and with the new update, it is considered “broken.” Here’s how to fix it:

  1. Quit Safari.
  2. Navigate to /Library/Application Support/SIMBL/Plugins/PithHelmet.bundle.
  3. Control click to show package contents.
  4. Open bundle and go to Contents.
  5. Double click or open info.plist in your favorite text editor.
  6. Change MaxBundleVersion to 5525.13. This is to match the current Safari version/build.

    It will then look like this:

    <key>MaxBundleVersion</key>
    <string>5525.13</string>
    		

  7. Save and relaunch Safari.

Continue reading

Facebook News Feed Filter

By Ali Karbassi | March 13th, 2008 | General | Comments

While stumbling around on Facebook, it seems like they accidently released (or to me for a second) a new front page. The front page we usually see is the News Feed. The new page is the same News Feed, but filtered.

I took the liberty to take some pictures.

Facebook's New News Feed Filter?

Facebook's New Newsfeed Filter

Facebook's new Filter?

What do you think?