Archive

Archive for the ‘programming’ Category

WordPress update without FTP

March 14th, 2013

When I want to install upgrade / theme into wordpress, some of my server request me to input FTP connection setting, the others don’t. The problem is, my server don’t have a FTP account.

I’m trying to figure out, what’s the difference in setting, but i cannot find any. Luckily today i found a way to force wordpress NOT using the FTP method.

You just need to edit the wp-config.php. Add this line

define('FS_METHOD' , 'direct');

Reference: http://codex.wordpress.org/Editing_wp-config.php

Share

linux, programming, web

Happy Thanksgiving

November 26th, 2010

This time of year. Time to give thanks for everything that GOD had gave us.

Firstly thank you GOD for giving me strength for enduring this year. This year is full of problem, but I know You will guide me trough all these.

Thank you for all family, friends, for their love and support.

And all these year I use open source programming as my source of income, and never said any thanks. This year, I would like to address a thanks to the following:

- PHP Language. We’ve been together for 10 years now. Thanks for all the updates and security patches from PHP dev Team. Thanks for the easy to understand language.
- Ubuntu Linux. For being a great development OS for last 3 years. Ubuntu server had been installed on all my client.
- Apache Server. Running on all my server.
- MySQL. For keeping open source database for as long I learn database. Very stable and good for small – medium company.
- Komodo Edit. A very nice GUI for coding. Support all the language I use, PHP, SQL, Jquery, etc.
- JQuery. A neat, very fast, easily expandable and beautiful Javascript Framework.
- Bazaar. For keeping my source safe.
- Titanium Developer. New IPhone rapid development framework that I just learned. Very inspirational.

Thank you for the hard work developing these software. Happy Thanks Giving to all.

Share

programming, web, zuru zuru

Coloring Mac Terminal

September 14th, 2010

By default Mac OS X’s Terminal application uses the Bash shell (Bourne Again SHell) but doesn’t have directory and file color highlighting enabled to indicate resource types and permissions setting

Enabling directory and file color highlighting requires that you open (or create) ~/.bash_profile in your favourite text editor, add these contents:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

… save the file and open a new Terminal window (shell session). Any variant of the “ls” command:

ls
ls -l
ls -la
ls -lah

… will then display its output in color.

More details on the LSCOLORS variable can be found by looking at the man page for “ls“:

man ls
LSCOLORS needs 11 sets of letters indicating foreground and background colors:

directory
symbolic link
socket
pipe
executable
block special
character special
executable with setuid bit set
executable with setgid bit set
directory writable to others, with sticky bit
directory writable to others, without sticky bit

The possible letters to use are:

a  black
b  red
c  green
d  brown
e  blue
f  magenta
c  cyan
h  light grey
A  block black, usually shows up as dark grey
B  bold red
C  bold green
D  bold brown, usually shows up as yellow
E  bold blue
F  bold magenta
G  bold cyan
H  bold light grey; looks like bright white
x  default foreground or background

By referencing these values, the LSCOLORS variable setting mentioned above translates to:

Bold blue with default background for directories, bold magenta with default background for symbolic links, bold green with default background for sockets, etc.

Reference :
http://www.geekology.co.za/blog/2009/04/enabling-bash-terminal-directory-file-color-highlighting-mac-os-x/

Share

mac, programming

FTP Sync

April 14th, 2010

I use rsync a lot for sync between my Local and Remote Backup Server, rsync is doing very great job in term of speed and stability. But in certain cases, my client is not using ssh enabled account. So i forced to use an FTP sync, which is very slow. Sure you can use usual FTP Client like Filezilla, etc. But I doesn’t have a good build in sync system.

So I start googling and find 1 solution using LFTP. This program is already installed on standard Ubuntu installation, so you can use it immediately.

This is a sample file how to do a sync

#!/bin/bash    
HOST="yourhost.com"
USER="yourusernamehere"
PASS="yourpasswordgoeshere"
LCD="/home/local/directory/"
RCD="/home/remote/directory/"
lftp -c "set ftp:list-options -a;
open ftp://$USER:$PASS@$HOST; 
lcd $LCD;
cd $RCD;
mirror --reverse \
       --delete \
       --verbose \
       --exclude-glob config/ \
       --exclude-glob .htaccess \
       --exclude-glob index.php"

