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.
Dış dünyaya açık bir API kullanarak, girilen şehrin anlık hava durumunu ve sıcaklık bilgilerini çeken Python uygulaması.
import requests
api_key = "YOUR_API_KEY"
sehir = "Ankara"
url = f"http://api.openweathermap.org/data/2.5/weather?q={sehir}&appid={api_key}&units=metric"
response = requests.get(url).json()
sicaklik = response['main']['temp']
durum = response['weather'][0]['description']
print(f"{sehir} için hava: {sicaklik} derece ve {durum}")
api_key = "YOUR_API_KEY"
sehir = "Ankara"
url = f"http://api.openweathermap.org/data/2.5/weather?q={sehir}&appid={api_key}&units=metric"
response = requests.get(url).json()
sicaklik = response['main']['temp']
durum = response['weather'][0]['description']
print(f"{sehir} için hava: {sicaklik} derece ve {durum}")
Sistemin CPU ve RAM kullanım oranlarını anlık olarak takip eden sistem aracı.
import psutil
print(f"CPU Kullanımı: %{psutil.cpu_percent()}")
print(f"Bellek Kullanımı: %{psutil.virtual_memory().percent}")
print(f"CPU Kullanımı: %{psutil.cpu_percent()}")
print(f"Bellek Kullanımı: %{psutil.virtual_memory().percent}")
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();
MessageBox Kulanımı
CSHARPKullanıcılara bilgi vermek için kullanılan MessageBoxın aynı zamanda ikonlarını ve butonlarını değiştirmekte mümkündür.
MessageBox.Show("There is an error.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
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");
?>
Veritabanından çekilen verileri comboboxta yazdıran güzel bir kod. Herhangi bir formun içerisinde <SELECT></SELECT> blokları arasına yerleştirilmesi gerekiyor.
<SELECT NAME='kategori_id'>
<?
$dbh=mysql_connect ("localhost", "", "") or die (' Veritabanına bağlantı sağlanamıyor. Nedeni: ' . mysql_error());
mysql_select_db ("veritabanı_adı");
$sql = "SELECT * FROM tablo";
$sonuc = mysql_query($sql);
while ($satir = mysql_fetch_row($sonuc))
{
?>
<OPTION Value="<?=$satir[0]?>"><?=$satir[1]?></OPTION>
<?
}
?>
</select>
<?
$dbh=mysql_connect ("localhost", "", "") or die (' Veritabanına bağlantı sağlanamıyor. Nedeni: ' . mysql_error());
mysql_select_db ("veritabanı_adı");
$sql = "SELECT * FROM tablo";
$sonuc = mysql_query($sql);
while ($satir = mysql_fetch_row($sonuc))
{
?>
<OPTION Value="<?=$satir[0]?>"><?=$satir[1]?></OPTION>
<?
}
?>
</select>
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.
Kullanıcının sayfayı ziyaret ettiği saate bakarak günaydın veya iyi akşamlar şeklinde mesaj veren bir script.
<SCRIPT LANGUAGE="JavaScript">
currentTime = new Date();
if (currentTime.getHours() < 12)
document.write("Günaydın");
else if (currentTime.getHours() < 17)
document.write("İyi Akşamlar");
else
document.write("İyi Geceler");
</SCRIPT>
currentTime = new Date();
if (currentTime.getHours() < 12)
document.write("Günaydın");
else if (currentTime.getHours() < 17)
document.write("İyi Akşamlar");
else
document.write("İyi Geceler");
</SCRIPT>
Sayfalarınızda kullanıcıların mouse (fare)'un sağ tuş fonksiyonlarına ulaşmasını istemiyorsanız bu scripti rahatlıkla kullanabilirsiniz.
<style>
#ie5menu { position: absolute; width: 210px; background-color: menu; font-family: Tahoma; font-size: 12px; line-height: 20px; cursor: default; visibility: hidden; border: 2px outset default }
.menuitems { padding-left: 15px; padding-right: 15px }
//-->
</style>
<script>
var display_url=0
function showmenuie5(){
ie5menu.style.left=document.body.scrollLeft+event.clientX
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
return false
}
function hidemenuie5(){
ie5menu.style.visibility="hidden"
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=''
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems")
window.location=event.srcElement.url
}
</script>
<script>
function correct(){
if (finished){
setTimeout("begin()",1000)
}
return true
}
window.onerror=correct
function begin(){
if (!document.all)
return
if (maxheight==null)
maxheight=temp.offsetHeight
whatsnew.style.height=maxheight
temp.style.display="none"
c=1
finished=true
change()
}
</script>
<!-- İSTEDİĞİNİZ LİNKLERİ AŞAĞIDAKİ BÖLÜMLERE YERLEŞTİRİNİZ.. -->
<!--[if IE]><div id="ie5menu" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5()">
<div class="menuitems" url="http://www.ipucu.web.tr">ipucu siteniz</div>
<div class="menuitems" url="http://www.adres2.com">LİNK2</div>
<div class="menuitems" url="http://www.google.com">Google</div>
<div class="menuitems" url="http://www.altavista.com">Altavista</div>
<div class="menuitems" url="http://www.hotmail.com">Hotmail</div></div>
<![endif]-->
<script>
document.oncontextmenu=showmenuie5
if (document.all&&window.print)
document.body.onclick=hidemenuie5
</script>
#ie5menu { position: absolute; width: 210px; background-color: menu; font-family: Tahoma; font-size: 12px; line-height: 20px; cursor: default; visibility: hidden; border: 2px outset default }
.menuitems { padding-left: 15px; padding-right: 15px }
//-->
</style>
<script>
var display_url=0
function showmenuie5(){
ie5menu.style.left=document.body.scrollLeft+event.clientX
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
return false
}
function hidemenuie5(){
ie5menu.style.visibility="hidden"
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if (display_url==1)
window.status=event.srcElement.url
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=''
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems")
window.location=event.srcElement.url
}
</script>
<script>
function correct(){
if (finished){
setTimeout("begin()",1000)
}
return true
}
window.onerror=correct
function begin(){
if (!document.all)
return
if (maxheight==null)
maxheight=temp.offsetHeight
whatsnew.style.height=maxheight
temp.style.display="none"
c=1
finished=true
change()
}
</script>
<!-- İSTEDİĞİNİZ LİNKLERİ AŞAĞIDAKİ BÖLÜMLERE YERLEŞTİRİNİZ.. -->
<!--[if IE]><div id="ie5menu" onMouseover="highlightie5()" onMouseout="lowlightie5()" onClick="jumptoie5()">
<div class="menuitems" url="http://www.ipucu.web.tr">ipucu siteniz</div>
<div class="menuitems" url="http://www.adres2.com">LİNK2</div>
<div class="menuitems" url="http://www.google.com">Google</div>
<div class="menuitems" url="http://www.altavista.com">Altavista</div>
<div class="menuitems" url="http://www.hotmail.com">Hotmail</div></div>
<![endif]-->
<script>
document.oncontextmenu=showmenuie5
if (document.all&&window.print)
document.body.onclick=hidemenuie5
</script>