Embeda(mbed) 介紹 & Mac 10.8 開發使用

Embeda 是由國內廠商,於知名mbed所開發而來的.相容原有mbed系統(目前我測試是這樣的)資源豐富.
而mbed(MCU微控制器)類似於Arduino 都屬於簡單易用可快速架構開發.

各位可以前往官網查詢購買方式.
http://www.embeda.com.tw/tw/

接下來直接開箱:


(收到的樣子,大家可以看到實際大小實在夠迷你!!)


(整個控制版)

(接上usb即可使用)
Read More

Phalcon !! 以C開發的php freamwork!!

Phalcon is a C extension so you need to download a binary for your platform or compile it from source code.

看完這句,再去看 官方的數據. Framework Benchmark
這完全拋開PHP!!!的包袱.

安裝方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
##Ubuntu必須先確認 安裝下列套件
# sudo apt-get install php5-dev php5-mysql gcc
cd /tmp
# git clone git://github.com/phalcon/cphalcon.git
Cloning into 'cphalcon'...
remote: Counting objects: 1856, done.
remote: Compressing objects: 100% (700/700), done.
remote: Total 1856 (delta 1277), reused 1552 (delta 973)
Receiving objects: 100% (1856/1856), 1.76 MiB | 460 KiB/s, done.
Resolving deltas: 100% (1277/1277), done.
# cd /tmp/cphalcon/release
# ./configure
# make;make install;
/usr/local/etc/php/extensions.ini
extension=phalcon.so

待續…

Redis Key-Value資料庫建置實測

reids

Redis是一個開源的使用ANSI C語言編寫、支援網路、可基於記憶體亦可持久化的日誌型、Key-Value資料庫,並提供多種語言的API。從2010年3月15日起,Redis的開發工作由VMware主持。

通常,Redis將數據存儲於記憶體,或被配置為使用虛擬記憶體。通過兩種方式可以實現數據持久:使用快照的方式,將內存中的數據不斷寫入磁碟;或使用類似MySQL的日誌方式,記錄每次更新的日誌。前者性能較高,但是可能會引起一定程度的數據遺失(後者相反)。

Mac 使用brew安裝reids

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-> % brew install redis
==> Downloading http://redis.googlecode.com/files/redis-2.4.8.tar.gz
######################################################################## 100.0%
==> make -C src
==> Caveats
If this is your first install, automatically load on login with:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/Cellar/redis/2.4.8/homebrew.mxcl.redis.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
 
If this is an upgrade and you already have the homebrew.mxcl.redis.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
    cp /usr/local/Cellar/redis/2.4.8/homebrew.mxcl.redis.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
 
  To start redis manually:
    redis-server /usr/local/etc/redis.conf
 
  To access the server:
    redis-cli
==> Summary
/usr/local/Cellar/redis/2.4.8: 9 files, 424K, built in 5 seconds

Read More

Gearman Install OSX

安裝Gearman 在OSX上面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$ sudo -s
$ cd /tmp
$ wget https://github.com/downloads/libevent/libevent/libevent-2.0.15-stable.tar.gz
$ tar zxvf libevent-2.0.15-stable.tar.gz
$ cd libevent-2.0.15-stable
$ ./configure
$ make
$ make install
$ cd ..
$ wget https://launchpad.net/ubuntu/lucid/+source/libdrizzle/0.7-1/+files/libdrizzle_0.7.orig.tar.gz
$ tar libdrizzle_0.7.orig.tar.gz
$ cd libdrizzle-0.7/
$ ./configure
$ make
$ make install
$ cd ..
$ wget http://launchpad.net/gearmand/trunk/0.14/+download/gearmand-0.14.tar.gz
$ tar zxvf gearmand-0.14.tar.gz
$ cd gearmand-0.14/
$ ./configure
$ make
$ make install
$ cd ..
$ wget http://pecl.php.net/get/gearman-0.8.0.tgz
$ tar zxvf gearman-0.8.0.tgz
$ cd gearman-0.8.0
$ phpize
$ ./configure
$ make
$ sudo make install
/bin/sh /tmp/gearman-0.8.0/libtool --mode=install cp ./gearman.la /tmp/gearman-0.8.0/modules
cp ./.libs/gearman.so /tmp/gearman-0.8.0/modules/gearman.so
cp ./.libs/gearman.lai /tmp/gearman-0.8.0/modules/gearman.la
----------------------------------------------------------------------
Libraries have been installed in:
   /tmp/gearman-0.8.0/modules
 
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
     during execution
 
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions:     /usr/lib/php/extensions/no-debug-non-zts-20090626/
 
