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.
Bilgisayarlı görü (Computer Vision) projelerinde sık kullanılan, bir görseli gri tonlamaya çevirip kenar tespiti (Canny Edge Detection) yapan örnek.
import cv2
# Resmi oku
resim = cv2.imread('input.jpg')
# Gri tona çevir
gri_resim = cv2.cvtColor(resim, cv2.COLOR_BGR2GRAY)
# Kenarları tespit et
kenarlar = cv2.Canny(gri_resim, 100, 200)
# Sonucu kaydet
cv2.imwrite('kenar_tespiti.jpg', kenarlar)
print("Görüntü işlendi ve kaydedildi.")
# Resmi oku
resim = cv2.imread('input.jpg')
# Gri tona çevir
gri_resim = cv2.cvtColor(resim, cv2.COLOR_BGR2GRAY)
# Kenarları tespit et
kenarlar = cv2.Canny(gri_resim, 100, 200)
# Sonucu kaydet
cv2.imwrite('kenar_tespiti.jpg', kenarlar)
print("Görüntü işlendi ve kaydedildi.")
K-Means ile Veri Kümeleme
PYTHONMakine öğrenmesi kullanarak benzer verileri gruplara ayıran algoritma örneği.
from sklearn.cluster import KMeans
import numpy as np
X = np.array([[1, 2], [1, 4], [10, 2], [10, 4]])
kmeans = KMeans(n_clusters=2).fit(X)
print(kmeans.labels_)
import numpy as np
X = np.array([[1, 2], [1, 4], [10, 2], [10, 4]])
kmeans = KMeans(n_clusters=2).fit(X)
print(kmeans.labels_)
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.
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);
Faktöriyel Hesabı
CSHARPTextboxt'tan girilen sayının faktöriyelini hesaplayıp sonucu gösteren bir kod örneği
int toplam = 1;
int girilenSayi = int.Parse(textBox1.Text);
for (int i = 1; i < girilenSayi ; i++)
{
toplam += toplam*i;
}
MessageBox.Show(toplam.ToString());
int girilenSayi = int.Parse(textBox1.Text);
for (int i = 1; i < girilenSayi ; i++)
{
toplam += toplam*i;
}
MessageBox.Show(toplam.ToString());
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.
Ziyaretçinin sorduğu sorunun cevabını anında almasını istiyorsanız, bu scripti deneyin. Sayfa refresh edilmeden soruların cevaplarını görmek mümkün olmaktadır.
// ……………………………………………………………….
// ..1.. <HEAD></HEAD> Tagları arasına eklenecek bölüm
// ……………………………………………………………….
<SCRIPT LANGUAGE="JavaScript">
function showFAQ(form) {
form.cevap.value = form.question.options[form.question.selectedIndex].value;
}
</SCRIPT>
// ……………………………………………………………….
// ..2.. <BODY></BODY> Tagları arasına eklenecek bölüm
// ……………………………………………………………….
<form name=faqform>
<table border=1 cellspacing=0 cellpadding=5>
<tr bgcolor="#BEA78B">
<td align=center><font face="verdana,arial" size="-1" color="#000000">
<b>Soru Cevap Örnek Form</b></font></td>
</tr>
<tr bgcolor="#E8E4D0"><td><font face="verdana,arial" size="-1"><br>
<center> Soruların üzerine tıklayarak yanıtlarını görebilirsiniz.</center>
<p>
<ul><select size=10 name=question onChange="javascript:showFAQ(this.form);">
<option value="......CEVAPLARI BURAYI YAZINIZ......"> --> ......SORULARI BURAYA YAZINIZ......
<option value="www.ipucu.web.tr"> --> Şu anda hangi sayfadayız?
<option value="cevap 2"> --> Soru 2
<option value="Cevap 3"> --> Soru 3
<option value="Cevap 4"> --> Soru 4
</select>
</ul>
<p align="center">
Yanıtlar:
<p>
<ul>
<textarea name="cevap" rows=15 cols=50 wrap=virtual>
// ..1.. <HEAD></HEAD> Tagları arasına eklenecek bölüm
// ……………………………………………………………….
<SCRIPT LANGUAGE="JavaScript">
function showFAQ(form) {
form.cevap.value = form.question.options[form.question.selectedIndex].value;
}
</SCRIPT>
// ……………………………………………………………….
// ..2.. <BODY></BODY> Tagları arasına eklenecek bölüm
// ……………………………………………………………….
<form name=faqform>
<table border=1 cellspacing=0 cellpadding=5>
<tr bgcolor="#BEA78B">
<td align=center><font face="verdana,arial" size="-1" color="#000000">
<b>Soru Cevap Örnek Form</b></font></td>
</tr>
<tr bgcolor="#E8E4D0"><td><font face="verdana,arial" size="-1"><br>
<center> Soruların üzerine tıklayarak yanıtlarını görebilirsiniz.</center>
<p>
<ul><select size=10 name=question onChange="javascript:showFAQ(this.form);">
<option value="......CEVAPLARI BURAYI YAZINIZ......"> --> ......SORULARI BURAYA YAZINIZ......
<option value="www.ipucu.web.tr"> --> Şu anda hangi sayfadayız?
<option value="cevap 2"> --> Soru 2
<option value="Cevap 3"> --> Soru 3
<option value="Cevap 4"> --> Soru 4
</select>
</ul>
<p align="center">
Yanıtlar:
<p>
<ul>
<textarea name="cevap" rows=15 cols=50 wrap=virtual>
Sayfanın sol tarafında duran ve mouse ile tıklandığında kayarak açılan bir menü örneği
// *****************************************************************
// <BODY> Bölümleri arasına eklenecek olan bölüm
// *****************************************************************
<style>
TD{font-family:arial,helvetica; font-size:10pt}
BODY{background-color:white}
A{color:Navy; text-decoration:none}
A:hover{color:red}
A:visited:{color:#808080}
DIV{font-family:arial,helvetica; font-size:12pt; font-weight:bold}
</style><!-- -->
<script>
/*
Copyright (C) 1999 Thomas Brattli
This script is made by and copyrighted to Thomas Brattli at www.bratta.com
Visit for more great scripts.
This may be used freely as long as this msg is intact!
*********************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0
//How much of the layer do you wan't to be visible when it's in the out state?
lshow=60
//How many pixels should it move every step?
var move=10;
//At what speed (in milliseconds, lower value is more speed)
menuSpeed=40
//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=true
//Defining variables
var tim;
var ltop;
//Object constructor
function makeMenu(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
this.state=1
this.go=0
this.width=n?this.css.document.width:eval(obj+'.offsetWidth')
this.left=b_getleft
this.obj = obj + "Object"; eval(this.obj + "=this")
}
//Get's the top position.
function b_getleft(){
var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);
return gleft;
}
/*
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
*/
function moveMenu(){
if(!oMenu.state){
clearTimeout(tim)
mIn()
}else{
clearTimeout(tim)
mOut()
}
}
//Menu in
function mIn(){
if(oMenu.left()>-oMenu.width+lshow){
oMenu.go=1
oMenu.css.left=oMenu.left()-move
tim=setTimeout("mIn()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=1
}
}
//Menu out
function mOut(){
if(oMenu.left()<0){
oMenu.go=1
oMenu.css.left=oMenu.left()+move
tim=setTimeout("mOut()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=0
}
}
/*
Checking if the page is scrolled, if it is move the menu after
*/
function checkScrolled(){
if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
if(n) setTimeout('checkScrolled()',30)
}
/*
Inits the page, makes the menu object, moves it to the right place,
show it
*/
function menuInit(){
oMenu=new makeMenu('divMenu')
scrolled=n?"window.pageYOffset":"document.body.scrollTop"
oMenu.css.left=-oMenu.width+lshow
ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;
oMenu.css.visibility='visible'
if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}
//Initing menu on pageload
onload=menuInit;
</script>
<!-- Bu bölümde menünün linklerini ayarlayabilirsiniz.-->
<!--A1 --><div id="divMenu" style="position:absolute; top:300; left:30; height:100; width:540; visibility:hidden">
<a href="http://www.ipucu.web.tr/jsipucu.php" ONMOUSEOVER="window.status='Site Navigation Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">Javascript ipucu</a> -
<a href="http://www.ipucu.web.tr/phpipucu.php" ONMOUSEOVER="window.status='Page Effect Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">PHP ipucu</a> -
<a href="http://www.ipucu.web.tr/aspipucu.php" ONMOUSEOVER="window.status='MouseOver Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">ASP ipucu</a> -
<a href="http://www.ipucu.web.tr/" ONMOUSEOVER="window.status='User Information Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">Yeni ipucu siteniz</a> -
<a href="http://www.ipucu.web.tr/jsipucu.php" onclick="moveMenu(); window.focus()" ONMOUSEOVER="window.status='Click For Menu';return true;" ONMOUSEOUT="window.status='';return true;">MENU</a>
</div><!-- -->
// <BODY> Bölümleri arasına eklenecek olan bölüm
// *****************************************************************
<style>
TD{font-family:arial,helvetica; font-size:10pt}
BODY{background-color:white}
A{color:Navy; text-decoration:none}
A:hover{color:red}
A:visited:{color:#808080}
DIV{font-family:arial,helvetica; font-size:12pt; font-weight:bold}
</style><!-- -->
<script>
/*
Copyright (C) 1999 Thomas Brattli
This script is made by and copyrighted to Thomas Brattli at www.bratta.com
Visit for more great scripts.
This may be used freely as long as this msg is intact!
*********************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0
//How much of the layer do you wan't to be visible when it's in the out state?
lshow=60
//How many pixels should it move every step?
var move=10;
//At what speed (in milliseconds, lower value is more speed)
menuSpeed=40
//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=true
//Defining variables
var tim;
var ltop;
//Object constructor
function makeMenu(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
this.state=1
this.go=0
this.width=n?this.css.document.width:eval(obj+'.offsetWidth')
this.left=b_getleft
this.obj = obj + "Object"; eval(this.obj + "=this")
}
//Get's the top position.
function b_getleft(){
var gleft=(n) ? eval(this.css.left):eval(this.css.pixelLeft);
return gleft;
}
/*
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
*/
function moveMenu(){
if(!oMenu.state){
clearTimeout(tim)
mIn()
}else{
clearTimeout(tim)
mOut()
}
}
//Menu in
function mIn(){
if(oMenu.left()>-oMenu.width+lshow){
oMenu.go=1
oMenu.css.left=oMenu.left()-move
tim=setTimeout("mIn()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=1
}
}
//Menu out
function mOut(){
if(oMenu.left()<0){
oMenu.go=1
oMenu.css.left=oMenu.left()+move
tim=setTimeout("mOut()",menuSpeed)
}else{
oMenu.go=0
oMenu.state=0
}
}
/*
Checking if the page is scrolled, if it is move the menu after
*/
function checkScrolled(){
if(!oMenu.go) oMenu.css.top=eval(scrolled)+ltop
if(n) setTimeout('checkScrolled()',30)
}
/*
Inits the page, makes the menu object, moves it to the right place,
show it
*/
function menuInit(){
oMenu=new makeMenu('divMenu')
scrolled=n?"window.pageYOffset":"document.body.scrollTop"
oMenu.css.left=-oMenu.width+lshow
ltop=(n)?oMenu.css.top:oMenu.css.pixelTop;
oMenu.css.visibility='visible'
if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}
//Initing menu on pageload
onload=menuInit;
</script>
<!-- Bu bölümde menünün linklerini ayarlayabilirsiniz.-->
<!--A1 --><div id="divMenu" style="position:absolute; top:300; left:30; height:100; width:540; visibility:hidden">
<a href="http://www.ipucu.web.tr/jsipucu.php" ONMOUSEOVER="window.status='Site Navigation Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">Javascript ipucu</a> -
<a href="http://www.ipucu.web.tr/phpipucu.php" ONMOUSEOVER="window.status='Page Effect Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">PHP ipucu</a> -
<a href="http://www.ipucu.web.tr/aspipucu.php" ONMOUSEOVER="window.status='MouseOver Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">ASP ipucu</a> -
<a href="http://www.ipucu.web.tr/" ONMOUSEOVER="window.status='User Information Scripts';return true;" ONMOUSEOUT="window.status='';return true;" onclick="window.focus()">Yeni ipucu siteniz</a> -
<a href="http://www.ipucu.web.tr/jsipucu.php" onclick="moveMenu(); window.focus()" ONMOUSEOVER="window.status='Click For Menu';return true;" ONMOUSEOUT="window.status='';return true;">MENU</a>
</div><!-- -->