Wednesday, September 30, 2015

Cool way to count bits

Count the set bits in a number.  Pretty cool.

for( count = 0; value != 0; count++ )
   value &= value – 1;


Wednesday, July 24, 2013

Tomato router and usb ext3 fs

I was copying some files to my routers external hd and sshed into it to notice that 75% of the CPU was being used by the ntfs daemon.  I had formatted the drive and used it with a windows machine before attaching it to the router.  I wanted to change it over to ext3 to hopefully bottle neck the router with smb instead :).

I ran into a problem making the fs on Tomato though, I had to create a swap device and turn it on for the mke2fs command to run successfully.  I didn't realize it would take so much memory.  But simple solution.  I also had to write the partition table after deleting the old partitions.

fdisk /dev/sda # adjust for disk if necessary
p # to see existing partitions
d # to delete partition if any
w # write table
fdisk /dev/sda
n # new swap
p # primary
1 # partition 1 swap
 # start at default block
+64M # size of Swap in MB; can be larger
t # set type of Swap partition
2 # partition 2 is Swap
82 # swap type
p # check partitions
n # new Data for remaining
p # primary
2 # partition 2 Data
 # default start block
 # default remaining blocks
p # check partitions
w # write it all out and exit
mkswap -L swap /dev/sda1
mke2fs -j -L data /dev/sda2

Friday, June 15, 2012

Dojo and the Grid !!!

DataGrid is making me pull my hair out.  I just wanted to be able to use a custom widget in the grid to edit things.  Worked pretty well, until we needed to make it AlwaysEditing (when the edit button was clicked).

If you have a button to edit, DO NOT USE AlwaysEditing and set the grid to editable.  It didn't work for me at least.

The way to do it is to return the widget from the formatter function, you create two functions and toggle between them depending on the state of your edit button.  Gottcha's include setting selectable for the grid in order to select text with your mouse, and override onCellClick so that the grid doesn't cause your widget to lose focus on the first click.

Tuesday, October 25, 2011

Dojo Tree's

I am working with Dojo Tree's at work.  Some interesting notes:

If you want to highlight the selectedNode in the tree use: .dijitTreeRowSelected.
You can set the selectedNode to null when there is a click in the root area of the tree like this:
    if(className.indexOf('dijitTreeContainer') !== -1) {
      this._objTree.set('selectedItem', null);
Also you might want to expand the selected node if you are creating a new node as a child of it:
    if(this._objTree.selectedItem) {
      this._objTree._expandNode( this._objTree.getNodeFromItem(this._objTree.selectedItem)[0] );

Wednesday, April 20, 2011

Tuesday, April 5, 2011

New cell phone plans

Jen and I are switching over to prepaid cell phone plans. We both transfered our "known" phone numbers to Google Voice, so that it is easy to switch plans and not have to worry about transferring the number.

I am still on Lockheed's cell phone plan, but we just bought Jen a sim card and 1000 minutes on T-mobile prepaid. The first challenge was getting Jen's cell phone an old Cingular phone unlocked so she could use it (all the prepaid phones are pretty ugly).

In the end I had to call AT&T to get the unlock code, but they didn't have a problem giving it to me, even though I had already canceled my plan with them, so that was nice. Here is the process:

  1. Get the IMEI number: Dial: * # 0 6 # and it will show up. I had to put in the old SIM card so that I could find this information. So get it while you can.
  2. Call the phone company (AT&T: 1-800-331-0500) and get the unlock code ours was: 4992009364755526, though I doubt it will do much good for anyone else.
  3. Enter the unlock code, for our w300i we had to press left, left, star, star while it was booting up. You can probably find instructions for most phones online.
The only problem is how to get the callee to see our GV number instead of our disposable phone number. You can do it multiple ways.
  • If someone texts you, the text will appear to come from some random number, you can call this and it will appear as if GV called them.
  • You can program in the number to call as , <2>, . the comma's are pauses, you also have to set GV to not ask for a password when the call comes from you mobile phone.
  • You can make the call from GV itself, and it will call your phone then your callee's.
Not a prefect system, but probably the best they can do w/o becoming a provider.

NFS is a ...

I recently started my new job and have been tasked with creating an embedded application to speed up the processing a certain web pages. The process for embedded application at Trane involves booting the SC from a NFS mount, so that you can build your application and it is immediately ready to run and debug.

It was really strange, the SC would boot once, then it would return a -13 error during boot. Running the NFS daemon in the foreground showed me that it was complaining about my /etc/exports. I had my export set to "10.*", which seemed to cause a problem, even though the client was a 10..

Anyways changing the export to * seemed to fix the problem, so I am going to go with that for now. Might try to look at it again if things slow down again someday.