Varázsló készítése CardLayout-val

CardLayout készítése Netbeansben.

Lépések:

  1. Felvettem az indító alkalmazást JFrame-ként BorderLayout()-tal.
  2. Hozzáadtam egy cards nevű JPanel()-t CardLayout()-tal.
  3. Csináltam egy pár újrafelhasználható panel-t amiből építkeztem.
  4. Pl. egy file választó panelt, multiselectionnel.
  5. A CardLayout()-hoz adtam a pár JPanel()-t ami az egyes kártyáknak felelt meg.
  6. Csináltam egy pár publikus függvényt az egyes panelok tartalmához, hogy hozzáférjek.
  7. Készítettem egy CardChanger osztályt, melyet bejegyeztem a frame-hez.
  8. A  e.getActionCommand()-val vizsgáltam, hogy mikor léptessem a kártyákat. cardLayout.next(cards) paranccsal.
  9. Ez után bizonyos gombra hívtam a working osztályt egy másik csomagból.

Korlátlan kategória mélység

Tábla tartalmaz egy 0-val paddingolt ordered oszlopot, mely vesszővel elválasztva mutatja az utat a gyerekig.

Beszúrásnál átveszi a szülő ordered mezőjét és hozzá bigyeszti saját id-jét.

Előnye eszerint lehet rendezni. Illetve ez az sql megadja a mélység szintjét.

Valamint alul egy lekérdezés, mely legyűjti az összes gyermek terméket.

 LENGTH(c.ordered) - LENGTH(REPLACE(c.ordered, ',', '')) AS depth
