Skip to content

Instantly share code, notes, and snippets.

View microdesign's full-sized avatar
💭
Working hard

Martin Tonev microdesign

💭
Working hard
View GitHub Profile
@microdesign
microdesign / gist:e1b8d74806fdb2f1a4c1
Last active November 12, 2015 08:46
Draw text to existing image and save it into new one - PHP
$ts = gmdate("D, d M Y H:i:s") . " GMT";
header("Expires: $ts");
header("Last-Modified: $ts");
header("Pragma: no-cache");
header("Cache-Control: no-cache, must-revalidate");
$imgPath = \URL::to( 'exiting_images/exiting.jpg' );
$save_image = 'user_images/test.jpg';
$save_to = public_path($save_image);
@microdesign
microdesign / jQueryDroppable.js
Last active September 18, 2015 12:40 — forked from seanmcn/jQueryDroppable.js
jQuery Droppable (Accept only one Draggable)
$(".drop_area").droppable({
tolerance: "intersect",
accept: ".drop_item",
greedy: true,
drop : function(event, ui) {
$(this).droppable( "option", "disabled", true );
},
out : function(event, ui) {
$(this).droppable( "option", "disabled", false );
},
<?php
/**
* Created by PhpStorm.
* User: mtonev
* Date: 10/14/15
* Time: 11:01 AM
*/
class FTP {
@microdesign
microdesign / gist:b0fcfe1badda0b7c2f69
Created November 27, 2015 10:17
PHP Server side Google Maps Geocoding
public function geocode(array $address)
{
$address = urlencode(implode(', ', $address));
$url = sprintf('https://maps.googleapis.com/maps/api/geocode/json?address=%s&key=%s', $address, 'YOUR-KEY');
$data = @file_get_contents($url);
$data = json_decode($data, true);
// If the json data is invalid, return empty array
@microdesign
microdesign / web.config
Last active January 26, 2016 15:26 — forked from jatubio/web.config
IIS web.config file for Laravel 5
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!-- Quitar los slash '/' del final de la ruta -->
<rule name="RewriteRequestsToPublic">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
@microdesign
microdesign / filter.js
Created February 26, 2016 01:10
jQuery easy lists filter
var $products = $('.list li');
$('#filter').keyup(function() {
var re = new RegExp($(this).val(), "i"); // "i" means it's case-insensitive
$products.show().filter(function() {
return !re.test($(this).text());
}).hide();
@microdesign
microdesign / example.php
Created August 15, 2016 10:53 — forked from Webcreations907/example.php
Example VC Nesting
<?php
/************************************************************************
* Example Nested For VC
* vc_map() stuff should only be included when VC is enabled.
*
* This is just for a copy/paste test purpose.
*************************************************************************/
git archive --output=test_zip.zip HEAD $(git diff --name-only HASH1 HASH2)
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$code = file_get_contents('https://ipapi.co/'.$ip.'/country/');
$bannedCountries = ['IT', 'AU', 'MY', 'HK']; //Replace with your countries
if (in_array($code, $bannedCountries)) {
die('No access');
$now = strtotime(date("Y-m-d 00:00:01"));
$nextFriday = strtotime('next friday midnight');
$difff = $nextFriday - $now;
$diff = floor($difff / (60 * 60 * 24));
$daysLeft = ($diff == 1) ? $diff.' day' : $diff.' days';
echo 'Next delivery will be on Friday, '.date('d.m.Y', $nextFriday).'. '.$daysLeft.' left till delivery.';