2016年7月28日 星期四

[swift] imageView Attributes

There are six pictures .


class ViewController: UIViewController {
    @IBOutlet weak var imageShow: UIImageView!

    var arrImg = ["img01","img02","img03","img04","img05","img06"]
    var images:Array<UIImage> = []
    var p:Int = 0
    var count:Int = 0
    override func viewDidLoad() {
        super.viewDidLoad()
        imageShow.image = UIImage(named: arrImg[p])
        count = arrImg.count
        for key in arrImg {
            images.append(UIImage(named: key)!)
        }
        imageShow.animationImages = images
        imageShow.animationDuration = NSTimeInterval(count * 1)
        imageShow.animationRepeatCount = 0
        
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func prevClick(sender: UIButton) {
        p = p - 1
        if p < 0 {
            p = count - 1
        }
        imageShow.image = UIImage(named: arrImg[p])
    }

    @IBAction func nextClick(sender: UIButton) {
        p = p + 1
        if p == count {
            p = 0
        }
        imageShow.image = UIImage(named: arrImg[p])
    }
    @IBAction func playClick(sender: UIButton) {
        imageShow.startAnimating()
    }
    @IBAction func stopClick(sender: UIButton) {
        imageShow.stopAnimating()
    }
    @IBAction func borderClick(sender: UIButton) {
        imageShow.layer.borderColorUIColor.blueColor().CGColor
        imageShow.layer.borderWidth = 3
    }
    @IBAction func roundClick(sender: UIButton) {
        imageShow.layer.cornerRadius = 10.0
        imageShow.layer.masksToBounds = true
    }
    @IBAction func shadowClick(sender: UIButton) {
        imageShow.layer.shadowColor = UIColor.blackColor().CGColor
        imageShow.layer.shadowOffset = CGSizeMake(10.0, 10.0)
        imageShow.layer.shadowOpacity = 0.8
        imageShow.layer.shadowRadius = 5
    }
    @IBAction func normalClick(sender: UIButton) {
        imageShow.layer.borderWidth = 0
        imageShow.layer.cornerRadius = 0
        imageShow.layer.masksToBounds = false
        imageShow.layer.shadowOpacity = 0
    }

}

[PHP] is_array , in_array Function





is_array — Finds whether a variable is an array

<?php
echo is_array(array(1,2,3));  => True
echo is_array('123');     =>False
?>


in_array — Checks if a value exists in an array

<?php
echo in_array('b',array('a','b','c'));   => True
echo in_array('2',array('a','b','c'));   => False
?>

[PHP] is_numeric Function



Finds whether a variable is a number or a numeric string



Example:

<?php

echo is_numeric('33');   => True

echo is_numeric('we');   => False


?>


Returns TRUE if it is a number 

2016年7月26日 星期二

[PHP] print_r pretty print for PHP

Advance print_r in PHP

Example:

<?php

$a = array('1','2','5','8');
print_nice($a);

function print_nice($elem,$max_level=10,$print_nice_stack=array()){
    if(is_array($elem) || is_object($elem)){
        if(in_array($elem,$print_nice_stack,true)){
            echo "<font color=red>RECURSION</font>";
            return;
        }
        $print_nice_stack[]=&$elem;
        if($max_level<1){
            echo "<font color=red>nivel maximo alcanzado</font>";
            return;
        }
        $max_level--;
        echo "<table border=1 cellspacing=0 cellpadding=3 width=100%>";
        if(is_array($elem)){
            echo '<tr><td colspan=2 style="background-color:#333333;"><strong><font color=white>ARRAY</font></strong></td></tr>';
        }else{
            echo '<tr><td colspan=2 style="background-color:#333333;"><strong>';
            echo '<font color=white>OBJECT Type: '.get_class($elem).'</font></strong></td></tr>';
        }
        $color=0;
        foreach($elem as $k => $v){
            if($max_level%2){
                $rgb=($color++%2)?"#888888":"#BBBBBB";
            }else{
                $rgb=($color++%2)?"#8888BB":"#BBBBFF";
            }
            echo '<tr><td valign="top" style="width:40px;background-color:'.$rgb.';">';
            echo '<strong>'.$k."</strong></td><td>";
            print_nice($v,$max_level,$print_nice_stack);
            echo "</td></tr>";
        }
        echo "</table>";
        return;
    }
    if($elem === null){
        echo "<font color=green>NULL</font>";
    }elseif($elem === 0){
        echo "0";
    }elseif($elem === true){
        echo "<font color=green>TRUE</font>";
    }elseif($elem === false){
        echo "<font color=green>FALSE</font>";
    }elseif($elem === ""){
        echo "<font color=green>EMPTY STRING</font>";
    }else{
        echo str_replace("\n","<strong><font color=red>*</font></strong><br>\n",$elem);
    }
}


?>

Result:


[PHP] find the Duplicate values in array using php


Return duplicate values in array using PHP

Example:


<?php

$a = array('1','2','5','8');
$b = array('2','3','4','5');
print_r(array_repeat(array_merge($a,$b)));

function array_repeat($arr){
    if(!is_array($arr))
        return $arr;    
$arr1 = array_unique($arr);    
$arr3 = array_diff_key($arr,$arr1);    
return array_unique($arr3);}



?>

Result:

array $a



array $b



array_merge($a,$b)


array_repeat(array_merge($a,$b))







[PHP] Regular Expression to URL removed in PHP


Regular Expression to URL removed in PHP


Example:

<?php

