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.
Herhangi bir URL'yi veya metni saniyeler içinde .png formatında bir QR koda dönüştüren eğlenceli ve pratik bir örnek.
import qrcode
data = "https://www.kodornekleri.com"
img = qrcode.make(data)
# QR kodu kaydet
img.save("site_qr.png")
print("QR Kod başarıyla oluşturuldu.")
data = "https://www.kodornekleri.com"
img = qrcode.make(data)
# QR kodu kaydet
img.save("site_qr.png")
print("QR Kod başarıyla oluşturuldu.")
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.
QueryString ile Değer Alma
CSHARPSayfadan kullanıcının seçmiş olduğu değişkeni QueryString ile almak için kullanılan kod örneğidir.
string myidstr;
int myid;
if (Request.QueryString["x"] != null)
{
myidstr = Request.QueryString["x"];
myid = Int32.Parse(Request.QueryString["x"]);
}
else
{
return;
}
int myid;
if (Request.QueryString["x"] != null)
{
myidstr = Request.QueryString["x"];
myid = Int32.Parse(Request.QueryString["x"]);
}
else
{
return;
}
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.
If ....Else ifadesi belirtilen durumun doğru ya da yanlış olmasına göre program akışına yön vermektedir.
<?
$site = "www.ME.com.tr";
if ( $site == "www.ME.com.tr" ) {
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr");
}
elseif ($site == "www.ME.com.tr/forums") {
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr/forums");
}
else {
echo ("Şu anda ME.com sitesinde değilsiniz.");
}
?>
$site = "www.ME.com.tr";
if ( $site == "www.ME.com.tr" ) {
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr");
}
elseif ($site == "www.ME.com.tr/forums") {
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr/forums");
}
else {
echo ("Şu anda ME.com sitesinde değilsiniz.");
}
?>
Herhangi bir dosya oluşturmak için PHP'de kullanılacak komut touch()' tır. Bu fonksiyonu kullanırken oluşturulması istenilen dosyanın adının verilmesi gerekmektedir.
<?
$dizin = "/wwwroot/";
touch ("$dizin/yeni.txt");
echo ("yeni.txt dosyası oluşturuldu!");
?>
$dizin = "/wwwroot/";
touch ("$dizin/yeni.txt");
echo ("yeni.txt dosyası oluşturuldu!");
?>
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.
Sayfaya dijital bir saat eklemesi yapmak için güzel bir uygulama
<TABLE BORDER=4 BGCOLOR=CYAN>
<TR><TD>
<FORM NAME="clock_form">
<INPUT TYPE=TEXT NAME="clock" SIZE=25>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
function clockTick()
{
currentTime = new Date();
document.clock_form.clock.value = " "+currentTime;
document.clock_form.clock.blur();
setTimeout("clockTick()", 1000);
}
clockTick();
</SCRIPT>
</TD></TR>
</TABLE>
<TR><TD>
<FORM NAME="clock_form">
<INPUT TYPE=TEXT NAME="clock" SIZE=25>
</FORM>
<SCRIPT LANGUAGE="JavaScript">
function clockTick()
{
currentTime = new Date();
document.clock_form.clock.value = " "+currentTime;
document.clock_form.clock.blur();
setTimeout("clockTick()", 1000);
}
clockTick();
</SCRIPT>
</TD></TR>
</TABLE>
Sayfanızda arka planınızın sürekli değişmesini istiyorsanız bu scripti kullanabilirsiniz.
// ADIM-1 kodları body tagları arasına kopyalayınız
<script>
function MakeArray(n) {
//allow new array to be made below...
this.length = n
for (i = 0;i<n;i++)
this[i] = null
}
green = new MakeArray(10)
g = 0
a = true
green[1] = "#006000"
green[2] = "#007000"
green[3] = "#008000"
green[4] = "#009000"
green[5] = "#00A000"
green[6] = "#00B000"
green[7] = "#00C000"
green[8] = "#00D000"
green[9] = "#00E000"
green[10] = "#00F000"
function greenizer() {
if(a == true) {
g++
}
if(g==11) {
g--
a = false
}
if(g==1) {
g++
a = true
}
if(a == false) {
g--
}
document.bgColor = green[g]
setTimeout ("greenizer()",100)
}
</script>
<script>
function MakeArray(n) {
//allow new array to be made below...
this.length = n
for (i = 0;i<n;i++)
this[i] = null
}
green = new MakeArray(10)
g = 0
a = true
green[1] = "#006000"
green[2] = "#007000"
green[3] = "#008000"
green[4] = "#009000"
green[5] = "#00A000"
green[6] = "#00B000"
green[7] = "#00C000"
green[8] = "#00D000"
green[9] = "#00E000"
green[10] = "#00F000"
function greenizer() {
if(a == true) {
g++
}
if(g==11) {
g--
a = false
}
if(g==1) {
g++
a = true
}
if(a == false) {
g--
}
document.bgColor = green[g]
setTimeout ("greenizer()",100)
}
</script>