#linux

コメントでいろいろ書いてますが、root権限付与のところは多分個人の場合はそのままvisudoにユーザ名を追記して、会社の場合はグループを変更したほうが良さそうです。

# HOW TO CREATE USER AND GROUP, GRANT ROOT PRIVILEGE

## PART1 CREATE USER
# assume user1,user2,user3 is already created
# and they are in wheel group, which can execute as root
# and here we're creating a new user named:new_user

# create new user
useradd new_user
# set password for it, in the prompt
passwd new_user


# you can now login as new_user
# but when you run sudo you may get this error
new_user is not in the sudoers file.  This incident will be reported.
# so you need to set the privilege to new_user

## PART2 GRANT SUDO PRIVILEGE
## 1. BY CHANGE USER GROUP
$ visudo
############ in visudo ############
## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
## Same thing without a password
%wheel  ALL=(ALL)       NOPASSWD: ALL
############ in visudo ############
# It means people in wheel group can run all commands, without password
# Below we're adding the new user called new_user to the wheel group.

# list users and user id, group id, home directory, login shell, etc.
$ cat /etc/passwd
...
wheel:x:10:root,user1,user2,user3
...

$ id -a [user name]
uid=503(user3) gid=503(init_group) 所属グループ=503(init_group),10(wheel)
$ usermod -g init_group -G init_group,wheel new_user
$ id -a new_user
uid=506(new_user) gid=503(init_group) 所属グループ=503(init_group),10(wheel)

## 2. BY ADD USER TO sudoers FILE.
$ visudo
############ in visudo ############
new_user          ALL=(ALL) NOPASSWD: ALL
############ in visudo ############

## some handy commands
# show user list
$ cut -d: -f1 /etc/passwd
root
bin
daemon
adm
...

# TODO
# what is the difference between -g(initial_group) and -G(group)

# Reference
# (ENG) http://superuser.com/questions/120340/user-not-in-the-sudoers-file-this-incident-will-be-reported
# (JPN) http://kazmax.zpp.jp/linux_beginner/usermod.html
#tips #textmate #textmate

課題

最後の編集した箇所に遷移する機能はTextMateデフォルトではないですが、多分みんなUndo/Redoで実現していたと思います。 でも⌘Z(Undo)、⇧⌘Z(Redo)はやはり手間がかかってしまいますので、一発でできるかをググッてみたところ、TMGoToLastEditを見つかりました。

インストール

ダウンロード、解凍、ダブルクリックでインストール完了です。

使い方

⌥⌘J ( Option + Command + J ) あるいは Navigationのメニューからクリック

Go_to_Last_Edit

#linux #date #server
# stop it first if it's running, 
# or you will get a warning like: 
# the NTP socket is in use, exiting
$ /etc/init.d/ntpd stop

# ntp.nict.jp: 日本標準時プロジェクト 公開NTP
$ ntpdate ntp.nict.jp
19 Aug 15:30:18 ntpdate[27156]: step time server 133.243.238.243 offset -856.532277 sec

# start ntp again
$ /etc/init.d/ntpd start

# confirm
$ date
2011年  8月 19日 金曜日 15:32:15 JST

NPTについて

ここでは、ネットワーク上のサーバー及びクライアントマシンの時刻同期をとるためのプロトコルであるNTP(Network Time Protocol )について解説していきます。PCの時刻はマザーボード上のリアルタイムクロック(RTC)によって時間が表示されていますが、この時間はあまり正確ではなく、毎日少しづつ時間が狂っていきます(電池の消耗度にもよりますが、年間約10分程度)。NTPサーバーは、タイムサーバーに接続されたラジオ・クロックや原子時計から時刻を取得し、UTC (協定世界時)に同期させることができます。PCの時刻が狂っていると、メールの送受信時刻が狂ったり、こまめにとっているログの取得時間なども狂ってくることになります。Linuxでは標準でNTPサーバーが付属しているので是非、活用して時刻同期を行いましょう。

#tips #mac #textmate #textmate

従来の⌘T(Command + T)Go to Fileの問題:パスが効かない

⌘TはTextMateで速やかにファイルを開ける機能ですが、例えばこんなファイルがあるとします。 -blogs/index.html.erb -posts/index.html.erb -categories/index.html.erb -tags/index.html.erb -users/index.html.erb

で⌘Tで”blogs/index”を叩くと何も表示されない、つまりパスが効かないのが一番の問題です。それを解消するのがgotofile.tmbundle

インストール

cd ~/Library/Application\ Support/TextMate/Bundles/ git clone git://github.com/stevenchanin/gotofile.tmbundle.git GoToFile.tmbundle で、textmateを再起動

使い方

⇧⌘K ( Command + Shift + K )で新しいGo To Fileダイアログを開いて”ar/in”を叩くことでarticles/index.htmlが選択されます! <a href=”https://images.kinopyo.com/wp-content/uploads/2011/08/Go-To-File-Textmate-Bundle.png)><img class=”alignnone size-medium wp-image-2126” title=”Go To File Textmate Bundle” src=”https://images.kinopyo.com/wp-content/uploads/2011/08/Go-To-File-Textmate-Bundle-300x273.png) alt=”” width=”300” height=”273” /></a>

他にもspaceキーでQuickLookモードでファイルを見たり、⌥(option)キーでデフォルトのアプリでファイルを開いたり、⇧(shift)キーでフォーカスに選択したファイルのパスを入力することができます。

参考

http://how-i-work.com/workbenches/2-keyboard-based-no-mouse-rails-development-with-textmate

#ruby #rvm #環境構築

ruby 1.9.2p290へ更新しました。rvmもついでに。

# update rvm  
$ rvm get head  
# or older versions such as 1.0.0  
$ rvm update --head  
# you need to run reload to reflect the update  
$ rvm reload         
$ rvm -v
  rvm 1.7.2 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]

# install ruby 1.9.2.p290  
$ rvm install 1.9.2-p290
  ...  
$ rvm list
  ruby-1.9.2-p0
  ruby-1.9.2-p180  
# you need to replace the p0 based on your environment  
$ rvm upgrade ruby-1.9.2-p0 ruby-1.9.2-p290
yes  
yes  
yes  ...  
Upgrade complete!  
$ rvm list
  ruby-1.9.2-p290 [ x86_64 ]  
$ rvm --default use 1.9.2
$ ruby -v
  ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
#mysql #oracle #sql

これが既存データで、同じ日に複数のデータがある。

Example data

期望結果はこれ、つまり日付別で集計したい場合

Expected result

MySQLではDATE関数を使う

mysql> SELECT DATE(create_datetime), COUNT(*) FROM user_m GROUP BY DATE(create_datetime);

Oracleではto_char関数を使う

SELECT to_char(create_datetime, 'YYYY-MM-DD'), COUNT(*) FROM user_m GROUP BY to_char(create_datetime, 'YYYY-MM-DD');

参考

git clone https://github.com/enormego/EGOTextMateFullScreen.git /tmp/EGOTextMateFullScreen

xcodebuild -project /tmp/EGOTextMateFullScreen/EGOTextMateFullScreen.xcodeproj -target EGOTextMateFullScreen

cp -R /tmp/EGOTextMateFullScreen/build/Release/EGOTextMateFullScreen.tmplugin ~/Library/Application\ Support/TextMate/PlugIns

# after installed
rm -rf /tmp/EGOTextMateFullScreen/

これが完成図!

Textmate Fullscreen