    preg_match_all('/<a.*?href=".*?">(.*?)<[\/]a>/', $content,$arr);
    
    $new_content = str_replace($arr[0], $arr[1], $content);
    echo $new_content;


?>

Source:
$content='The author is occupied with handling solutions for quite sometimes and he has years of experience in <br />
<a href="http://www.optimumgroup.com.au/product-details/Outdoor-Dangerous-Goods-Storage/51" rel="nofollow">Outdoor Dangerous Goods Storage</a> and Line Shaft Conveyors. OHS is a premium company for handling <a href="http://www.optimumgroup.com.au/product-details/Line-Shaft-Conveyors/26" rel="nofollow">solutions</a> in Sydney. ';


Result:

$arr





$new_content


The author is occupied with handling solutions for quite sometimes and he has years of experience in 
Outdoor Dangerous Goods Storage and Line Shaft Conveyors. OHS is a premium company for handling solutions in Sydney.

 

[PHP] Regular Expression get Image Src

Regular Expression


Example:

<?php

$pattern = '/<img.*?src="(.*?)" .*?\/>/';
preg_match_all($pattern, $content,$img_arr);
print_r($img_arr);

?>

Source:

$content="<p> &nbsp; <img class="alignnone size-full wp-image-40188" src="http://img2.localhost/img/news/78/e2/78e2780f351d33ca38b93c677bc9578a.jpg" alt="18" width="750" height="500" />
If you are reading this article, chances are you are a Project Management Professional (PMP) and then you know what PDU stands for.

&nbsp; <img class="alignnone size-full wp-image-40186" src="http://img2.localhost/img/news/22/a6/22a66b54003dc506eea9b7fc93299723.jpg" alt="7" width="750" height="500" />
If not, Professional Development Units (PDU) are like credits that every PMP needs to earn in order to keep their certification.
 &nbsp; <img class="alignnone size-full wp-image-40187" src="http://img2.localhost/img/news/2d/66/2d66c300244ef31e57790203bea0870d.jpg" alt="18" width="750" height="500" />  &nbsp; &nbsp; &gt;&gt;&nbsp;</strong>&nbsp;<strong>http://housetube.tw</strong> <strong>&nbsp;</strong> &nbsp;</p>";

Reslut:

$img_arr


2016年7月25日 星期一

[PHP] function strrpos() in PHP

Function strrpos()

Find the position of the last occurrence of a substring in a string

Returns FALSE if the needle was not found.

Example:

<?

echo strrpos("http://localhost/img/c3d33ccc73567189.jpg","/");

?>


Result:

20

嘉義好美里3D彩繪圖

好美里3D彩繪村
共有13張大圖

分散在各地,可以依照圖上的指標方向去找下一個。

1.危機四伏

2.鯊到好美

3.人魚秘境

4.海底宮殿

5、7美人魚

6.地心歷險

8.海洋世界

9.水蓮游鯉

10.奇幻世界

11.寶貝的窩

12.白雪公主與七矮人

13.抹香鯨大戰大王烏賊,傑克與豌豆


危機四伏

危機四伏

海底宮殿


海洋世界

海洋世界

海洋世界

水蓮游鯉

水蓮游鯉

水蓮游鯉

奇幻世界


奇幻世界



白雪公主與七矮人

白雪公主與七矮人

白雪公主與七矮人









抹香鯨大戰大王烏賊,傑克與豌豆


鯊到好美

鯊到好美

鯊到好美

鯊到好美

人魚秘境


[PHP] Function substr() in PHP

Function substr()

The substr() function returns a part of a string.

<?php
   echo substr("abcde", -1); =>  e
    echo substr("abcde", -2);  => de


