Skip to content

Instantly share code, notes, and snippets.

View hsleonis's full-sized avatar
🏝️
Travellers unite.

Hasan Shahriar hsleonis

🏝️
Travellers unite.
View GitHub Profile
@hsleonis
hsleonis / js-inline-xml-parser-validation.html
Created March 30, 2016 04:50
Validate inline script '<' and '&' in XML parsers
<script type='text/javascript'>
/* <![CDATA[ */
var scriptParams = {"theme":"light"};
/* ]]> */
</script>
@hsleonis
hsleonis / wp-plugin-constants.php
Created March 30, 2016 04:48
WP plugin constant definition
<?php
/**
* Prevent Direct Access
*
* @since 0.1
*/
defined('ABSPATH') or die("No script kiddies please!");
/**
* Plugin constants
@hsleonis
hsleonis / wp-register-textdomain.php
Created March 30, 2016 04:45
WP register text domain
<?php
/**
* Register text domain
*
* @since 0.1
*/
function tmx_textdomain() {
load_plugin_textdomain( 'themeaxe', false, dirname(plugin_basename(__FILE__)). '/languages/' );
}
add_action( 'init', 'tmx_textdomain' );
@hsleonis
hsleonis / wp-plugin-page-link.php
Created March 30, 2016 04:43
WP add plugin settings page link to plugins.php
@hsleonis
hsleonis / .htaccess
Created March 29, 2016 04:08
HTAccess file with ETag, Cache, GZip and custom routing
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript application/json
</ifModule>
Header unset ETag
FileETag None
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
@hsleonis
hsleonis / iphone-text-resizing-disable.css
Created March 23, 2016 10:16
Mobile Safari on iPhone will automatically increase the size of small text.The work around is ‑webkit‑text‑size‑adjust: 100%
/*
On mobile devices, the text-size-adjust property allows Web authors to control if and how
the text-inflating algorithm is applied to the textual content of the element it is applied to.
As this property is non-standard, it must be used prefixed: -moz-text-size-adjust,
-webkit-text-size-adjust, and -ms-text-size-adjust.
Reference:
http://blog.55minutes.com/2012/04/iphone-text-resizing
http://davemacaulay.com/webkit-text-size-adjust-doesnt-work-on-android-chrome
*/
@hsleonis
hsleonis / text-unselectable.css
Created March 23, 2016 09:21
Make text unselectable
/*
This is useful in situations where you want to provide an easier/cleaner
copy-paste experience for users (not have them accidentally text-select
useless things, like icons or images). However it's a bit buggy. Firefox enforces
the fact that any text matching that selector cannot be copied. WebKit still
allows the text to be copied if you select elements around it.
Reference: https://css-tricks.com/almanac/properties/u/user-select
*/
.row-of-icons {
-webkit-user-select: none; /* Chrome all / Safari all */
@hsleonis
hsleonis / image-rendering.css
Last active April 5, 2016 10:05
The image-rendering property defines how the browser should render an image if it is scaled up or down from its original dimensions.
/*
Chrome appears to render pixelated images in the same way that Firefox and Safari will render images with crisp-edges.
Reference:
https://css-tricks.com/almanac/properties/i/image-rendering
https://developer.mozilla.org/en/docs/Web/CSS/image-rendering
*/
img {
image-rendering: auto;
image-rendering: crisp-edges;
@hsleonis
hsleonis / ini_set.php
Created March 22, 2016 12:23
Sets the value of a configuration option
<?php
/*
Pattern: string ini_set ( string $varname , string $newvalue )
Documentation: http://php.net/manual/en/function.ini-set.php
*/
echo ini_get('display_errors');
if (!ini_get('display_errors')) {
ini_set('display_errors', '1');
}
@hsleonis
hsleonis / bootboxjs-ajax.js
Created March 22, 2016 10:10
Dynamic content in Bootbox JS with AJAX request
bootbox.dialog({
title: "This is a AJAX Form from external file.",
data: {'user':'dc','task':'get'},
datauri: 'ajax.html',
buttons: {
success: {
label: "Save",
className: "btn-success",
callback: function () {
var name = $('#name').val();