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.
Büyük veri setleri içerisinde belirli kriterlere göre filtreleme yapmayı ve istatistiksel özet almayı sağlayan profesyonel veri analizi örneği.
import pandas as pd
# Veri setini yükle
df = pd.read_csv('satislar.csv')
# Filtreleme: Satışı 5000'den büyük olan ve Ankara şubesi verileri
filtre = df[(df['Satis'] > 5000) & (df['Sehir'] == 'Ankara')]
# Genel istatistiksel özet
print(filtre.describe())
# Gruplandırarak toplam alma
print(df.groupby('Kategori')['Satis'].sum())
# Veri setini yükle
df = pd.read_csv('satislar.csv')
# Filtreleme: Satışı 5000'den büyük olan ve Ankara şubesi verileri
filtre = df[(df['Satis'] > 5000) & (df['Sehir'] == 'Ankara')]
# Genel istatistiksel özet
print(filtre.describe())
# Gruplandırarak toplam alma
print(df.groupby('Kategori')['Satis'].sum())
Haar Cascade sınıflandırıcılarını kullanarak bir fotoğraf üzerindeki insan yüzlerini tespit eden ve çerçeve içine alan görüntü işleme örneği.
import cv2
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
img = cv2.imread("insanlar.jpg")
gri = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
yuzler = face_cascade.detectMultiScale(gri, 1.1, 4)
for (x, y, w, h) in yuzler:
cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)
cv2.imshow('Yuz Tespiti', img)
cv2.waitKey()
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
img = cv2.imread("insanlar.jpg")
gri = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
yuzler = face_cascade.detectMultiScale(gri, 1.1, 4)
for (x, y, w, h) in yuzler:
cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)
cv2.imshow('Yuz Tespiti', img)
cv2.waitKey()
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.
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);
String Replace İşlemi
CSHARPString içindeki ifadelerin değiştirilmesi için String.Replace ifadesi kullanılmaktadır.
string mystr = "www.kodornekleri.com";
string newstr = mystr.Replace("com", "COM");
MessageBox.Show(newstr, "C# String Replace", MessageBoxButtons.OK, MessageBoxIcon.Information);
string newstr = mystr.Replace("com", "COM");
MessageBox.Show(newstr, "C# String Replace", MessageBoxButtons.OK, MessageBoxIcon.Information);
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.
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!");
?>
While döngüsü döngüye girilmeden önce şartın sağlanıp sağlanmadığını kontrol ettikten sonra işlemleri yapmaktadır. İşlemler ilk kez yapıldıktan sonra şartın sağlanıp sağlanmaması isteniyorsa bu durumda do..while döngüsü kullanılır.
<?
$sayac=1;
Do
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
sayac++;
}
while ($sayac <= 7) ;
?>
$sayac=1;
Do
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
sayac++;
}
while ($sayac <= 7) ;
?>
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.
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>
Sitenizde Yıl, Ay, Gün takvim görüntülemek için. (Tablo Şeklinde)
<!--ADIM 1 : Aşağıdaki scripti takvim.js olarak kaydedin -->
<!-- Başlangıç
// Dizi Oluştur
var day_of_week = new Array('Paz','Pzt','Salı','Çar','Per','Cu','Cts');
var month_of_year = new Array('Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık');
// Değişkenleri Tanımlama
var Calendar = new Date();
var year = Calendar.getYear();
var month = Calendar.getMonth();
var today = Calendar.getDate();
var weekday = Calendar.getDay();
var DAYS_OF_WEEK = 7;
var DAYS_OF_MONTH = 31;
var cal;
Calendar.setDate(1);
Calendar.setMonth(month);
/* Format değişkenleri
NOT: Görünümü değiştirmek için 'BORDER', 'BGCOLOR', 'CELLPADDING', 'BORDERCOLOR'
taglarını değiştirebilirsiniz. */
var TR_start = '<TR>';
var TR_end = '</TR>';
var highlight_start = '<TD WIDTH="30"><TABLE CELLSPACING=0 BORDER=1 BGCOLOR=DEDEFF BORDERCOLOR=CCCCCC><TR><TD WIDTH=20><B><CENTER>';
var highlight_end = '</CENTER></TD></TR></TABLE></B>';
var TD_start = '<TD WIDTH="30"><CENTER>';
var TD_end = '</CENTER></TD>';
cal = '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR=BBBBBB><TR><TD>';
cal += '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2>' + TR_start;
cal += '<TD COLSPAN="' + DAYS_OF_WEEK + '" BGCOLOR="#EFEFEF"><CENTER><B>';
cal += month_of_year[month] + ' ' + year + '</B>' + TD_end + TR_end;
cal += TR_start;
// BURADAN AŞAĞIYI DEĞİŞTİRMEYİNİZ //
for(index=0; index < DAYS_OF_WEEK; index++)
{
if(weekday == index)
cal += TD_start + '<B>' + day_of_week[index] + '</B>' + TD_end;
else
cal += TD_start + day_of_week[index] + TD_end;
}
cal += TD_end + TR_end;
cal += TR_start;
for(index=0; index < Calendar.getDay(); index++)
cal += TD_start + ' ' + TD_end;
for(index=0; index < DAYS_OF_MONTH; index++)
{
if( Calendar.getDate() > index )
{
week_day =Calendar.getDay();
if(week_day == 0)
cal += TR_start;
if(week_day != DAYS_OF_WEEK)
{
var day = Calendar.getDate();
if( today==Calendar.getDate() )
cal += highlight_start + day + highlight_end + TD_end;
else
cal += TD_start + day + TD_end;
}
if(week_day == DAYS_OF_WEEK)
cal += TR_end;
}
Calendar.setDate(Calendar.getDate()+1);
}// end for loop
cal += '</TD></TR></TABLE></TABLE>';
// TAKVIMI YAZDIR
document.write(cal);
// Son -->
<!-- ADIM 2: Aşağıdaki kodu sayfanızda takvimin görüntülenmesini istediğiniz yere kopyalayın -->
<BODY>
<SCRIPT SRC="takvim.js"></SCRIPT>
<!-- Başlangıç
// Dizi Oluştur
var day_of_week = new Array('Paz','Pzt','Salı','Çar','Per','Cu','Cts');
var month_of_year = new Array('Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık');
// Değişkenleri Tanımlama
var Calendar = new Date();
var year = Calendar.getYear();
var month = Calendar.getMonth();
var today = Calendar.getDate();
var weekday = Calendar.getDay();
var DAYS_OF_WEEK = 7;
var DAYS_OF_MONTH = 31;
var cal;
Calendar.setDate(1);
Calendar.setMonth(month);
/* Format değişkenleri
NOT: Görünümü değiştirmek için 'BORDER', 'BGCOLOR', 'CELLPADDING', 'BORDERCOLOR'
taglarını değiştirebilirsiniz. */
var TR_start = '<TR>';
var TR_end = '</TR>';
var highlight_start = '<TD WIDTH="30"><TABLE CELLSPACING=0 BORDER=1 BGCOLOR=DEDEFF BORDERCOLOR=CCCCCC><TR><TD WIDTH=20><B><CENTER>';
var highlight_end = '</CENTER></TD></TR></TABLE></B>';
var TD_start = '<TD WIDTH="30"><CENTER>';
var TD_end = '</CENTER></TD>';
cal = '<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR=BBBBBB><TR><TD>';
cal += '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2>' + TR_start;
cal += '<TD COLSPAN="' + DAYS_OF_WEEK + '" BGCOLOR="#EFEFEF"><CENTER><B>';
cal += month_of_year[month] + ' ' + year + '</B>' + TD_end + TR_end;
cal += TR_start;
// BURADAN AŞAĞIYI DEĞİŞTİRMEYİNİZ //
for(index=0; index < DAYS_OF_WEEK; index++)
{
if(weekday == index)
cal += TD_start + '<B>' + day_of_week[index] + '</B>' + TD_end;
else
cal += TD_start + day_of_week[index] + TD_end;
}
cal += TD_end + TR_end;
cal += TR_start;
for(index=0; index < Calendar.getDay(); index++)
cal += TD_start + ' ' + TD_end;
for(index=0; index < DAYS_OF_MONTH; index++)
{
if( Calendar.getDate() > index )
{
week_day =Calendar.getDay();
if(week_day == 0)
cal += TR_start;
if(week_day != DAYS_OF_WEEK)
{
var day = Calendar.getDate();
if( today==Calendar.getDate() )
cal += highlight_start + day + highlight_end + TD_end;
else
cal += TD_start + day + TD_end;
}
if(week_day == DAYS_OF_WEEK)
cal += TR_end;
}
Calendar.setDate(Calendar.getDate()+1);
}// end for loop
cal += '</TD></TR></TABLE></TABLE>';
// TAKVIMI YAZDIR
document.write(cal);
// Son -->
<!-- ADIM 2: Aşağıdaki kodu sayfanızda takvimin görüntülenmesini istediğiniz yere kopyalayın -->
<BODY>
<SCRIPT SRC="takvim.js"></SCRIPT>