    echo substr("abcd", -3, 1); => b    echo substr("abcdef", 0, -1); =>  abcde    echo substr("abcdef", 2, -1); =>  cde    echo substr("abcdef", -4, -2); =>  cd



?>

[PHP] Function strstr(),strchr()

Function strstr()

Find the first word and return the rest of the string:

Example:

<?php
 echo strstr("I love my family.","my");?>


Result:

my family.




Function strchr()


Find the first occurrence of "o" inside "I love my family." and return the rest of the string:

Example:

<?php
 echo strstr("I love my family.","o");?>

Result:


ove my family.

[PHP] Removing the backslash in PHP

Example
       $txt = htmlspecialchars($txt);
to change
       $txt = stripslashes($txt);



Example2:
<?php
$str="<img src="\"http://img.localhost/548123df619bb06744fbcd075c0f1b52.jpg\"" >";
echo stripslashes($str);
?>


Result:
<img src="http://img.localhost/548123df619bb06744fbcd075c0f1b52.jpg" >

2016年7月24日 星期日

go Back in HTML,Javascript

go back button in HTML
<input name="Submit" type="button" onClick="javascript:history.back(1)" value="return" />

go to one page in HTML
<input type="button" value="Home" onclick="self.location.href='home.html'"/>

go to Google website in HTML
<input type ="button" onclick="javascript:location.href='http://www.google.com'" value="go to Google"></input>

go back button in Javascript
window.history.back();

2016年7月23日 星期六

台南 北區 Eat Time 義燉糖

台南 北區 Eat Time 義燉糖

地址:台南市北區海安路三段979
電話:06-2801198
營業時間:11:00-15:30; 17:00-22:00
消費金額:請參考菜單(需酌收10%服務費)
消費日期:2016.7

因有訂位,所以運氣好,坐長頸鹿探頭進去的那桌

有個小小的缺點,講話不方便,有長頸鹿擋著

若有當月壽星,可以整桌消費打9折(等於是免服務費)

先來環境介紹

門口

停車時,店家的小提醒



招牌,長頸鹿



長頸鹿特寫



大門口一進門的造景

因有訂位,所以運氣好,坐長頸鹿探頭進去的那桌

但有個小小的缺點,講話不方便,有長頸鹿擋著


店內座位算多

冷氣機上方都有娃娃




有辦集點活動,僅知道300元一點

有特約廠商,或是當月壽星,整桌消費可以打9折



店內環境




以下是菜單介紹





每桌都有先備好水杯、衛生紙及餐具


換介紹餐點


蕃茄香料嫩雞義大利麵(170元)

蒜香辣惡魔風味義大利麵(單點130)

單點的小pizza,忘記是什麼口味, 160元

開胃菜的酥炸薯條

辣味蕃茄牛肉燉飯(219)

甜點介紹
酒釀櫻桃黑森林蛋糕


法式風情烤布蕾

比利時風味鬆餅

藍莓乳酪蛋糕

咖啡熱拿鐵

蜜桃蘇打


奶蓋紅茶

若有當月壽星,可以整桌消費打9折(等於是免服務費)
義大利麵吃起來還好,青醬很濃,有看到別桌的客人有點火鍋
不知道火鍋會不會CP值高一點
是假日晚上去用餐,可能是服務生太忙,餐後的飲料一直催很久才送來,桌上的水壺沒水,也要自己跟服務生要水
店家環境很優,服務有待加強
餐點的話,個人口感不同,用完餐,大家的感覺是普通而已
佐佐義的義大利麵比較好吃