Skip to content

Instantly share code, notes, and snippets.

View taner-dll's full-sized avatar
🏠
Working from home

Taner Deliloglu taner-dll

🏠
Working from home
View GitHub Profile
@taner-dll
taner-dll / upload.php
Last active December 16, 2019 03:06
Symfony 2 - Basic Image Upload
$file = $_FILES['fileinput'];
$this->SF2imageUpload($file['name'],$file['type'],$file['size'],$file['error'],$file['tmp_name'],$upload_directory);
public function SF2imageUpload($file, $file_type, $file_size, $file_error, $temp, $upload_url)
{
//Kabul edilen uzantılar.
$allowed_extensions = array("gif", "jpeg", "jpg", "png");
@taner-dll
taner-dll / check.java
Last active December 16, 2019 03:06
Android - Check Internet Connection
package com.animacoder.akcaykentportali;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Toast;
@taner-dll
taner-dll / query.php
Last active December 16, 2019 03:07
Symfony 2 - Query Builder Order By Rand
$sorular = $em->createQueryBuilder()
->select('s')
->from('PauSemYonetimBundle:Sorular', 's')
->where('s.testler = :test')
->setParameter('test',$test)
->getQuery()
->getResult();
//sorularin dizideki sıralamasını değiştir
@taner-dll
taner-dll / transaction.php
Last active December 16, 2019 03:02 — forked from datacow-com/transaction.php
Symfony 2 - Transaction
<?php
// Snippet for Symfony 2 application that uses Doctrine 2 to handle transactions
// It uses the names of the objects/doctrine repositories from the Beta 4 Manual of Symfony 2.
// Get the entity manager
$em = $this->getDoctrine()->getEntityManager();
// suspend auto-commit
$em->getConnection()->beginTransaction();
@taner-dll
taner-dll / symfony_validate_date.php
Last active December 16, 2019 03:09
Symfony 2 - Validate Date
<?php
private function validateDate($date, $format = 'd-m-Y')
{
$d = \DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
if ($this->validateDate($dueDate) == true) {
$todo->setDueDate(\DateTime::createFromFormat('d-m-Y', $dueDate));
}
@taner-dll
taner-dll / check_valid_email.php
Last active November 12, 2020 13:18
PHP - Check Valid Email #php #email #validation
<?php
// check for valid email address
$email = $_POST['remail'];
$pattern = '/^[^@]+@[^srn'";,@%]+$/';
if (!preg_match($pattern, trim($email))) {
$error[] = 'Please enter a valid email address';
}
@taner-dll
taner-dll / gist:6669387031436bdd0e1b1fa612aaff70
Last active September 13, 2020 04:54
Symfony / Javascript - Left Menu / Treeview Active
import $ from "jquery";
/**
* Left Menu - Active Dynamically
*/
let current_route = $('#current_route').val();
let active = {'font-weight': 'bold'};
//console.log(current_route);
/**