Finally in the section where it writes –exclude-glob, you write file that you should exclude in sync process. You can write directory name with / (slash) or filename, or event support a wildcard (* / ?).

Hope it helps

Share

linux, programming , ,

How to use ‘find’ in file

January 7th, 2010

Linux has many usefull command.

I always use this command to find a single file

find . | grep filename

But it’s not a really good implementation to how to use the syntax. For search file name, use this command instead.

find -name filename
find -name "you can event use a wildcard *"

For directory you can write like this

find -type d

For find only file

find -type f

Together joined will be

find -type f -name "rick*"

And the most useful syntax, you can run a command on every file it found. Here’s how to delete every jpg it found.

find -type f -name "*.jpg" -exec rm {} \;

Or upgrade all bzr in every directory

find -type d -maxdepth 1 -exec bzr update {} \;

Hope it helps

Share

linux, programming

XREA Anti comment spam & Trackback

August 5th, 2009

XREA (coreserver.jp) punya akses limit buat POST, sehingga kalo post dari IP yang engga di ijinkan akan keluar 403 Forbidden. Lamaaa banget gue cari masalahnya kenapa. Gue pikir masalah dengan script redirect gue, atau masalah dengan .htaccess gue.

Karena susah banget dapetnya nich, gue mencoba berbagi dengan mungkin temen2 yang bakal ngalamin masalah yang sama.

Quote ini diambil langsung dari support forumnya XREA

動的に変わるIPアドレスから 不正な投稿(トラックバック・コメントスパム、掲示板へのスパム目的のPOST処理)があるため、自動的にサーバー側でブロックを掛けさせていただく場合があります。

POST処理のみ拒否される場合は、SSLサーバーを介してアクセスしていただければと存じます。

https://ss1.xrea.com/www.sサーバー名.xrea.com/jp/admin.cgi

または

https://ss2.xrea.com/www.sサーバー名.xrea.com/jp/admin.cgi

もしくは、大変お手数で申し訳ございませんが、「.htaccess」ファイルで

<Limit POST>
order allow,deny
allow from all
</Limit>

として設置していただきますようにお願い申し上げます。

スパム目的のPOSTが多いサーバー、アカウントでは、単位時間あたりのPOST数に制限を設けております。
上記回避設定を行っていただきますと、スパムの影響で正常なPOSTが溢れてしまうことがあります。

「各ユーザー様での自己防衛について」の方法などで、スパムを極力制限していただきますようにお願い申し上げます。

Source : http://sb.xrea.com/showthread.php?p=78426#post78426

Share

linux, programming, web

Tips buat atasin LIMIT di subquery

August 4th, 2009

Bagi yang sering otak-atik MySQL dan bermain-main dengan subquery pasti pernah ketemu dengan pesan error ini dech.

This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME subquery’

Tadi kebetulan ada temen saya yang tanya. Eh Gimana sih keluarin data 5 tertinggi dari 50 data yang gue random? Pertama gue jawab-in bahwa query nya seperti ini

SELECT * FROM a WHERE a_id IN (
SELECT a_id FROM a ORDER BY RAND() LIMIT 50
) ORDER BY a_value DESC LIMIT 5

Terus gue bilang, bahwa “saat ini versi MySQL belom ada yang bisa begitu”. Terus setelah dia cari2, rupanya bisa diakal2in seperti ini :

SELECT * FROM (
SELECT * FROM a ORDER BY RAND() LIMIT 50
) ORDER BY t_value DESC LIMIT 5

Semoga membantu.

Credits goes to @xtian

Share

programming

Blackberry Application Launcher

June 24th, 2009

Pernah penasaran begimana caranya bikin launcer seperti detik.com? Punya website mobile dan pengen bikin launcher yang serupa tapi engga tahu cara bikinnya? Saya juga ^^

