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
./ngrok http -host-header=rewrite myname.test:80
$.fn.form = function() {
var formData = {};
this.find('[name]').each(function() {
formData[this.name] = this.value;
})
return formData;
};
var formData = $('#form').form();
$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.';
<?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');
git archive --output=test_zip.zip HEAD $(git diff --name-only HASH1 HASH2)
@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.
*************************************************************************/
@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 / 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 / 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
<?php
/**
* Created by PhpStorm.
* User: mtonev
* Date: 10/14/15
* Time: 11:01 AM
*/
class FTP {