Skip to content

Instantly share code, notes, and snippets.

View emresaracoglu's full-sized avatar
:atom:
"Every software system is flawed... Every coder is corrupt"

Emre Saraçoğlu emresaracoglu

:atom:
"Every software system is flawed... Every coder is corrupt"
View GitHub Profile
@emresaracoglu
emresaracoglu / backup_mysql.sh
Created August 13, 2016 11:57 — forked from servergrove/backup_mysql.sh
Script to backup MySQL
# Configuration.
date=`date +%Y-%m-%d`
bk_dest='/var/archives/mysql'
log_file=$bk_dest/bk_mysql-${date}.log
mysql_cmd='/usr/bin/mysql'
mysqldump_cmd='/usr/bin/mysqldump'
dbuser=root
dbpass=`cat /etc/.mysqlpasswd`
@emresaracoglu
emresaracoglu / db-connect-test.php
Created September 9, 2016 10:45 — forked from chales/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
@emresaracoglu
emresaracoglu / CronSchedule.php
Created September 13, 2016 19:25 — forked from m4tthumphrey/CronSchedule.php
CronSchedule.php - Allows one to parse a cron expression into human readable text.
<?php
/*
* Plugin: StreamlineFoundation
*
* Class: Schedule
*
* Description: Provides scheduling mechanics including creating a schedule, testing if a specific moment is part of the schedule, moving back
* and forth between scheduled moments in time and translating the created schedule back to a human readable form.
*
* Usage: ::fromCronString() creates a new Schedule class and requires a string in the cron ('* * * * *', $language) format.
@emresaracoglu
emresaracoglu / FlxZipArchive.class.php
Created September 20, 2016 11:00 — forked from stajnert/FlxZipArchive.class.php
Extended ZipArchive - simply way to create zip with subdirectories
<?php
class FlxZipArchive extends ZipArchive
{
/**
* Add a Dir with Files and Subdirs to the archive
*
* @param string $location Real Location
* @param string $name Name in Archive
@emresaracoglu
emresaracoglu / browser.html
Created September 20, 2016 11:00 — forked from stajnert/browser.html
Javascript to find browser version, os version and os bit version
<html>
<body>
<script type="text/javascript">
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
@emresaracoglu
emresaracoglu / php-ping.php
Created October 7, 2016 09:46 — forked from k0nsl/php-ping.php
PHP ping script
<?php
/*
*
* Use the examples below to add your own servers. Coded by clone1018 [?]
*
*/
$title = "Simple Server Status"; // website's title
$servers = array(
'Google Web Search' => array(
@emresaracoglu
emresaracoglu / download.php
Created May 4, 2017 09:21 — forked from brasofilo/download.php
Force File Download with PHP
<?php
/*
* Foce File Download
* Usage: http://example.com/download.php?file=./uploads/image.jpg
*
* There are a couple of *ninja* exit() as security guarantee, adapt as necessary
*
*/
// grab the requested file's name
@emresaracoglu
emresaracoglu / Autoloader.php
Created May 8, 2017 23:17 — forked from Nilpo/Autoloader.php
A simple recursive PHP autoloader using the RecursiveDirectoryIterator.
<?php
/*
* The MIT License (MIT)
*
* Copyright (c) 2014 Rob Dunham
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
@emresaracoglu
emresaracoglu / gist:35e0181b42aadd118862ee253fa69343
Created May 9, 2017 10:44 — forked from erikjung/gist:3079806
PHP 5.4 Namespace-based Autoloader
<?php
// Probably unnecessary, but wanted to test the waters of 5.4
trait NamespaceConverter
{
function nsToPath($class) {
return str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
}
}
@emresaracoglu
emresaracoglu / db-connect-test.php
Created December 2, 2017 08:08 — forked from M165437/db-connect-test.php
Script for a quick PHP MySQL DB connection test.
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'name';
$dbuser = 'user';
$dbpass = 'pass';
$dbhost = 'host';
$link = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");