Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Monday, November 21, 2011

Kirim Email via Telnet ke SMTP

1. telnet smtp.****.com 25
2. ketik helo
--- nanti muncul respon dari server
3. ketik mail to:*******@***.com
---muncul Sender OK
4. ketik rcpt to:*******@***.com
---muncul Recipient OK
5. ketik data
---muncul Start mail input; end with .
6. ketik pesan yang akan dikirim
7. untuk mengakhiri pesan, ketik titik <.> kemudian enter
8. untuk keluar dari telnet ketik quit

dapet dari sini

Monday, September 13, 2010

setup timer di macro excel

Sub Timernya()
' script yang mau dijalankan setiap x waktu
Macro1
' macro akan memanggil kembali script ini setelah 5 menit
Application.OnTime Now + TimeValue("00:05:00"), "Timernya"
End Sub


dapet pencerahan dari sini

Friday, July 30, 2010

close browser without confirmation box

menutup jendela browser tanpa konfirmasi:

<script language=javascript>
window.open('','_self','');
window.close();
</script>

dapet dari sini

Monday, April 12, 2010

Validasi Form Input

<form action="index.php?menu=action" method="post" enctype="multipart/form-data"
name="form1" onsubmit="return validate_form(this)";>
Data: <input type=text name=data1>
Type: <label><input type="radio" name="tipe" value="1">tipe1</label>
<label><input type="radio" name="tipe" value="2">tipe2</label>
<input type="submit" value="submit" name="update">
</form>
validation script will be:
function validate_required(field,alerttxt) {
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}
}
}

function validate_install(thisform) {
with (thisform)
{
if (!document.form1.tipe[0].checked && !document.form1.tipe[1].checked)
{alert("Choose tipe1 or tipe2!");
document.form1.tipe[0].focus();
return false;}
if (validate_required(data1,"Data must be filled out!")==false)
{data1.focus();return false}
}
}
dapat pencerahan dari sini

Saturday, December 12, 2009

ASPX - DataGrid dalam Email

This summary is not available. Please click here to view the post.

Thursday, December 3, 2009

Mengirim Email via Aspx

Versi VB
<% @Page Language="VB" Debug="true" %>
<% @Import Namespace="System.Web.Mail" %>
<%
Dim strTo as String
Dim strFrom as String
Dim strSubject as String

strTo = "dia@dia.Com"
strFrom = "aku@aku.com"
strSubject = "Hi Dia"
SmtpMail.SmtpServer = "smtp.xxxx.com"

SmtpMail.Send(strFrom, strTo, strSubject, "email dari aku untukmu")
%>
Versi C#
<% @Page Language="C#" %>
<% @Import Namespace="System.Web.Mail" %>
<%

string strTo = "dia@dia.com";
string strFrom = "aku@aku.com";
string strSubject = "Hi Dia";
SmtpMail.SmtpServer = "smtp.xxxx.com"

SmtpMail.Send(strFrom, strTo, strSubject,"Email dari aku untukmu");
Response.Write("Email berhasil dikirim");
%>
dimodifikasi dari sini

Sebelumnya ada error berikut waktu running scriptnya:
System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.

Ternyata kalau tidak di set smtp nya, server akan menganggap smtp nya adalah localhost. Jadi kalau ada smtp khusus, tinggal ditambahin baris di bawah:
SmtpMail.SmtpServer = "smtp.xxxx.com"

Succesfully send the mail :)

Wednesday, November 4, 2009

Otomatis Maximize Excel Window Lewat Macro

Script ini digunakan untuk otomatis membuka sebuah file excel dalam format maximize.

Option Explicit

Private Sub Workbook_Open()
Application.WindowState = xlMaximized
End Sub


step:
copi kan script di atas ke macro workbook yang akan dibuka di bagian This Workbook

dapet dari sini :)

Wednesday, September 23, 2009

PHP date() Function

It formats a local time/ date as follow:


