Cuma, Aralık 20, 2013

how to find postgresql duplicate records

SELECT * FROM (
SELECT id,
codename,
ROW_NUMBER() OVER(PARTITION BY name, codename ORDER BY id asc) AS count
FROM auth_permission
) dups
WHERE
dups.count > 1

Cumartesi, Eylül 21, 2013

ubuntu debian basit vnc server kurulmu


$ sudo apt-get install x11vnc vnc-java



kullanıcı şifresi oluşturalım.

$ x11vnc -storepasswd
Enter VNC password:
Verify password:
Write password to /home/kullanici/.vnc/passwd? [y]/n y
çalıştıralım
$ x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800

sunucumuz hazır.

http://sistem_makine_adresi:5800


Cumartesi, Temmuz 20, 2013

Okunası



Almanya’da bir lise müdürü, her eğitim öğretim yılı başında öğretmenlerine şu mektubu gönderirmiş.

“Bir toplama kampından sağ kurtulanlardan biriyim. Gözlerim hiçbir insanın görmemesi gereken şeyleri gördü. İyi eğitilmiş ve yetiştirilmiş mühendislerin inşa ettiği gaz odaları, iyi yetiştirilmiş doktorların zehirlediği çocuklar, işini iyi bilen hemşirelerin vurduğu iğnelerle ölen bebekler, lise ve üniversite mezunlarının vurup yaktığı insanlar.

Eğitimden bu nedenle kuşku duyuyorum. Sizlerden isteğim şudur.Öğrencilerinizin insan olması için çaba harcayın.Çabalarınız bilgili canavarlar ve becerikli psikopatlar üretmesin. Okuma yazma, matematik, çocuklarınızın daha fazla insan olmasına yardımcı olursa ancak o zaman önem taşır.”

Çarşamba, Temmuz 10, 2013

php online kullanıcı sayısı


$folder = dirname(__FILE__)."/activeusers/";
$timeold=30;   // seconds
$actualtime=date("U");   // seconds since January 1st, 1970.

$ip = "0.0.0.0";
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
if(isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
file_put_contents ($folder."$ip.$actualtime.txt", "0");

$counter=0;
$ipCounter = array();

$dir = dir($folder);
while($temp = $dir->read()){
if ($temp=="." or $temp==".."){continue;}
$filecreatedtime=date("U", filemtime($folder.$temp));
if ($actualtime>($filecreatedtime+$timeold)){
unlink ($folder.$temp);                                                                   //
}else{
$dataArr = explode('.',$temp);
$dataIp = sprintf('%s', $dataArr[0], $dataArr[0], $dataArr[0], $dataArr[0]);
$ipCounter[$dataIp] += 1;
$counter++;

if($ipCounter[$dataIp]>15) {
echo ":)";
exit(0);
}
}
}

Çarşamba, Mayıs 08, 2013

toplu dosya ismi değiştirme

for i in *.bmp; do convert ${i} ${i%bmp}jpg; done

gelişmiş seçenekler eklenebilir

convert -size 360x85 xc:transparent -font Bookman-DemiItalic -pointsize 72 -draw "text 25,60 'nixCraft'" -channel RGBA -gaussian 0x6 -fill YellowGreen -stroke RosyBrown -draw "text 20,55 'nixCraft'" nixCraft.png

Perşembe, Nisan 25, 2013

How to Compact a VirtualBox Linux Guest’s VDI file

Steps to compact a VDI file:

  1. Zero-fill the virtual machine’s disk using the dd command
  2. Shut down the machine
  3. Use Oracle’s VBoxManage program to compact the VDI
  4. Restart the virtual machine

To zero-fill a linux disk, the most efficient way is to use the dd command, which can write a stream to a file. In this case, we will be writing from the linux pseudo-device /dev/zero to a fill file. Use the following command to zero-fill the disk:

$ dd if=/dev/zero of=fillfile bs=1M

if= specifies the input file, in this case, a stream of zeroes. of= specifies an output file. If you were to specify a drive here, like /dev/sda, it would zero fill the entire drive, so be careful. bs= specifies the block size. In this case, it will write a megabyte of zeroes at a time into fillfile.

Once dd has completed, delete your zero-fill file

This is a minor consideration, done for speed. For future reference, it can be much faster to specify a 512k-1M block size when random filling a drive with dd for data destruction purposes.


Once dd has completed, delete your fill file (which should be taking up all of the free space on the drive at this point) and shut the virtual machine down. Once it’s shut down, run VBoxModify to complete the process. VBoxModify is a very powerful tool, and occupies an entire chapter of the VirtualBox Manual. Compact the VDI using the following command:

$ VBoxManage modifyhd /path/to/your.vdi --compact




When the process is complete, you should have a smaller vdi. If not, something went wrong with the zero-filling process or there was no room to compact your VDI.

Cuma, Mart 15, 2013

Javascript URL Parse

javascript ile url pars etme


var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";

parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"

Çarşamba, Mart 13, 2013

OpenERP Ident authentication failed for user "openerp"



OpenERP kurulumunda
Ident authentication failed for user "openerp"
hatası alıyorsanız pg_hba.conf dosyasında

local all all ident 

satırını

local all all md5


şeklinde deneyin