26 May 2011

openbsd network

openvpn

  • cd /etc/openvpn
  • openvpn client.conf


firewall:

  • pfctl -n -f /etc/pf.conf


network restart

  • sh /etc/netstart em1    (atau)
  • sh /etc/netstart

alias ip
  • cat /etc/hostname.em1

defautl gw :   /etc/mygate


route
  • route show
  • route -n show
  • route -n show -inet
  • netstat -rn
route add:
  • route add -net 192.168.1.0/24 192.168.1.254


24 May 2011

crossover: takleh restore window word


[Manage Bottle]->[ControlPanel]->[WineConfiguration]->[LaunchedSelectedItems]->[Graphics]
Uncheck Below options:
  • Allow the window manager to decorate the windows
  • Allow the window manager to control the windows

19 May 2011

joomla model

1- Joomla framework akan cipta kelas model yang sama nama dengan view, dan membolehkan kelas model tersebut digunakan dalam kelas view.


Dalam /com_sample/view/js/view.html.php
class SampleViewJs extend JView

Dalam /com_sample/models/js.php
class SampleModelJs extend JModel



2- nak call model dari dalam view

$model = &$this->getModel();
$greeting = $model->getGreeting();

16 May 2011

php kod formatter

artikel sebelum ni di hasilkan menggunakan kod php berikut:


<?php

$str 
$argv[1];

$str = ` cat $str;`;
highlight_string($str);
?>


joomla JController->execute()

Joomla JController->execute



<?phpclass kelas{
    function 
papar($var1 "lk"){
        echo 
"kod dalam function papar";  
    }
    function 
execute($task){
        
$this->$task();
    }
}
$objek = new kelas();$objek->execute("papar");
?>

11 May 2011

php variable scope

1) global
<?php
$a = 1;
$b = 2;

function cuba(){
  global $a;
  echo "\$a = $a  \$b = $GLOBALS['b']";
}
?>

2) static
<?php
  function init(){
  static $a;
  $a++
}

05 May 2011

svn propedit

ignoring file(s) in dir
svn propedit svn:ignore dir/

>> dalam mod vi, tukar senarai fail yg nak di abaikan. satu fail satu baris


ps/: kalau guna svn propset, akan overwrite senarai fail yg sebelum.

svn ignore dir

svn propset svn:ignore '*' unwanted_dir/

1)
webcapt/tmp$ svn status
M sessions
? sessions/ruby_sess.20649250e5a2ebfa
? sessions/ruby_sess.34a7003c82eaa928
? sessions/ruby_sess.f8c127b41f2b56ba
? sessions/ruby_sess.a75f05bc662a38ac

2)
webcapt/tmp$ svn propset svn:ignore '*' sessions/
property 'svn:ignore' set on 'sessions'

3)
webcapt/tmp$ svn status
M sessions

4)
webcapt/tmp$ svn commit
"svn-commit.tmp" 4L, 87C written
Sending tmp/sessions
Committed revision 19.

5)
webcapt/tmp$ svn status
[[[no more {? sessions/ruby_sess.34a7003c82eaa928} ]]]

UUID

1)
$ ls /dev/disk/by-uuid/ -alh
total 0
drwxr-xr-x 2 root root 100 2011-05-05 10:15 .
drwxr-xr-x 5 root root 100 2011-05-05 10:15 ..
lrwxrwxrwx 1 root root 10 2011-05-05 10:15 185de63a-3239-494d-993d-25cac74231dd -> ../../sda2
lrwxrwxrwx 1 root root 10 2011-05-05 10:15 1ca70448-5191-43de-b9e0-3ce9dfa14703 -> ../../sda3
lrwxrwxrwx 1 root root 10 2011-05-05 10:15 4c63ea13-039b-4346-b726-0a0cf59ab86e -> ../../sdb1


2)
$sudo blkid
/dev/sda1: TYPE="swap"
/dev/sda2: UUID="185de63a-3239-494d-993d-25cac74231dd" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda3: UUID="1ca70448-5191-43de-b9e0-3ce9dfa14703" SEC_TYPE="ext2" TYPE="ext3"
/dev/sdb1: UUID="4c63ea13-039b-4346-b726-0a0cf59ab86e" TYPE="ext3"


ref: http://ubuntuforums.org/showthread.php?t=1026957

04 May 2011

find dan rm

find ./ -mtime +100 -exec rm -r {} \;

cari dalam ./ file yang berumur lebih dari 100 hari, dan delete.
> +100 : 100 hari dan lebih
> -100 : kurang dari 100 hari
> 100 : exact 100 hari


lain-lain pilihan:
-amin, -atime, -cmin, -ctime, -mmin, and -mtime

c(ctime) > file's status
a > access
m > File's data modified

time > day(24 hours)
min > min


ref:http://www.linuxquestions.org/questions/linux-newbie-8/delete-files-older-than-30-days-using-cronjob-333477/

redmine, webdav - svn

bagaimana webdav semak permisi untuk baca svn


Fail: /usr/lib/perl5/Apache/Redmine.pm:

sub RedmineDSN {
my ($self, $parms, $arg) = @_;
$self->{RedmineDSN} = $arg;
my $query = "SELECT
hashed_password, auth_source_id, permissions
FROM members, projects, users, roles
WHERE
projects.id=members.project_id
AND users.id=members.user_id
AND roles.id=members.role_id
AND users.status=1
AND login=?
AND identifier=? ";
$self->{RedmineQuery} = trim($query);
}


ps:/kena add members dalam project

ref:http://www.redmine.org/projects/redmine/wiki/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl

03 May 2011

NoMachine Fullscreen

CTRL+Alt+F  full screen


URL: http://www.nomachine.com/ar/view.php?ar_id=AR03C00172

01 May 2011

inline assembly

mingW
#include <stdio.h>

get_sp(int *eip){
asm (
"mov %esp, %eax\n"
"mov 4(%ebp), %ebx\n" // ebx isi eip
"lea 8(%ebp), %ecx\n"
"mov (%ecx), %ecx\n"
"mov %ebx, (%ecx)\n"
);
}
void main(){
int x = 5;
asm( "int3");
printf ("StackPointer (ESP): 0x%x\n", get_sp(&x));
printf ("EIP: 0x%x\n", x);
}



cl (visual studio)
#include <stdio.h>

get_sp(int *eip){
__asm{ 
mov eax, esp
mov ebx, [ebp+4]
lea ecx,[ebp+8]
mov ecx, [ecx]
mov [ecx], ebx
}
}
void main(){
int x = 5;
__asm {int 3};
printf ("StackPointer (ESP): 0x%x\n", get_sp(&x));
printf ("EIP: 0x%x\n", x);
}