CREATE TABLE IF NOT EXISTS `category` (
  `cat_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `cat_name` varchar(64) COLLATE utf8_hungarian_ci NOT NULL,
  `parent_id` int(10) unsigned DEFAULT NULL,
  `ordered` varchar(255) COLLATE utf8_hungarian_ci DEFAULT NULL,
  `cat_color` int(10) unsigned NOT NULL,
  PRIMARY KEY (`cat_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci AUTO_INCREMENT=43 ;

 

Az új kategória beszúrása:

if($_POST['cat'] == "") { 
               //main category
                $sql = "INSERT INTO category (cat_name, parent_id, cat_color)
                        VALUES ('".$name."', 0,'".$_POST['color']."')";
                mysql_query($sql) or die ("Nem sikerült új kategória hozzáadása!");

                print_r($sql);

                $last_idd = mysql_insert_id();
                $padding_lastid = str_pad("$last_idd", 4, "0", str_pad_left);

                $sql3 = "UPDATE category 
                         SET ordered = '".$padding_lastid."'
                         WHERE cat_id = ".$last_idd;
                $result3 = mysql_query($sql3) or die ("Update problem!".$last_idd);

                print_r($sql3);
            }

            else { 

                //sub category
                $sql2 = "SELECT *
                         FROM category
                         WHERE cat_id = ".$_POST['cat']; 
                $result2 = mysql_query($sql2);

                $row2 = mysql_fetch_assoc($result2);
                $ordered = $row2['ordered'];

                $sql = "INSERT INTO category (cat_name, parent_id)
                        VALUES ('".$name."', '".$_POST['cat']."')";
                mysql_query($sql) or die ("Nem sikerült új kategória hozzáadása!");

                $last_idd = mysql_insert_id();

                $padding_lastid = str_pad("$last_idd", 4, "0", str_pad_left);

                $sql3 = "UPDATE category 
                         SET ordered='".$ordered.",".$padding_lastid."' 
                         WHERE cat_id=".$last_idd;
                $result3 = mysql_query($sql3) or die ("Update problem!".$ordered);
            }
SELECT coalesce(c2.cat_name,'-') AS parent_name, 
            c.cat_name AS child_name, 
            c.cat_id, c.ordered, color.col_class, 
            LENGTH(c.ordered) - LENGTH(REPLACE(c.ordered, ',', '')) AS occurence
            FROM category c
            LEFT JOIN category c2
            on c.parent_id=c2.cat_id
            LEFT JOIN color
            ON c.cat_color = color.col_id
            ORDER BY ordered ASC;

Az alábbi bekezdés pedig legyűjti a szülő gyerek kapcsolatokat 2 oszlopos formátumban.

//sub category         
    $sql2 = "SELECT getChildLst(".$cat_id.") AS cat_list";
    $result2 = mysql_query($sql2);
    $row2 = mysql_fetch_assoc($result2);
    $cat_idd .= $row2['cat_list'];

    //products
    $sql = "SELECT *
            FROM product
            INNER JOIN prod_cat
            ON product.pro_id = prod_cat.pro_id
            INNER JOIN price
            ON product.pro_id = price.pro_id
            WHERE cat_id IN (".$cat_idd.")";

 

És a getChildLst függvény mint tárolt függvény.

DROP FUNCTION `getChildLst`//
CREATE  FUNCTION `getChildLst`(rootId INT) RETURNS varchar(1000) CHARSET latin1
    DETERMINISTIC
BEGIN
 DECLARE Stemp VARCHAR (1000);
 DECLARE sTempChd VARCHAR (1000);
 DECLARE checkChd VARCHAR (1000);

 SET sTemp = '$';
 SET sTempChd = cast(rootId as CHAR);

 SET checkChd = cast(rootId as CHAR);

 WHILE sTempChd is not null DO

         IF( sTempChd != checkChd) THEN
          SET sTemp = concat(sTemp, ',', sTempChd);
         ELSE
              SET sTemp = sTempChd;
         END IF;

     SELECT group_concat(cat_id) INTO sTempChd FROM category where FIND_IN_SET(parent_id, sTempChd)> 0;

 END while;
 RETURN sTemp;
 END

Git with Bitbucket.org and Aptana

  1. Generate ssh key pairs.
  2. Upload to bitbucket account
  3. Create a .ssh/config file
    Host bitbucket.org
    IdentityFile ~/.ssh/anybody_rsa
  4. Terminal type:
    1. git config –global user.name „anybody”
    2. git config –global user.email anybody@anywhere.com
    3. cd c:/wamp/www or anywhere
      1. Caveout: If you don’t give, the default is C:/Users/anybody/
    4. git clone git@bitbucket.org:otheruser/repo.git
  5. Import existing project into the workspace

 

Mutató equivalencia C++

pmovie->title     ====     (*pmovie).title

NO EQUIVALENT TO:

*pmovie.title  ====   *(pmovie.title)
Expression What is evaluated Equivalent
a.b Member b of object a
a->b Member b of object pointed by a (*a).b
*a.b Value pointed by member b of object a *(a.b)
expression can be read as
*x pointed by x
&x address of x
x.y member y of object x
x->y member y of object pointed by x
(*x).y member y of object pointed by x (equivalent to the previous one)
x[0] first object pointed by x
x[1] second object pointed by x
x[n] (n+1)th object pointed by x

Mutató függvényre C++

// pointer to functions http://www.cplusplus.com/doc/tutorial/pointers/
#include <iostream>
using namespace std;

int addition (int a, int b)
{ return (a+b); }

int subtraction (int a, int b)
{ return (a-b); }

int operation (int x, int y, int (*functocall)(int,int))
{
  int g;
  g = (*functocall)(x,y);
  return (g);
}

int main ()
{
  int m,n;
  int (*minus)(int,int) = subtraction;

  m = operation (7, 5, addition);
  n = operation (20, m, minus);
  cout <<n;
  return 0;
}

Mutatók és tömbök C++

// more pointers source: http://www.cplusplus.com/doc/tutorial/pointers/
#include <iostream>
using namespace std;

int main ()
{
  int numbers[5];
  int * p;
  p = numbers;  *p = 10;
  p++;  *p = 20;
  p = &numbers[2];  *p = 30;
  p = numbers + 3;  *p = 40;
  p = numbers;  *(p+4) = 50;
  for (int n=0; n<5; n++)
    cout << numbers[n] << ", ";
  return 0;
}
10, 20, 30, 40, 50, 

Mutató és referencia maszlag C++

void duplicate(int& a, int&b){
  a*=2;
  b*=2;
}
void pointer_duplicate(int* a,int* b){
  // *a=(*a)+(*a)
  // *b=(*b)+(*b)
duplicate(*a, *b); //Ugyanaz mint a 2 kikommentezett
}
int main(){
  int a=2;int b (3);
  int* e; int* f;
  e=new int(3); f=new int(4);
  duplicate(a,b);
  duplicate(*e,*f);
  pointer_duplicate(&a,&b);
  pointer_duplicate(e,f);
}

Raphael JSON

r.circle(100, 100, 50).attr({
    fill: "CadetBlue",
    stroke: "black"
}).mouseover(function (e) {
    var httpRequest = new XMLHttpRequest();
    httpRequest.onreadystatechange = function() {
        if (httpRequest.readyState === 4) {
            if (httpRequest.status === 200) {
                var msg = JSON.parse(httpRequest.responseText);

                // do stuff, for example show a popup

            } else {

                // fail

            }
        }
    };
    httpRequest.open('GET', url);
    httpRequest.send();
});