Skip to content

Instantly share code, notes, and snippets.

View btamas86's full-sized avatar

Balku Tamás btamas86

View GitHub Profile
@btamas86
btamas86 / protectMail.php
Last active April 23, 2019 09:45
Encode email address - ASCII
<?php
function protectMail($mail, $addMailTo = true)
{
$result = '';
$mail = ($addMailTo ? 'mailto:' : '') . $mail;
for ($i = 0; $i < strlen($mail); $i++) {
$result .= '&#' . ord(substr($mail, $i, 1)) . ';';
}
@btamas86
btamas86 / exception.php
Last active June 27, 2018 08:39
Exception stack trace with long arguments.
<?php
set_exception_handler(function (Exception $exception) {
$i = 0;
foreach ($exception->getTrace() as $frame) {
echo sprintf("#%d %s(%d): %s(%s)\n",
$i++, $frame["file"], $frame["line"],
$frame["function"],
implode(", ", array_map(
function ($e) {
return var_export($e, true);
@btamas86
btamas86 / ncore.json
Last active March 14, 2018 09:22
nCore downloader
{
"rss_url": "https://ncore.cc/rss.php?key=",
"save_path": "_files",
"downloads": {
"sorozat_hun_sd": [
"Barátok Közt"
],
"sorozat_eng_sd": [
"The Flash",
"^The 100.+hdtv",
@btamas86
btamas86 / SimpleResponseMinify.php
Last active October 29, 2018 08:40
Very simple HTML response minifying - Laravel middleware
<?php
namespace App\Http\Middleware;
use Closure;
class SimpleResponseMinify
{
/**
@btamas86
btamas86 / gist:28390a2038df361d87bf38814b77252e
Created April 19, 2017 11:45
phpStorm setter method template
/**
* @param ${TYPE_HINT} $${PARAM_NAME}
*/
#if (${TYPE_HINT} == "int" || ${TYPE_HINT} == "integer" || ${TYPE_HINT} == "bool" || ${TYPE_HINT} == "boolean" || ${TYPE_HINT} == "float" || ${TYPE_HINT} == "double" || ${TYPE_HINT} == "real" || ${TYPE_HINT} == "string")
public ${STATIC} function set${NAME}($${PARAM_NAME})
#else
public ${STATIC} function set${NAME}(${TYPE_HINT} $${PARAM_NAME})
#end
{
#if (${STATIC} == "static")
@btamas86
btamas86 / ip.php
Created December 20, 2016 14:22
Client IP and Host
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
/**
* IP lekérdezése
**/
function getIp()
@btamas86
btamas86 / cinemacity-info.php
Last active November 25, 2017 14:05
CinemaCity oldalát figyelő script, ami értesít, ha az általad megadott filmre rendelhető már jegy.
<?php
/**********************************************************************************************************************
* Kilistazza a megadhato mozineveket es az eppen elerheto filmek cimeit, azonositokkal egyutt.
**********************************************************************************************************************/
$presentations = json_decode(file_get_contents('http://www.cinemacity.hu/presentationsJSON'), true);
if (!is_array($presentations) && (count($presentations) === 0 || empty($presentations['sites']) || !is_array($presentations['sites']))) {
die('Adatok beolvasasa sikertelen.');
}
@btamas86
btamas86 / pingSearchEngines.php
Created February 21, 2014 19:27
Ping search engines
<?php
function pingSearchEngines($sitemap, $service)
{
$ping = '';
switch (strtolower($service)) {
case 'google':
$ping = 'http://www.google.com/webmasters/sitemaps/ping?sitemap=[SITEMAP]';
break;
case 'bing':
var obj = {
method: 'feed',
link: SHARE_URL,
picture: SHARE_PICTURE,
name: SHARE_NAME, // Optional
caption: SHARE_CAPTION, // Optional
description: SHARE_DESCRIPTION // Optional
};
function saveData(resp) {