tmp
Monday, June 30, 2014
grep
###検索するファイルの拡張子を指定 ```bash grep <pattern> . -r --include="*.txt" --include="*.html" ``` ###検索文字をファイルから複数指定 ```bash cat pattern.txt | xargs grep -I pattern grep -i pattern . -r ```
Tuesday, June 24, 2014
Android で console.log を見る
AndroidSDK か Android Studio が入ってるのが前提(adbを使用する) adbの場所(Android Studioの場合) ```bash /Applications/Android Studio.app/sdk/platform-tools/adb ``` PATHが通ってなかったら通しておく ```bash export PATH=$PATH:/Applications/Android\ Studio.app/sdk/platform-tools ``` ###接続されているデバイスの確認 ```bash adb devices List of devices attached 381eb813 device ``` ###ログ出力(ブラウザのconsole.logのみ) ```bash adb logcat | grep browser | grep Console ``` ##参考 * <http://webtech-walker.com/archive/2011/05/12152024.html>
Tuesday, June 10, 2014
Ubuntu 14.04 Install
###ISO <http://releases.ubuntu.com/releases/trusty/>からDL <http://releases.ubuntu.com/releases/trusty/ubuntu-14.04-server-amd64.iso> ##Install ###Language [English] ###Menu [Install Ubuntu Server] ###Choose language [English]->[United States] ###Configure the keyboard [No]->[Japanese]->[Japanese] ###Configure the network [eth0: Intel ...] Hostname: ubuntu ###Set up users and passwords Full name for the new user: (適当に) Username for your account: (適当に) Choose a password for the new user: (適当に) Re-enter password to verify: (上のパスワードを再度) [No] ###Configure the clock [Yes] ###Partition disks [Guided - use entire disk and set up LVM] ->[SCSI3 (0,0,0) (sda) ..]->[Yes]->[8.3 GB] ->[Yes] ###Configure the package manager (何も入力せずEnter) ###Confituring tasksel [No automatic updates] ###Software selection [LAMP server], [OpenSSH server]にチェック ###Configuring mysql-server-5.1 New password for the MySQL "root" user: (適当に) Repeat password for the MySQL "root" user: (上のパスワードを再度) ###Install the GRUB boot loader on a hard disk [Yes] ###Finish the installation [Continue]
Ubuntu 10.10 Install
##ISO <http://old-releases.ubuntu.com/releases/maverick/>からDL <http://old-releases.ubuntu.com/releases/maverick/ubuntu-10.10-server-amd64.iso> ##Install ###Language [English] ###Menu [Install Ubuntu Server] ###Choose language [English]->[United States] ###Ubuntu installer main menu [No]->[Japan]->[Japan] ###Configure the network [eth0: Intel ...] Hostname: ubuntu ###Configure the clock [Yes] ###Partition disks [Guided - use entire disk and set up LVM] ->[SCSI3 (0,0,0) (sda) ..]->[Yes]->[8.3 GB] ->[Finish partitioning and write changes to disk]->[Yes] ###Set up users and passwords Full name for the new user: (適当に) Username for your account: (適当に) Choose a password for the new user: (適当に) Re-enter password to verify: (上のパスワードを再度) [No] ###Confituring tasksel [No automatic updates] ###Software selection [LAMP server], [OpenSSH server]にチェック ###Configuring mysql-server-5.1 New password for the MySQL "root" user: (適当に) Repeat password for the MySQL "root" user: (上のパスワードを再度) ###Configuring grub-pc [Yes] ###Finish the installation [Continue]
Thursday, June 5, 2014
c++ で apache module 開発
##必要なパッケージのインストール ``` sudo apt-get install apache2-threaded-dev sudo apt-get install g++ ``` ##サンプル用のモジュールを作成 ###mod_cpphello.cpp ``` #include "ap_config.h" #include "apr.h" #include "apr_lib.h" #include "apr_strings.h" #include "apr_network_io.h" #include "apr_want.h" #include "httpd.h" #include "http_config.h" #include "http_core.h" #include "http_request.h" #include "http_protocol.h" #include <string> extern "C" module AP_MODULE_DECLARE_DATA cpphello_module; typedef struct { char *hellomessage; } cpphello_dir_config; static void *cpphello_create_dir_config(apr_pool_t *p, char *path) { cpphello_dir_config *cfg = (cpphello_dir_config *)apr_pcalloc(p, sizeof(cpphello_dir_config)); cfg->hellomessage = (char *)"Hello World!"; return cfg; } static int cpphello_handler(request_rec *r) { cpphello_dir_config *cfg = (cpphello_dir_config *) ap_get_module_config(r->per_dir_config, &cpphello_module); std::string messagetosend = std::string("<html><p>") + std::string(cfg->hellomessage) + std::string("</p></html>\n"); r->content_type = "text/html"; if (!r->header_only) { ap_rputs(messagetosend.c_str(), r); } return OK; } static void register_hooks(apr_pool_t *p) { ap_hook_handler(cpphello_handler,NULL,NULL,APR_HOOK_MIDDLE); } extern "C" { module AP_MODULE_DECLARE_DATA cpphello_module = { STANDARD20_MODULE_STUFF, cpphello_create_dir_config, NULL, NULL, NULL, NULL, register_hooks }; }; ``` ###Makefile ``` ## ## Makefile -- Build procedure for fast3lpoad Apache module ## ## This is a C++ module so things have to be handled a little differently. # the used tools APXS=apxs2 APACHECTL=apachectl # Get all of apxs's internal values. APXS_CC=`$(APXS) -q CC` APXS_TARGET=`$(APXS) -q TARGET` APXS_CFLAGS=`$(APXS) -q CFLAGS` APXS_SBINDIR=`$(APXS) -q SBINDIR` APXS_CFLAGS_SHLIB=`$(APXS) -q CFLAGS_SHLIB` APXS_INCLUDEDIR=`$(APXS) -q INCLUDEDIR` APXS_LD_SHLIB=`$(APXS) -q LD_SHLIB` APXS_LIBEXECDIR=`$(APXS) -q LIBEXECDIR` APXS_LDFLAGS_SHLIB=`$(APXS) -q LDFLAGS_SHLIB` APXS_SYSCONFDIR=`$(APXS) -q SYSCONFDIR` APXS_LIBS_SHLIB=`$(APXS) -q LIBS_SHLIB` # the default target all: mod_cpphello.so # compile the shared object file. use g++ instead of letting apxs call # ld so we end up with the right c++ stuff. We do this in two steps, # compile and link. # compile mod_cpphello.o: mod_cpphello.cpp g++ -c -fPIC -I$(APXS_INCLUDEDIR) -I/usr/include/apr-1/ $(APXS_CFLAGS) $(APXS_CFLAGS_SHLIB) -Wall -o $@ $< # link mod_cpphello.so: mod_cpphello.o g++ -fPIC -shared -o $@ $< $(APXS_LIBS_SHLIB) # install the shared object file into Apache install: all $(APXS) -i -a -n 'cpphello' mod_cpphello.so # display the apxs variables check_apxs_vars: @echo APXS_CC $(APXS_CC);\ echo APXS_TARGET $(APXS_TARGET);\ echo APXS_CFLAGS $(APXS_CFLAGS);\ echo APXS_SBINDIR $(APXS_SBINDIR);\ echo APXS_CFLAGS_SHLIB $(APXS_CFLAGS_SHLIB);\ echo APXS_INCLUDEDIR $(APXS_INCLUDEDIR);\ echo APXS_LD_SHLIB $(APXS_LD_SHLIB);\ echo APXS_LIBEXECDIR $(APXS_LIBEXECDIR);\ echo APXS_LDFLAGS_SHLIB $(APXS_LDFLAGS_SHLIB);\ echo APXS_SYSCONFDIR $(APXS_SYSCONFDIR);\ echo APXS_LIBS_SHLIB $(APXS_LIBS_SHLIB) # cleanup clean: rm -f *.so *.o *~ # install and activate shared object by reloading Apache to # force a reload of the shared object file reload: install restart # the general Apache start/restart/stop # procedures start: $(APACHECTL) start restart: $(APACHECTL) restart stop: $(APACHECTL) stop ``` ##コンパイルしてインストール ``` sudo make install sudo make stop sudo make start ``` サイトを表示してみて ``` Hello World! ``` と表示されていたら成功 ##参考 * <http://d.hatena.ne.jp/yutakikuchi/20131101/1383260489> * <http://blog.enjoitech.jp/article/131>
Guest Additions
VirtualBox の Guest OS に Guest Additions を入れて共有フォルダを使用できるようにする Guest OS: Ubuntu 10.10 ##Guest Additionsのインストール ###sources.listの編集 `jp.archive.ubuntu.com` を `old-releases.ubuntu.com` に置換 ``` sudo vi /etc/apt/sources.list ``` ``` sudo apt-get update ``` ###必要なパッケージのインストール ``` sudo apt-get install gcc make sudo apt-get install xserver-xorg xserver-xorg-core ``` ###インストールCDのマウント GuestOSのメニュー->[Devices]->[Insert Guest Additions CD image...] ``` sudo mkdir /mnt/cdrom sudo mount -r /dev/cdrom /mnt/cdrom ``` ###インストール ``` cd /mnt/cdrom sudo ./VBoxLinuxAdditions.run ``` ##共有フォルダの設定 対象のOSを選択しVirtualBoxの[設定]->[共有フォルダー] 右側のアイコンから追加 フォルダーのパス: (任意のフォルダ) フォルダー名: vboxshare (適当に) [自動マウント], [永続化する]にチェックを入れる ##共有フォルダのマウント ``` sudo mkdir /mnt/share sudo mount -t vboxsf vboxshare /mnt/share ``` アクセス権を緩く ``` sudo mount -t vboxsf -o uid=1000,gid=1000,dmode=0755,fmode=0755 vboxshare /mnt/share ``` ##参考 * <http://d.hatena.ne.jp/hirokiky/20110822/1314033552> * <http://webkaru.net/linux/ubuntu-apt-get-update-error/> * <http://mpweb.mobi/windows/guestadditions-centos.php> * <http://mpweb.mobi/windows/share-centos.php> * <http://blog.goo.ne.jp/j_adversaria/e/9eace0f5c9a27066ce6121fd895d8192> * <http://risin.jp/blog/2010/12/27/virtualbox_/>
Ubuntu command
##バージョン確認等 ```bash $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick DISTRIB_DESCRIPTION="Ubuntu 10.10" ``` ```bash $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 10.10 Release: 10.10 Codename: maverick ``` ```bash $ arch x86_64 ``` ```bash $ uname -a Linux ubuntu-10-10 2.6.35-22-server #33-Ubuntu SMP Sun Sep 19 20:48:58 UTC 2010 x86_64 GNU/Linux ``` ##自動起動 ###設定の確認 ```bash $ sysv-rc-conf --list ```
Wednesday, June 4, 2014
VirtualBox ホストオンリーアダプターで接続
##環境 Host OS: MacOSX 10.9.3 Guest OS: Ubuntu 10.10 Server x64 ##VirtualBoxのインストール <https://www.virtualbox.org/wiki/Downloads>からダウンロードして適当にインストール ##VirtualBoxの設定 1. [環境設定]->[ネットワーク]->[ホストオンリーネットワーク]タブを表示 2. 右側のアイコンからネットワークの追加 3. [アダプタ]タブ IPv4 アドレス: 192.168.56.1 IPv4 ネットマスク: 255.255.255.0 4. [DHCP サーバ]タブ [サーバーを有効化]のチェックを外す 5. [OK]で `vboxnet0` というネットワークが作成される ##VMの作成 メニューの[作成]から... ###名前とオペレーティングシステム 名前: Ubuntu 10.10 (適当に) タイプ: Linux バージョン: Ubuntu (64bit) ###メモリーサイズ 512MB (適当に) ###ハードドライブ 仮想ハードドライブを作成する ###ハードドライブのファイルタイプ VDI (VirtualBox Disk Image) ###物理ハードドライブにあるストレージ 固定サイズ (適当に) ###ファイルの場所とサイズ 8.00GB (適当に) ##VMの設定 1. [設定]->[一般]->[高度]タブを表示 2. クリップボードの共有: 双方向 ドラッグ&ドロップ: 双方向 3. [設定]->[ネットワーク]->[アダプター 2]タブを表示 4. [ネットワークアダプターの有効化]にチェック 割り当て: ホストオンリーアダプター 名前: vboxnet0 5. [OK] ##Ubuntu 10.10 のインストール <http://fiahfy.blogspot.jp/2014/06/ubuntu-1010-install.html> ##Ubuntuでネットワークの設定 ネットワーク設定の編集 ```bash sudo vi /etc/network/interfaces ``` ```bash # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet static address 192.168.56.101 netmask 255.255.255.0 network 192.168.56.0 broadcast 192.168.56.255 ``` ネットワークの再起動 ```bash sudo /etc/init.d/networking restart ``` ##確認 Host OSから <http://192.168.56.101/> を表示してみる ```bash It works! This is the default web page for this server. The web server software is running but no content has been added, yet. ``` と表示されればok ##参考 * <http://linux.tsutomuonoda.com/ubuntu-server-12-04-lts-virtualbox-install/> * <http://server-setting.info/ubuntu/lamp-wordpress-install.html>
tar
毎回忘れる ###圧縮 ```bash tar zcvf <archive_name> <target_dir> ``` ###展開 ```bash tar zxvf <target_dir> ```
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)