Saya baru aja mencoba bikin applikasi launcher seperti itu, yang rupanya engga sulit2 amat. Tutorial nya bisa banyak ditemukan dimana2. Code nya juga sebenernya simple sekali, hanya buka website tersebut, dan close program tersebut. Makanya disebut application launcher.

Ngapain pake launcher kalo bisa cuma pake bookmark?
1. Engga semua orang punya knowledge untuk menggunakan browser dengan semestinya.
2. Simplicity
3. Mengurangi 1 step click menuju bookmark

Semua proses pembuatannya sebenernya simple. Tapi ada satu masalah. Applikasi blackberry sebelum di launch mengharuskan developer untuk “menandatangani” applikasi tersebut. Gunanya supaya RIM bisa tracking code mana saja yang ada di pasar dan dikembangkan. Untuk bisa menandatangani applikasi tersebut dibutuhkan $20 tambahan.

Nah khan cape kalo cuma mao bikin satu launcher simple aja tapi sampe harus bayar biaya segitu ^^, nah kemaren itu baru aja gue register 1 key.

Gue menawarkan service untuk membuatkan anda application launcher hanya dengan 20Rb rupiah. Itung kita bagi2 license key nya supaya sama2 senang :P

Anda cukup mempersiapkan
1. URL website anda
2. Icon berupa PNG berukuran 80 x 80 pixel
3. Uang Rp 20.000

Jika anda tertarik silahkan tinggalkan informasi untuk menghubungi anda di comment.

Untuk contoh silahkan download launcher sample di http://www.rickyok.net/crackberry.jad

Share

programming

Teka teki solver

January 5th, 2009

Ini dulu gue bikin waktu lagi isenk di kantor, adu cepet2an pecahin teka teki silang, akhirnya karena kalah melulu gue kesel, terus bikin programnya buat pecahin teka teki silang otomatis. Emang engga guna :P tapi sapa tau suatu saat berguna.

<html>
<head><title>Crozz Puzzle - Problem Solver</title></head>
<body onLoad="frmSolver.txtFind.focus();frmSolver.txtFind.select()">
  <form name="frmSolver" method="GET" action="crossSolverFixedMulti.php">
    Soal : <br>
    <textarea name="txtSoal" cols="30" rows="12"><?echo $txtSoal?></textarea><br>
    Kata yang dicari :<br>
    <input type="text" name="txtFind" value="<?echo $txtFind?>">
    <input type="submit" value="Cari">
  </form>
 
