Kod Örnekleri & Teknik Rehberler
Python, C#, PHP ve modern web teknolojileri üzerine profesyonel örnekler.
Python & Veri Bilimi
PopülerÖğrenmesi kolay ve son derece güçlü. Yapay Zeka, Veri Analizi ve Otomasyon dünyasının lider dili Python ile ilgili en güncel snippetları keşfedin.
PyPDF2 kütüphanesi kullanarak, bir klasördeki birden fazla PDF dosyasını tek bir PDF belgesi haline getiren pratik otomasyon örneği.
import PyPDF2
import os
merger = PyPDF2.PdfMerger()
path = "./belgeler/"
for file in os.listdir(path):
if file.endswith(".pdf"):
merger.append(path + file)
merger.write("birlesik_dosya.pdf")
merger.close()
print("PDF dosyaları başarıyla birleştirildi.")
import os
merger = PyPDF2.PdfMerger()
path = "./belgeler/"
for file in os.listdir(path):
if file.endswith(".pdf"):
merger.append(path + file)
merger.write("birlesik_dosya.pdf")
merger.close()
print("PDF dosyaları başarıyla birleştirildi.")
Belirlenen bir haber sitesinden anlık başlıkları çekip listeleyen temel scraping örneği.
import requests
from bs4 import BeautifulSoup
url = "https://news.ycombinator.com/"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
for story in soup.find_all("span", class_="titleline")[:10]:
print(story.text)
from bs4 import BeautifulSoup
url = "https://news.ycombinator.com/"
page = requests.get(url)
soup = BeautifulSoup(page.content, "html.parser")
for story in soup.find_all("span", class_="titleline")[:10]:
print(story.text)
C# (CSharp) & .NET Core
KurumsalModern, nesne yönelimli ve yüksek performanslı. ASP.NET Core ve Entity Framework ile profesyonel web ve masaüstü projeleri geliştirin.
Text dosyası okuma
CSHARPBu kod seçilen text dosyasını satır satır okumaktadır.
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader("c:\\test.txt");
while((line = file.ReadLine()) != null)
{
Console.WriteLine (line);
counter++;
}
file.Close();
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader("c:\\test.txt");
while((line = file.ReadLine()) != null)
{
Console.WriteLine (line);
counter++;
}
file.Close();
Form1 içindeki buton.a tıklandığında oluşturulan Form2.nin açılmasını ve görüntülenmesini sağlayan kod örneği.
FrmForm2 frmForm2;
private void btnOpenNewForm_Click(object sender, EventArgs e)
{
if (frmForm2 == null)
frmForm2 = new FrmForm2();
frmForm2.FormClosed += FrmForm2__Closed;
frmForm2.ShowDialog();
}
private void FrmForm2__Closed(object sender, FormClosedEventArgs e)
{
frmForm2 = null;
}
private void btnOpenNewForm_Click(object sender, EventArgs e)
{
if (frmForm2 == null)
frmForm2 = new FrmForm2();
frmForm2.FormClosed += FrmForm2__Closed;
frmForm2.ShowDialog();
}
private void FrmForm2__Closed(object sender, FormClosedEventArgs e)
{
frmForm2 = null;
}
PHP & Web Programlama
DinamikWeb dünyasının emektar ve güçlü dili. PDO veritabanı yönetimi, API işlemleri ve modern PHP 8.x tekniklerini inceleyin.
Kullanıcının başka bir URL adresine yönlendirilmesini sağlar.
<?
header("Location: http://www.google.com");
?>
header("Location: http://www.google.com");
?>
Herhangi bir dosya silmek için PHP'de kullanılacak komut unlink()' tir. Bu fonksiyonu kullanırken silinmesi istenilen dosyanın adının verilmesi gerekmektedir.
<?
$dizin = "/wwwroot/";
unlink ("$dizin/yeni.txt");
echo ("yeni.txt dosyası silindi!");
?>
$dizin = "/wwwroot/";
unlink ("$dizin/yeni.txt");
echo ("yeni.txt dosyası silindi!");
?>
JavaScript (ES6+)
Frontendİnteraktif web sayfalarının kalbi. Modern JS, Async/Await ve DOM manipülasyonu üzerine en pratik kod parçacıkları burada.
İstenilen mesajın sayfa yüklenirken ekrana gelmesini sağlayan basit bir JavaScript örneği.
<SCRIPT LANGUAGE="JavaScript">
alert("Hardiske format atmak için OK 'e tıklayınız");
</SCRIPT>
alert("Hardiske format atmak için OK 'e tıklayınız");
</SCRIPT>
Sayfanızda üzerinde kayan yazı olan bir buton (düğme) olsun istiyorsanız bu script'i kullanabilirsiniz.
<SCRIPT LANGUAGE="JavaScript">
var message=" www.ipucu.web.tr ";//Mesajınızı Buraya Yazınız..
function ButtonURL(){
window.location="index.html"
}
function scroll()
{
message = message.substring(1,message.length) + message.substring(0,1);
document.bs.bs.value = message;
setTimeout("scroll()",140);
}
window.onload=scroll
document.write('<style type="text/css">')
document.write('.select{background: blue;border-color:"yellow";color:"white";font-family:Arial,Helvetica,Verdana;font-size:10pt;font-weight: bold;}')
document.write('</STYLE>')
document.write('<form name=bs><INPUT class="select" TYPE="button" NAME="bs" value="" onclick="ButtonURL()"></FORM>')
</script>
var message=" www.ipucu.web.tr ";//Mesajınızı Buraya Yazınız..
function ButtonURL(){
window.location="index.html"
}
function scroll()
{
message = message.substring(1,message.length) + message.substring(0,1);
document.bs.bs.value = message;
setTimeout("scroll()",140);
}
window.onload=scroll
document.write('<style type="text/css">')
document.write('.select{background: blue;border-color:"yellow";color:"white";font-family:Arial,Helvetica,Verdana;font-size:10pt;font-weight: bold;}')
document.write('</STYLE>')
document.write('<form name=bs><INPUT class="select" TYPE="button" NAME="bs" value="" onclick="ButtonURL()"></FORM>')
</script>