$ which php
/usr/bin/php
 
$ php --info | grep -i configuration                                                                                                  (11-17 13:30)
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /private/etc/php.ini
Configuration
$ vi /private/etc/php.ini
======= 加入以下資訊 ======
extension_dir = " /usr/lib/php/extensions/no-debug-non-zts-20090626/"  <~~這不一定要
extension="gearman.so"
========================
$ php --info | egrep -i "(configuration|gearman)"
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /private/etc/php.ini
Configuration
gearman
gearman support => enabled
libgearman version => 0.14

MongoDB VS Mysql 簡單測試.

廢話不多說.
MongoDB 使用 MongoDB Object Document Mapper測試.
Mysql 使用 Object Relational Mapper測試.
MongoDB部分:
config.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
< ?php
require_once __DIR__ . '/../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
use Doctrine\Common\ClassLoader,
    Doctrine\Common\Annotations\AnnotationReader,
    Doctrine\ODM\MongoDB\Configuration,
    Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver,
    Doctrine\MongoDB\Connection,
    Doctrine\ODM\MongoDB\DocumentManager;
 
$classLoader = new ClassLoader('Doctrine\Common', __DIR__ . '/../../lib/vendor/doctrine-common/lib');
$classLoader->register();
 
$classLoader = new ClassLoader('Doctrine\ODM\MongoDB', __DIR__ . '/../../lib');
$classLoader->register();
 
$classLoader = new ClassLoader('Doctrine\MongoDB', __DIR__ . '/../../lib/vendor/doctrine-mongodb/lib');
$classLoader->register();
 
$classLoader = new ClassLoader('Symfony', __DIR__ . '/../../lib/vendor');
$classLoader->register();
 
$classLoader = new ClassLoader('Documents', __DIR__);
$classLoader->register();
 
$config = new Configuration();
 
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
 
$config->setHydratorDir(__DIR__ . '/Hydrators');
$config->setHydratorNamespace('Hydrators');
 
$config->setDefaultDB('doctrine_odm_sandbox');
//使用safe模式
$con = new Connection('localhost',array('safe'=>true, 'w' => 2,'wtimeoutMS' => 2000));
//使用一般模式
//$con = new Connection('localhost');
 
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
 
$dm = DocumentManager::create($con, $config);

Read More

FreeBSD DenyHosts 擋掉暴力破解 ssh 的使用者

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# cd /usr/ports/security/denyhosts; make install clean;
-------------------------------------------------------------------------------
To run denyhosts from startup, add denyhosts_enable="YES"
in your /etc/rc.conf.
Configiration options can be found in /usr/local/etc/denyhosts.conf
-------------------------------------------------------------------------------
In order to proper working of denyhosts
1. edit your /etc/hosts.allow file and add:
sshd : /etc/hosts.deniedssh : deny
sshd : ALL : allow
2. issue the following command if /etc/hosts.deniedssh does not exist yet
touch /etc/hosts.deniedssh 
-------------------------------------------------------------------------------
Warning:
 
syslogd should ideally be run with the -c option; this will ensure that
denyhosts notices multiple repeated login attempts.
 
