Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Konrad fedek6

🎯
Focusing
View GitHub Profile
@fedek6
fedek6 / phpinfo.php
Created Sep 28, 2015
phpinfo() only for local requests
View phpinfo.php
<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if ( ! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) )
{
@fedek6
fedek6 / .php
Created Sep 28, 2015
Generate data tags for http://jquerypicture.com/ usable in Wordpress
View .php
<?php
/**
* Responsive bg data
*
* @see http://jquerypicture.com/
*/
function generate_reponsive_bg() {
global $post, $_wp_additional_image_sizes;
@fedek6
fedek6 / media-queries.scss
Created Nov 15, 2015
Media queries for Pure
View media-queries.scss
/**
* Media queries
*/
// this means upper than smallest screens...
// >=568px sm
@media screen and (min-width: 35.5em) {
@import "sm.less";
}
@fedek6
fedek6 / readable_time.php
Created Dec 8, 2015
Convert datetime to human readable representation (polish version).
View readable_time.php
<?php
/**
* Convert datetime to human readable representation.
* Polish version.
*
* @link http://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago
*/
function time_elapsed_string_pl($datetime, $full = false) {
$now = new DateTime;
$ago = new DateTime($datetime);
@fedek6
fedek6 / Gruntfile.js
Created Jun 1, 2016
Gruntfile for Wordpress theme
View Gruntfile.js
/**
* Realhe.ro Gruntfile for Wordpress
*
* @version 1.0
*/
module.exports = function(grunt) {
grunt.initConfig( {
// Prepare banner
pkg : grunt.file.readJSON('package.json'),
banner : '/*! <%= pkg.name %> - v<%= pkg.version %> ' +
@fedek6
fedek6 / List.js
Created Feb 28, 2017
Vtiger 6.5 mass edit limit change
View List.js
var selectedCount = this.getSelectedRecordCount();
if(selectedCount > 2000) {
var params = {
title : app.vtranslate('JS_MESSAGE'),
text: app.vtranslate('JS_MASS_EDIT_LIMIT'),
animation: 'show',
type: 'error'
};
Vtiger_Helper_Js.showPnotify(params);
return;
@fedek6
fedek6 / web.config
Created Mar 15, 2017
Protect Wordpress on MS IIS, say hello to Turkish hackers :)
View web.config
<rules>
<clear />
<rule name="Protect WP" stopProcessing="true">
<match url="(readme.html)|(xmlrpc.php)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="https://youtu.be/Ww0k-80n-zI" />
</rule>
</rules>
@fedek6
fedek6 / gist:f3dfa011f01c1addce38bb9ecd10dda2
Created Apr 10, 2017
Get all PostgreSQL databases and their sizes
View gist:f3dfa011f01c1addce38bb9ecd10dda2
psql -c "SELECT pg_database.datname, pg_database_size(pg_database.datname), pg_size_pretty(pg_database_size(pg_database.datname)) FROM pg_database ORDER BY pg_database_size DESC;" -d <db_name> <db_user>
@fedek6
fedek6 / benchmark.php
Last active Jun 8, 2017
Benchmark method taken from Instant Share app
View benchmark.php
<?php
/**
* Benchmark
*
* @category debug
*/
public function benchmark() {
/** @var integer $timeStart **/
$timeStart = microtime(true);
@fedek6
fedek6 / dummy_download.php
Created Jul 28, 2017
Dummy download tester for PHP with data throttling
View dummy_download.php
<?php
/**
* Long file download tester.
* You can test very long file downloads using PHP.
*/
ob_start();
/**
* Settings
*/
You can’t perform that action at this time.