d - The day of the month (from 01 to 31)
D - A textual representation of a day (three letters)
j - The day of the month without leading zeros (1 to 31)
l (lowercase 'L') - A full textual representation of a day
N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday)
S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j)
w - A numeric representation of the day (0 for Sunday through 6 for Saturday)
z - The day of the year (from 0 through 365)
W - The ISO-8601 week number of year (weeks starting on Monday)
F - A full textual representation of a month (January through December)
m - A numeric representation of a month (from 01 to 12)
M - A short textual representation of a month (three letters)
n - A numeric representation of a month, without leading zeros (1 to 12)
t - The number of days in the given month
L - Whether it's a leap year (1 if it is a leap year, 0 otherwise)
o - The ISO-8601 year number
Y - A four digit representation of a year
y - A two digit representation of a year
a - Lowercase am or pm
A - Uppercase AM or PM
B - Swatch Internet time (000 to 999)
g - 12-hour format of an hour (1 to 12)
G - 24-hour format of an hour (0 to 23)
h - 12-hour format of an hour (01 to 12)
H - 24-hour format of an hour (00 to 23)
i - Minutes with leading zeros (00 to 59)
s - Seconds, with leading zeros (00 to 59)
e - The timezone identifier (Examples: UTC, Atlantic/Azores)
I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise)
O - Difference to Greenwich time (GMT) in hours (Example: +0100)
T - Timezone setting of the PHP machine (Examples: EST, MDT)
Z - Timezone offset in seconds. The offset west of UTC is negative, and the offset east of UTC is positive (-43200 to 43200)
c - The ISO-8601 date (e.g. 2004-02-12T15:19:21+00:00)
r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200)
U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)



for example you can use this function to change a date format:
date("d M Y H:i:s" ,strtotime($the_date))

copied from here

Friday, July 24, 2009

NTLDR Missing

Seminggu yang lalu, satu server dengan win2k server-hdisk scasi di kantor ga mo update antivirus gara2 error di windows installernya. Berhubung tu server emang udah tua, bermasalah, plus servìs pada ga jalan, jd banyakan manualnya, so aku coba buat repair windows. Malangnya, di tengah2 repair, file ntldr ma ntdetect.com ga mau kecopi dan begitu booting ulang error dng message NTLDR Missing. mampus.com dah *_*
Seminggu kucoba segala cara:
- repair console, coba copy ntldr dari cd ke drive C tapi access denied
- boot pke disk versi win 98 hdisk tak terdetek coz tipenya NTFS
- repair pake disket, termasuk repair console, tapi tetep access denied
waktu copy ntldr
- instal win server 2k ma win xp di drive D, teteup.. sama2 error cannot copy NTLDR
-harddisk dibuka di server lain, terdetek tp no file
detected.
so, tetep aja ga berhasil. pusing.com wis pokoke... mana lg ga da akses internet, mo cari wangsit susah.
Satu usaha biar data terakhir bisa diambil: copi data ke disket lewat console, setelah sebelumnya removable disk di enable pake command SET. Cape deh..bolak balik dari ruangan server ke ruanganku, secara kapasitas cuma 1.4mb untuk data yg bejibun. Sangat memabukkan tapi mau gimana lagi, yang penting data kebackup.
Sampai disket ke 10, aku masih semangat ngopi data. Daripada musti nyekrip lagi kerjaan 1bulan terakhir to.. tapi memasuki disket 11 desperado mode: ON. Gambar yg musti d backup ribuan bo! Mana di console gabisa xcopy, jadi musti copi 1-1. Tidaaaaakkkk!!!
Hari ke-6 stelah hampir nyerah, -tp tetep ga mau format ulang coz data di drive C belum terbackup semua- aku coba browsing2 pake soner tercintakyu, dapet ilmu baru euy.. bootingnya pake disket yang diisi NTLDR, ntdetect.com ma boot.ini. Berhasil pak!! Slamet..slamet..
*hikmah: jangan backup data hanya di satu pc. mending dobel backup di pc lain untuk jaga2. noting tu lus. plg cuma perlu space harddisk sajah.
*thanks to my w950 n t-sel which provide me the internet access, also forums i've visited last night :)

Monday, March 9, 2009

serba-serbi macro excel

waktu searching cara setting warna font lewat macro excel, dapet artikel menarik tentang macro excel...
semua ada di sini... (paling ga yang aku cari ada hehehe...)
excelquotient.wordpress.com

