Skip to content

Instantly share code, notes, and snippets.

View bayraktugrul's full-sized avatar
🎯
Focusing

Tuğrul Bayrak bayraktugrul

🎯
Focusing
View GitHub Profile
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- JDBC Database connection settings -->
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate-yazilari?useSSL=false</property>
<property name="connection.username">root</property>
package com.hibernateyazilari.hibernate_2;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "Students")
public class Student {
@bayraktugrul
bayraktugrul / App.java
Last active September 23, 2018 12:12
Hibernate #2 - Medium (Saving object to DB example)
package com.hibernateyazilari.hibernate_2;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.internal.SessionFactoryServiceRegistryBuilderImpl;
public class App {
public static void main( String[] args ) {
SessionFactory factory = new Configuration()
@bayraktugrul
bayraktugrul / auth.js
Created April 17, 2019 12:21
express login auth jwt
login(req, res) {
if (!req.body.memail || !req.body.mpassword) {
return res.status(404).send({
message: 'Email and password can not be empty!',
});
} else {
const email = req.body.memail;
const password = crypto.createHash('md5').update(req.body.mpassword).digest("hex");
const potentialUser = {
where: {
const jwt = require('jsonwebtoken');
module.exports = (req, res, next) => {
try {
/*JWT is send with request header!
Format of it: Authorization : Bearer <token>
*/
const token = req.headers.authorization.split(" ")[1];
const decodedToken = jwt.verify(token, 'secret_key');
req.userData = decodedToken;
import java.util.Hashtable;
public abstract class Shape implements Cloneable {
private String id;
protected String type;
abstract void draw();
public String getType(){
return type;
public class SingleObject {
//SingleObject sınıfından bir nesne oluştur
private static SingleObject instance = new SingleObject();
/*constructorın access modifierını private olarak tanımlayalım ki bu sınıftan nesne oluşturulamasın*/
private SingleObject(){}
//Oluşturduğumuz nesneye erişim için getter
public static SingleObject getInstance(){
class LinearSearch {
public static int search(int arr[], int x) {
int n = arr.length;
for(int i = 0; i < n; i++) {
if(arr[i] == x)
return i;
}
return -1;
}
class BinarySearch {
int binarySearch(int arr[], int x) {
int l = 0, r = arr.length - 1;
while (l <= r) {
int m = l + (r - l) / 2;
//x değeri ortanca değer mi kontrol et
if (arr[m] == x)
return m;
@bayraktugrul
bayraktugrul / Person.java
Created July 6, 2019 14:11
class without builder pattern
public class Person {
private String name, surname, address;
public Person(String name, String surname, String address) {
this.name = name;
this.surname = surname;
this.address = address;
}
// Getter & setter metodları