mysql sort with FIND_IN_SET

if you want to sort a colum  not with the standard up/ down order, you can use FIND_IN_SET in ORDER BY.

The functzion Find_in_set:

SELECT FROM FIND_IN_SET(“b”, “a,b,c”)

Just return 2, the position where matched.

Use in ODER BY Example:

SELECT * FROM Product

WHERE id IN ( 6,5,4)

ORDER BY FIND_IN_SET(id, “6,5,4”)

 

add branch display in bash

function parse_git_branch_and_add_brackets {
git branch –no-color 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/\ \[\1\]/’
}
PS1=”\h:\W \u\[\033[0;32m\]\$(parse_git_branch_and_add_brackets) \[\033[0m\]\$ ”

add into .bashrc

 

 

install PHPUnit under Mac OS 10.6 Snow Leopord

first, read the following Link:

http://kubyshkin.ru/posts/phpunit-on-mac-os-x-snow-leopard-10-6.html

Then if you get problem with symfony/YAML version conflict  like:

phpunit/PHPUnit requires package “symfony/YAML” (version >= 1.0.2, version <= 1.0.2), installed version is 1.0.6
No valid packages found
install failed

Just uninstall it with:

sudo pear uninstall symfony/YAML
uninstall ok: channel://pear.symfony-project.com/YAML-1.0.6

then install old version like this:

sudo pear install symfony/YAML-1.0.2
downloading YAML-1.0.2.tgz …
Starting to download YAML-1.0.2.tgz (9,299 bytes)
…..done: 9,299 bytes
install ok: channel://pear.symfony-project.com/YAML-1.0.2

Now you can install PHPUnit :

sudo pear install phpunit/PHPUnit
downloading PHPUnit-3.6.12.tgz …
Starting to download PHPUnit-3.6.12.tgz (120,240 bytes)
……………………..done: 120,240 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.6.12

 

Now to check phpunit

phpunit –version
PHPUnit 3.6.12 by Sebastian Bergmann.

Done!

Bring the old Scanner Medion MD90092 to work under Snow Leopord 10.6.*

I got a old scaner Mediaon MD90092 without Driver CDs for two Euros from “flohmarkt”. The MD90092 is a OEM Product from Microtek Hompage. I need it to run under Mac OS 10.6.8. So I download the scanpotter_1050.dmg (173.4 MB) from Microtek homepage and installed. It works! Great. And the scanner can not work with meine PC with XP. Strange.

 

 

Problem with change checkbox status more than 2 times under jquery 9+

Today I got a problem with the checkbox. I wrote a very simple select all/deselect all feathers with jquey. something like that:

$('.mycheck').attr("checked", checked); //select all

and

$('.mycheck').removeAttr('checked'); // deselect all

The Problem is, the code work only once. After the second time,the checkbox will not be checked, even if a attriube “checked” is already attached in DOM.

So I found the post in stackoverlfow: http://stackoverflow.com/questions/14494467/jquery-1-9-checkbox-not-checked-second-time-after-once-it-unchecked

use

$("#add_cart_checkbox").prop("checked", true) ;

has solved the problem.

 

install gcc on mac snowleopad and homebrew

1 To install gcc on mac just follow the link:

https://github.com/kennethreitz/osx-gcc-installer

2 to install homebrew:

http://mxcl.github.io/homebrew/

now try gcc with

gcc -v

you will see:

Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~123/src/configure –disable-checking –enable-werror –prefix=/usr –mandir=/share/man –enable-languages=c,objc,c++,obj-c++ –program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ –with-slibdir=/usr/lib –build=i686-apple-darwin10 –program-prefix=i686-apple-darwin10- –host=x86_64-apple-darwin10 –target=i686-apple-darwin10 –with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

great! done.