ini buat edit font warna:
With Range("A1:B4").Font
.Name = "Verdana"
.Bold = True
.Size = 8
.ColorIndex = 23
End With


kalau yang ini dapet dari microsoft help and support buat edit warna cell . color bisa diganti pattern kalau mau ditambahkan pattern
Selection.Rows(Counter).Interior.Color = #112255

Monday, March 2, 2009

Run Time Error '1004'

Run Time Error '1004'
Calculate Method of Range Class Failed


tau ga masalahnya apa... calculation mode nya musti otomatis *_*

Thursday, February 19, 2009

run time error -2147220975

waktu jalanin script buat kirim email notifikasi EQTrack pake macro excel, ada notifikasi di bawah:

agak bingung juga, servernya dipindah kok jadi error gitu...
pikirku mungkin karena beda OS, yang lama XP dan sekarang 2003 server.
searching punya searching, akhirnya dapet pencerahan dari sini.

Klik kanan antivirus, masuk ke console - opsi Access Protection kemudian uncheck opsi "Prevent mass mailing worms from sending email" di bagian kanan.
Jika tidak ada Access Protection dan Console ter-lock, masuk ke Tools dan Unlock User Interface.
solved dah... thanks to whom ever gave the solution.

sah!!!

Tuesday, February 10, 2009

mengganti forward slash '/' dengan backslash '\'

kemarin buat ganti slash dengan backslash aku nyoba skrip ini ga jalan:
$string = ereg_replace ('\', '/', $string);

ada error:
Warning: ereg_replace(): REG_EESCAPE in /action/pjo.php

'\' aku ganti jadi '\\' eh ke replace nya beneran jadi '\\' padahal pengennya cuman '\'

akhirnya dapet dari sini

$string = ereg_replace ('\\\\', '/', $string);

ternyata di php \\ akan dirubah menjadi \, dan untuk mendapatkan murni backslash, kita harus menggunakan \\\\

contoh kasus:
//my_computer/temp/file.doc di rubah jadi \\my_computer\temp\file.doc

Sunday, January 25, 2009

copi folder lewat command line

kemarin aku nemu kesulitan waktu mau buat scheduler task backup data SQL ke folder D. script mentok gara² ga bisa ngakses folder "Program Files" klo mo ngopi file database nya. script ga bisa jalan klo ada nama folder yang berspasi. tapi akhirnya berkat mr gugle nemu juga solusinya di sini

* buat folder yg mengandung spasi kita musti menggunakan tanda petik 2 (") untuk membuka dan menutup nama foldernya. misalnya untuk folder "Program Files" kita pakai syntax:
xcopy "C:\Program Files\Mysql\data\nosa" "D:\backup_sql" /I

* sementara kalau mau copy folder beserta subfolder dan isinya tinggal ditambahkan parameter "/S"
xcopy "C:\Program Files\Mysql\data\nosa" "D:\backup_sql" /I/S

kalau mau overwrite file yang sudah ada tinggal ditambahkan /Y

Thursday, November 20, 2008

php error: header already sent

Beberapa hari ini dipusingkan dengan error ini niy...:

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\nosa\admin\sidenav\main2.php:36) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\nosa\admin\sidepages\schedule.php on line 566

dan akhirnya dapet juga solusinya...
tinggal tambahin aja : ob_start() di bagian paling awal halaman...

jadi deh.... jd aman ditinggal cuti besok... :)

Wednesday, November 5, 2008

drop down menu

safety web yang ada sekarang menunya udah makin banyak. makan tempat banget. buat mengurangi space, menunya mo aku buat drop down, biar ke kanannya masih banyak space buat menu baru. secara masih banyak elemen yg musti ditambahkan. searching punya searching, akhirnya dapet 'contekan' dari sini.
lumayan bisa langsung diimplementasikan. tapi teteup bikin pusing euy... masalah klasik... display jadi rada kacau klo dibuka pake IE7. tau nih... css di IE6 beda sama IE7. kemarin udah ngedit buat IE7, tapi giliran bagus di IE7, mawut d IE6. huaaa.... mawut... moga minggu ini bisa kelar deh, biar besok ditinggal cuti ga da trobel yg berarti :)