<br>
Hasil : <br>
<table cellpadding="10"><tr>
<?
  // Pecahin soalnya jadi array of char
  $soal = trim($_GET["txtSoal"]);
  $verti = 0; $hori = 0; $totalchar = 0;
  for($a = 0 ; $a < strlen($soal) ; $a++) {
    if (ord($soal[$a]) != 13 && ord($soal[$a]) != 10) {
      $chara[] = $soal[$a];
      $warna[] = 0;
      $verti++;
      $totalchar++;
    }
    else {
      $a++;
      $verti = 0;
      $hori++;
    }
  }
  $hori++;
 
  $find = $_GET["txtFind"];
  $maxLevel = strlen($find);
 
  // Proses $warna
  function process($x, $y, $level, $arah) {
    global $chara, $verti, $hori, $totalchar, $maxLevel, $find, $warna;
    $pos = ($y * $verti) + $x;
    if ($level == $maxLevel) {
      return true; // Ketemu nich berarti
    }
    if ($x < 0 || $x >= $verti) {
      return false; // Melebihi batas X
    }
    if ($y < 0 || $y >= $hori) {
      return false; // Melebihi batas Y
    }
    if ($chara[$pos] != $find[$level]) { // Huruf di posisi ini salah :D
      return false;
    }
 
    $found = 0;
    if ($arah == 1 || $arah == 99) if (process($x + 1 , $y , $level + 1, $arah)) $found++; // Kanan
    if ($arah == 2 || $arah == 99) if (process($x + 1 , $y + 1, $level + 1, $arah)) $found++; // Kanan Bawah
    if ($arah == 3 || $arah == 99) if (process($x + 1 , $y - 1, $level + 1, $arah)) $found++; // Kanan Atas
    if ($arah == 4 || $arah == 99) if (process($x , $y + 1, $level + 1, $arah)) $found++; // Bawah
    if ($arah == 5 || $arah == 99) if (process($x , $y - 1, $level + 1, $arah)) $found++; // Atas
    if ($arah == 6 || $arah == 99) if (process($x - 1 , $y , $level + 1, $arah)) $found++; // Kiri
    if ($arah == 7 || $arah == 99) if (process($x - 1 , $y + 1, $level + 1, $arah)) $found++; // Kiri Bawah
    if ($arah == 8 || $arah == 99) if (process($x - 1 , $y - 1, $level + 1, $arah)) $found++; // Kiri Atas
 
    if ($found > 0) {
      $warna[$pos] = 1;
      return true;
    }
    else {
      return false;
    }
  }
 
  function cetakHasil() {
    global $warna, $chara, $verti, $hori;
    static $counter = 0;
    if ($counter % 5 == 0 && $counter > 0) echo "</tr><tr>";
    echo "<td style='border: 1px solid #FFCCFF;'><gantijadipre>";
    for ($y = 0 ; $y < $hori ; $y++) {
      for ($x = 0 ; $x < $verti ; $x++) {
        $pos = ($y * $verti) + $x;
        if ($warna[$pos] == 1) {
          echo "<font color='red'>" . $chara[$pos] . "</font>";
        }
        else {
          echo "<font color='black'>" . $chara[$pos] . "</font>";
        }
      }
      echo "\n";
    }
    echo "</gantijadipre></td>";
    $counter++;
    flush();
  }
 
  function resetWarna() {
    global $warna, $verti , $hori;
    for ($y = 0 ; $y < $hori ; $y++) {
      for ($x = 0 ; $x < $verti ; $x++) {
        $pos = ($y * $verti) + $x;
        $warna[$pos] = 0;
      }
    }
  }
 
  for ($a = 0 ; $a < $totalchar ; $a++) {
    if (process($a % $verti , floor($a / $verti) , 0 , 1)) {cetakHasil();resetWarna();};
    if (process($a % $verti , floor($a / $verti) , 0 , 2)) {cetakHasil();resetWarna();};
    if (process($a % $verti , floor($a / $verti) , 0 , 3)) {cetakHasil();resetWarna();};
    if (process($a % $verti , floor($a / $verti) , 0 , 4)) {cetakHasil();resetWarna();};
    if (process($a % $verti , floor($a / $verti) , 0 , 5)) {cetakHasil();resetWarna();};
    if (process($a % $verti , floor($a / $verti) , 0 , 6)) {cetakHasil();resetWarna();};
    if (process($a % $verti , floor($a / $verti) , 0 , 7)) {cetakHasil();resetWarna();};
    if (process($a % $verti , floor($a / $verti) , 0 , 8)) {cetakHasil();resetWarna();};
  }
 
?>
</tr></table>
</body>
</html>
Share

programming, web , ,

Samba on Ubuntu

January 5th, 2009

Ada masalah yang timbul pada saat kita mount smbfs ke suatu direktori. Masalah yang akan timbul adalah symbolic link tidak bisa diakses seperti layaknya bila di akses dari Windows. Jika kita membuat symlink ke folder lain (contoh: /opt/lampp/htdocs dan diarahkan ke /home/admin/www/), jika folder admin itu di mount ke Windows, makan pada saat kita klik ‘www’, akan dibuka tanpa masalah, Windows akan mengira symlink itu adalah suatu direktori, dan samba akan otomatis mengeluarkan isi direktori tersebut, ini bukanlah bug tetapi fitur yang sangat baik.

Jika anda mencoba mount folder tersebut dari ubuntu dan klik folder www tersebut, yang terjadi adalah, symlink tetaplah sebuah symlink. Anda akan dibawa ke folder /opt/lampp/htdocs di local anda. Cara pemecahannya adalah:

Tambahkan ini di bagian [globals]

follow symlinks = yes
wide symlinks = yes
unix extensions = no
Share

linux, programming , , ,

Switch to our mobile site