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.
Belirli bir IP adresindeki portların açık olup olmadığını kontrol eden güvenlik aracı.
import socket
target = "127.0.0.1"
port = 80
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if s.connect_ex((target, port)) == 0:
print(f"Port {port} açık!")
s.close()
target = "127.0.0.1"
port = 80
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if s.connect_ex((target, port)) == 0:
print(f"Port {port} açık!")
s.close()
Hiçbir kütüphane kurmadan, sadece Python yerleşik modülleriyle yerel bir ağ üzerinde dosya paylaşımı için sunucu başlatma kodu.
import http.server
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Sunucu {PORT} portunda çalışıyor...")
httpd.serve_forever()
import socketserver
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Sunucu {PORT} portunda çalışıyor...")
httpd.serve_forever()
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
Mükemmel Sayılar
CSHARPKendisi hariç bütün pozitif çarpanları (tam bölenleri) toplamı, yine kendisine eşit olan sayılara ?mükemmel sayı? denir.
Örneğin 6=1+2+3 ve 28=1+2+4+7+14 gibi.
int sayi;
double bolumtopla = 0;
Console.Write("Bir sayı giriniz: ");
sayi = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <sayi; i++)
{
if (sayi % i == 0)
{
bolumtopla += i;
}
}
double bolumtopla = 0;
Console.Write("Bir sayı giriniz: ");
sayi = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <sayi; i++)
{
if (sayi % i == 0)
{
bolumtopla += i;
}
}
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.
Bir durumu bakarak karar vermeyi sağlar. Çeşiştli alternatiflerden seçim yapmak için kullanılır.
<?
$site = "www.ME.com.tr";
Switch $site {
Case "www.ME.com.tr";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr");
Case "www.ME.com.tr/forums";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr/forums");
default;
echo ("Şu anda ME.com sitesinde değilsiniz.");
}
?>
$site = "www.ME.com.tr";
Switch $site {
Case "www.ME.com.tr";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr");
Case "www.ME.com.tr/forums";
echo ("Şu anda bulunduğunuz sitenin adresi: www.ME.com.tr/forums");
default;
echo ("Şu anda ME.com sitesinde değilsiniz.");
}
?>
Herhangi bir dizinin eleman sayısının bulunmasını sağlar.
<?
$dizi = array("kırmızı", "yeşil", "mavi");
echo "Dizide" . sizeof($data) . " adet eleman vardır.";
?>
$dizi = array("kırmızı", "yeşil", "mavi");
echo "Dizide" . sizeof($data) . " adet eleman vardır.";
?>
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 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>
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>