Wednesday, August 27, 2008

mengganti baris baru di text area

dapet dari sini

$x = " *";
$pesan = $_POST['text'] ;
$pesanBaru = ereg_replace( "\n", $x, $pesanBaru);

note:
x - parameter untuk mengganti baris baru
pesan - pesan yg dimasukkan
pesanBaru - pesan baru setelah x dimasukkan

Sunday, May 18, 2008

Upload File - Auto Resize

langsung aja ya... ini scriptnya...:
btw berhubung aku upload error scriptnya, aku potong beberapa script.
jadi maklum kalau ada error hehehe

$error = false;
$file = false;
include "db.inc.php";
$upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]);

if (!$error && isset($_REQUEST["uploadbutton"]))
$size = $_FILES["dumpfile"]["size"];
if ($size < 500000) {
{ if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
{
$uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
$uploaded_filepath=str_replace("//admin/files/","/",$upload_dir."/".$uploaded_filename);

if (file_exists($uploaded_filename))
{ echo ("

File $uploaded_filename already exist! Delete and upload again!

\n"); }
else if !@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
{ echo ("

Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath

\n");
echo ("

Check the directory permissions for $upload_dir (must be 777)!

\n");
}
else
{ echo ("

Uploaded file saved as $uploaded_filename

\n");
$save = $uploaded_filename;
$file = $uploaded_filename;
header('Content-type: image/jpeg') ;
list($width, $height) = getimagesize($file) ;
$modwidth = 100;
$modheight = 100;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
// Here we are saving the .jpg, you can make this gif or png if you want
//the file name is set above, and the quality is set to 100%
imagejpeg($tn, $save, 100) ;
$filepath = "$uploaded_filename";
@unlink($filepath); }
}
else
{ echo ("

Error uploading file ".$_FILES["dumpfile"]["name"]."

\n");
}}}
else{echo "file kegedean $size";}
if ($filename==""){
?>
form method="POST" action=" echo '".$PHP_SELF."'; " enctype="multipart/form-data"
input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize"
p align="center">input type="file" name="dumpfile" accept="*/*" size="60"p align="center">input type="submit" name="uploadbutton" value="Upload"
/p>
/form>



Automatic Email Reporting with Attachment

Ada user yg butuh sistem untuk pengiriman email otomatis
dengan mengandalkan mr Google, dapet deh berbagai referensi untuk bikin email scheduler berikut:

ni untuk email.bat nya: tinggal ditulis di notepad, trs di save as *.bat
cd D:\php\ > folder dimana php berada
copy E:\ > file yg mo di attach
cd D:\php > lokasi php.exe
php D:\emailQC\mail.php > script buat ngirim

na ini isi file mail.php:

$to = "XXX";
$from = "XXX";
$cc = "XXX";
$bcc = "XXX";
$subject = "Load Assay Data";
$message = "\rDear all, \r\r Cuman ngetes pengiriman email dengan scheduler ni.... \r\rRegards,"; //

$fileatt="YYY";
$fileatt_type = $_FILES["YYY"]['type'];
$fileatt_name = "YYY";
$headers = "From: ".$from."\r\n";
$headers .= "Cc: ".$cc."\r\n";
$headers .= "Bcc: ".$bcc."\r\n";

$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\"";
$message = "Email dengan attachment dan MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .$message . "\n\n";
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: application/vnd.ms-excel\n" .
"Content-Disposition: attachment; filename=$fileatt_name\n".
"Content-Transfer-Encoding: base64\n\n" .$data . "\n\n" ."--{$mime_boundary}--\n";

$ok = @mail($to, $subject, $message, $headers);
?>

Scheduler Via PHP

Bulan lalu aku bikin sistem untuk kirim report otomatis pake scheduler di windows
tinggal tulis script berikut di notepad, terus di save as bat
tinggal di set aja scheduler biar bat tsb bisa dieksekusi di waktu yg kita inginkan
jadi dah...

cd c:\php > folder di mana php.exe berada
php D:\php\email.php > folder di mana file php yg mo dieksekusi berada