To do this, add syslogd_flags="-c" to /etc/rc.conf
-------------------------------------------------------------------------------
===> Installing rc.d startup script(s)
===>   Registering installation for denyhosts-2.6_3
===>  Cleaning for denyhosts-2.6_3
#

Read More

VirtualBox-OSE on FrreeBSD 免x11

參考 http://d.hatena.ne.jp/wittro/20100617/1276782079

cd /usr/src
make build32 install32;
ldconfig -v -m -R /usr/lib32
cd /usr/ports/emulators/virtualbox-ose
make install clean
=============================================================================
 
VirtualBox was installed.
 
You need to load the vboxdrv kernel module via /boot/loader.conf:
 
vboxdrv_load="YES"
 
For bridged networking please add the following line to your /etc/rc.conf:
 
vboxnet_enable="YES"
 
Reboot the machine to load the needed kernel modules.
 
You also have to add all users to your vboxusers group in order to use vbox.
 
% pw groupmod vboxusers -m jerry
 
Running VirtualBox as non-root user may fail with a fatal error
NS_ERROR_FACTORY_NOT_REGISTERED. In this case delete /tmp/.vbox-*-ipc file.
 
Check wiki page for known issues and troubleshooting:
http://wiki.freebsd.org/VirtualBox
 
Please report any problems to emulation@. Thanks!
 
=============================================================================

弄個shell-script 來產生 虛擬機器設定

#!/bin/csh -f
set vm=winxp
set mem=1024
set cpu=1
#HD
set size=10000
#set dvdiso=`pwd`/windows7.iso
set dvdiso=/raid5/virtualbox/windowsXPSP3r.iso
# /root/.VirtualBox/Machines/
VBoxManage createvm -name $vm -register
VBoxManage modifyvm $vm --memory $mem --cpus $cpu --vram 32
VBoxManage modifyvm $vm --acpi on --ioapic on
VBoxManage modifyvm $vm --nic1 bridged --bridgeadapter1 bge0
VBoxManage modifyvm $vm --nictype1 82540EM
VBoxManage modifyvm $vm --vrdp on --cableconnected1 on --boot1 dvd
 
VBoxManage createvdi --filename ${vm}.vdi --size $size --format VDI --variant Standard
VBoxManage storagectl $vm --name ide --add ide --controller PIIX4
VBoxManage storageattach $vm --storagectl ide --port 0 --device 0 --type hdd --medium ${vm}.vdi
VBoxManage storageattach $vm --storagectl ide --port 1 --device 0 --type dvddrive --medium $dvdiso
#VBoxVRDP  --startvm $vm
#VBoxManage storageattach $vm --storagectl ide --port 1 --device 0 --type dvddrive --medium /usr/local/lib/virtualbox/additions/VBoxGuestAdditions.iso
#VBoxVRDP  --startvm $vm

執行 5900 vnc的port vnc的密碼123456

VBoxHeadless -n -m 5900 -o 123456 -s winxp -w 1024 -h 768

很方便 還可搞個私人雲端XDDD (其實只是lab)
效能上比之前用QEMU好上太多太多~~


2011-02-14補充:
在安裝virtualbox-ose的時候一定要選上WEBSERVICE選項,後面安裝的phpvirtualbox的時候需要用到。

啟動vboxwebsrv
$ vboxwebsrv
安裝phpvirtualbox
$ cd /usr/ports/www/phpvirtualbox && make install clean
$ VBoxManage setproperty websrvauthlibrary null
然後在Nginx或Apache中配置站點,目錄指向/usr/local/www/phpvirtualbox目錄
在瀏覽器中輸入http://localhost/phpvirtualbox就可以開始安裝配置Virtualbox了。

Clone VM export

1
2
3
$ VBoxManage export winxp -o winxp.ovf                                                                   (08-02 08:10)  
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Successfully exported 1 machine(s).
1
$  VBoxManage import winxp.ovf --vsys 0 --vmname winxp2