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.
Dizileri sıralamak
CSHARPDizileri sıralamak için Array.Sort(Array) komutu kullanılabilir.
// sorting int array
int[] intArray = new int[5] { 8, 12, 55, 28, 6 };
Array.Sort(intArray);
// writing array
foreach (int i in intArray) Console.Write(i + " ");
// output: 6 8 12 28 55
int[] intArray = new int[5] { 8, 12, 55, 28, 6 };
Array.Sort(intArray);
// writing array
foreach (int i in intArray) Console.Write(i + " ");
// output: 6 8 12 28 55
String.ToUpper() ve String.ToLower() ifadeleri kelimeleri büyük ve küçük harfe çevirme işlemi için kullanılmaktadır.
// Buyuk harfe cevirme
string site = "Kodornekleri.com";
MessageBox.Show(site.ToUpper());
// Kucuk harfe cevirme
string isim = "Kodornekleri.COM";
MessageBox.Show(isim.ToLower());
string site = "Kodornekleri.com";
MessageBox.Show(site.ToUpper());
// Kucuk harfe cevirme
string isim = "Kodornekleri.COM";
MessageBox.Show(isim.ToLower());
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.
For döngüsü
PHPFor döngüsü, belirtilen bir numaraya kadar, devam eden ifadeleri tekrarlamaktadır. For döngüsünde bir sayaç değişkeni kullanılır ve belirtilen değere kadar sayaç arttırılır ve azaltılır.
<?
for ($sayac = 1; $sayac <= 7 ; $sayac++ )
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
}
?>
for ($sayac = 1; $sayac <= 7 ; $sayac++ )
{
echo ("<font size= $sayac >");
echo ("<b><p>www.ME.com.tr</b></p>");
echo ("</font>");
}
?>
Herhangi bir dosyanın diskte kapladığı yeri öğrenmek için filesize() komutu kullanılmaktadır.
<?
echo ("Dosyanın boyutu");
echo filesize( "dene.txt" )
?>
echo ("Dosyanın boyutu");
echo filesize( "dene.txt" )
?>
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.
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>
İstenilen mesajın kayan yazı olarak statusbar'da gösterilmesini sağlayan kısa bir script.
<SCRIPT LANGUAGE="JavaScript">
var scrollCounter = 0;
var scrollText = "Mesajınızı buraya yazınız.";
var scrollDelay = 70;
var i = 0;
while (i ++ < 140)
scrollText = " " + scrollText;
function Scroller()
{
window.status = scrollText.substring(scrollCounter++,
scrollText.length);
if (scrollCounter == scrollText.length)
scrollCounter = 0;
setTimeout("Scroller()", scrollDelay);
}
Scroller();
</SCRIPT>
var scrollCounter = 0;
var scrollText = "Mesajınızı buraya yazınız.";
var scrollDelay = 70;
var i = 0;
while (i ++ < 140)
scrollText = " " + scrollText;
function Scroller()
{
window.status = scrollText.substring(scrollCounter++,
scrollText.length);
if (scrollCounter == scrollText.length)
scrollCounter = 0;
setTimeout("Scroller()", scrollDelay);
}
Scroller();
</SCRIPT>