Skip to content

Instantly share code, notes, and snippets.

View jakubpolak's full-sized avatar

Jakub Polák jakubpolak

  • Slovakia
View GitHub Profile
@jakubpolak
jakubpolak / hosts-yt-ads
Created July 14, 2018 07:48 — forked from ewpratten/hosts-yt-ads
youtube ads hosts file
0.0.0.0 ads.doubleclick.net
0.0.0.0 s.ytimg.com
0.0.0.0 ad.youtube.com
0.0.0.0 ads.youtube.com
0.0.0.0 www.gstatic.com
0.0.0.0 gstatic.com
0.0.0.0 clients1.google.com
0.0.0.0 dts.innovid.com
0.0.0.0 googleads.g.doubleclick.net
0.0.0.0 googleads4.g.doubleclick.net
@jakubpolak
jakubpolak / approximation.php
Last active September 26, 2015 15:31
Approximation
<?php
$precision = 1;
do {
$oneMinute = bcdiv("1", "480", $precision);
$oneMD = bcmul($oneMinute, "480", $precision);
$differenceMD = bcsub("1", $oneMD, $precision);
$differenceMinutes = bcmul($differenceMD, "480", $precision);
echo "-------------------------------------------------------------------------\n"
. "1 / 480 = $oneMinute\n(1 / 480) * 480 = $oneMD\n"
. "rozdiel v MD = $differenceMD\nrozdiel v minútach = $differenceMinutes\n"
@jakubpolak
jakubpolak / ReflectionHelper.php
Last active April 3, 2016 09:06
ReflectionHelper
/**
* Class ReflectionHelper
*
* @package App\Bundle\Helper
*/
class ReflectionHelper {
/**
* Copy properties from one source object to one target object.
*
* @param Object $source source object
@jakubpolak
jakubpolak / File.php
Last active August 29, 2015 14:04
File upload in PHP.
<?php
class File {
private $validContentTypes;
private $uploadDir;
public function __construct($uploadDir = __DIR__, array $validContentTypes = ['image/png' => 'png']){
$this->uploadDir = $uploadDir;
$this->validContentTypes = $validContentTypes;
@jakubpolak
jakubpolak / gist:3951180
Last active October 12, 2015 01:37
CSS Test Page.
 <!-- Sample Content to Plugin to Template -->
<h1>CSS Basic Elements</h1>
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Headings</h1>
<h1>Heading 1</h1>
@jakubpolak
jakubpolak / has_event.js
Last active April 3, 2016 09:10
jQuery has event.
(function($) {
$.fn.hasEvent = function(A, F, E) {
var L = 0;
var T = typeof A;
var V = false;
E = E ? E : this;
A = (T == 'string') ? $.trim(A) : A;
if(T == 'function') F = A, A = null;
if(F == E) delete(F);
var S = E.data('events');
@jakubpolak
jakubpolak / number_format.js
Last active April 3, 2016 09:10
jQuery number format.
function number_format (number, decimals, dec_point, thousands_sep) {
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
s = '',
toFixedFix = function (n, prec) {
var k = Math.pow(10, prec);
return '' + Math.round(n * k) / k;