Skip to content

Instantly share code, notes, and snippets.

@mcihad
mcihad / go-ilk.go
Last active August 29, 2015 14:03
Go dili ilk deneme sum,avg, min,max
package main
import "fmt"
func sum(vals []int) (r int) {
for _, val := range vals {
r += val
}
return
}
@mcihad
mcihad / prime.rb
Last active August 29, 2015 14:04
Ruby asal sayı
#require "prime" diyerek standart prime modulünüde kullanabilirsiniz
class Fixnum
def prime?
2.upto((self-(self % 2))/2) do |i|
if self % i==0
return false
end
end
return true
end
@mcihad
mcihad / py-deco.py
Last active August 29, 2015 14:04
Decorator Python
"""
django view içerisinde kullanmak için
f fonksiyonu ilk parametresi request
kullanıcının applikasyon yetkisi kontrol edilebilir
"""
from functools import wraps
def apps_required(appname):
@mcihad
mcihad / test.php
Last active October 22, 2019 18:10
PHP MVC Basit Url Yönlendirmesi ve Action Çalıştırma, Simple MVC implementation , Url Routing and action execution
<?php
class Controller {
protected $data=array();
public function set($name,$value) {
$this->data[$name]=$value;
}
public function get($name) {
@mcihad
mcihad / .htaccess
Created September 15, 2014 19:23
test.php konfigurasyon dosyası
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
if __name__=="__main__":
print("Selam")
def singleton(class_):
instances = {}
def getinstance(*args, **kwargs):
if class_ not in instances:
instances[class_] = class_(*args, **kwargs)
return instances[class_]
return getinstance
@singleton
class MyClass(BaseClass):
@mcihad
mcihad / web.xml
Created May 2, 2017 07:05
web.xml java server faces
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
@mcihad
mcihad / web.xml
Created May 2, 2017 07:06
spring web.xml
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
@mcihad
mcihad / faces-config.xml
Created May 2, 2017 07:07
Faces Config spring
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver