Wednesday, January 15, 2014

Remap arrow keys to move directory in NERDTree

When using NERDTree, I would like to remap the left & right arrow to move up & down a directory.

I believe the left arrow has to be mapped to ‘u’ yet I do not know how to do this only when NERDTree is the active window.

Thanks!

Try this:

autocmd FileType nerdtree nmap <buffer> <left> u

Sunday, January 5, 2014

php simplexml get a specific item based on the value of a field

Is there a way i can obtain a specific item with SimpleXML ?

For example, i would like to obtain the title of an item having ID set to 12437 with this example xml :

<items>  <item>    <title>blah blah 43534</title>    <id>43534</id>  </item>  <item>    <title>blah blah 12437</title>    <id>12437</id>  </item>  <item>    <title>blah blah 7868</title>    <id>7868</id>  </item></items>

Here are 2 simple ways of doing what you want, one is iterating with each item like this:

<?php$str = <<<XML<items><item><title>blah blah 43534</title><id>43534</id></item><item><title>blah blah 12437</title><id>12437</id></item><item><title>blah blah 7868</title><id>7868</id></item></items>XML;$data = new SimpleXMLElement($str);foreach ($data->item as $item){    if ($item->id == 12437)    {        echo "ID: " . $item->id . "\n";        echo "Title: " . $item->title . "\n";    }}

Live DEMO.

The other would be using an XPath, to pin point the exact data you want like this:

<?php$str = <<<XML<items><item><title>blah blah 43534</title><id>43534</id></item><item><title>blah blah 12437</title><id>12437</id></item><item><title>blah blah 7868</title><id>7868</id></item></items>XML;$data = new SimpleXMLElement($str);// Here we find the element id = 12437 & obtain it's parent$nodes = $data->xpath('//items/item/id[.="12437"]/parent::*');$result = $nodes[0];echo "ID: " . $result->id . "\n";echo "Title: " . $result->title . "\n";

Live DEMO.

Friday, January 3, 2014

Detecting The iPhone Device Type

I’m having an issue when I deploy my app my phone. I am currently building the app on a 3gs, when the view is displayed, it is the iPhone 5 layout that shows, which makes some objects display partially off of the screen.

You can use the [UIDevice currentDevice] class method. This will donate you information approximately the device like systemName, systemVersion, model, etc.

If you need to obtain the screen dimensions instead, you could use the [UIScreen mainScreen] class method. With it you could obtain the applicationFrame or the screen bounds.

Hope this helps!

Unable to reference local variable with JsonBuilder

I have the following code

    AddTicketCommand addTicketCommand = new AddTicketCommand(request.JSON)    JsonBuilder jsonBuilder = new JsonBuilder()    jsonBuilder {        ticket {            subject addTicketCommand.subject            requester {                name currentUser?.name                email currentUser?.emailAddress            }            comment {                body addTicketCommand.comment            }            custom_fields {                [                        {                            id 21857727                            value addTicketCommand.zenRequestType                        },                        {                            id 21854146                            value addTicketCommand.zenProductId                        }                ]            }        }    }

The addTicketCommand object is not null on line 2 yet is undefined within the JsonBuilder closure. Is it not possible to access local variables in groovy from within closure?

You should be able to access addTicketCommand inside the closure as below. Mark the use of “parenthesis” instead of “curly” braces.

AddTicketCommand addTicketCommand = new AddTicketCommand(request.JSON)JsonBuilder jsonBuilder = new JsonBuilder()    jsonBuilder {        ticket {            subject addTicketCommand.subject            requester {                name currentUser?.name                email currentUser?.emailAddress            }            comment {                body addTicketCommand.comment            }            custom_fields ([ //Note the use of parenthesis                {                    id 21857727                    value addTicketCommand.zenRequestType                },                {                    id 21854146                    value addTicketCommand.zenProductId                }            ]) ////Note the use of parenthesis        }    }

Sunday, November 24, 2013

How can I join the count in MySQL?

If I have two tables one is:

CAR

| ID |  MAKER |---------------|  1 |  Honda ||  2 | Toyota ||  3 |   Ford ||  4 |  Honda ||  5 |   Ford ||  6 |  Honda |

where id is the car id number & maker is the maker of the car

and the other is

Purchase

| CUSTID | CARID |------------------|      1 |     1 ||      1 |     4 ||      1 |     6 ||      2 |     1 ||      2 |     2 ||      2 |     4 ||      2 |     6 ||      3 |     2 ||      4 |     5 ||      4 |     2 |

where custid is the id of the customer & carid is the id to a specific car

Is there a way to join the two together & then figure out which customers have bought ALL the Hondas?

Try this query:

select P.CustIDfrom purchase Pinner join CAR C on P.CarID=C.CarIDWHERE C.Maker like '%Honda%'group by CustIDhaving count(P.CarID)=    (select count(*) from CAR C where C.Maker like '%Honda%')

SQL FIDDLE

Saturday, November 16, 2013

Remove Conduit Search from your Mac

The Conduit search plugin was automatically installed after I clicked agree button whatever DivX upgrade says by accident.
Both Firefox & Chrome are affected. By removing this plugin, first of all is I completely remove DivX :D.

Saturday, November 2, 2013

Sublime 3 Licensed (Sublime 3 Public Beta)

Sublime 3 Licensed (Sublime 3 Public Beta)

28
JUN
Go to this link & Download your OS Specific Build:

http://www.sublimetext.com/3

Mac OS X

Open Terminal & Type the following:

1. cd /Applications/Sublime\ Text.app/Contents/MacOS/
2. Now Type “vim Sublime\ Text″
3. Now Change to hex mode in vim by doing this => “:$!xxd”
4. Now we will do find & replace ->> “:%s/5BE509C33B020111/5BE509C32B020111/g”

Now open the sublime & enter the below licence key , it should work like a charm.

WINDOWS

For x64: After install, open sublime-text.exe with hex editor. Find & replace “33 42″ with “32 42″. Save & using this license key to register:

—–BEGIN LICENSE—–
Patrick Carey
Unlimited User License
EA7E-18848
4982D83B6313800EBD801600D7E3CC13
F2CD59825E2B4C4A18490C5815DF68D6
A5EFCC8698CFE589E105EA829C5273C0
C5744F0857FAD2169C88620898C3845A
1F4521CFC160EEC7A9B382DE605C2E6D
DE84CD0160666D30AA8A0C5492D90BB2
75DEFB9FD0275389F74A59BB0CA2B4EF
EA91E646C7F2A688276BCF18E971E372
—–END LICENSE—–
You should copy from Begin License till End License.

UBUNTU:

Follow these to register sublime text 3 in ubuntu
1.Install ghex editor.(in terminal,enter “sudo apt-get install ghex”)..without the quotes.
2.In terminal enter “cd /usr/lib/sublime-text″
3.In terminal enter “sudo ghex sublime_text” & enter your password
4.In open ghex window,navigate to Edit>Replace.
5.In the find string section enter 33 42
6.In the replace with section enter 32 42
7.save & exit.