Skip to content

Instantly share code, notes, and snippets.

View EmranAhmed's full-sized avatar
🏠
Working from home

Emran Ahmed EmranAhmed

🏠
Working from home
View GitHub Profile
window.dump = function (data) {
console.log(data);
};
window.dd = function (...data) {
data.forEach(function(element) {
console.log(element);
});
throw {
@EmranAhmed
EmranAhmed / bs-04-wp-mix.md
Last active September 23, 2017 00:03
Bootstrap 4.0 Support wp-mix
$wp_customize->add_setting( 'themeslug_media_setting_id', array(
'sanitize_callback' => 'absint',
'validate_callback' => 'themeslug_validate_image,
) );
$wp_customize->add_control(
new WP_Customize_Media_Control( $wp_customize, 'themeslug_media_setting_id', array(
'label' => __( 'Custom Core Media Setting' ),
'section' => 'custom_section', // Add a default or your own section
'mime_type' => 'image',
@EmranAhmed
EmranAhmed / ignore-file-loader.js
Created May 15, 2017 12:59
ignore-file-loader create `loaders` dir and put `ignore-file-loader.js`
var loaderUtils = require("loader-utils");
module.exports = function (content) {
this.cacheable && this.cacheable();
if (!this.emitFile) throw new Error("emitFile is required from module system");
var query = loaderUtils.getOptions(this) || {};
var configKey = query.config || "ignoreFilesLoader";
var options = this.options[configKey] || {};
@EmranAhmed
EmranAhmed / nginx-tuning.md
Created March 4, 2017 21:29 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@EmranAhmed
EmranAhmed / functions.php
Last active June 8, 2023 20:34
Hook Info. Get Action hook info. What functions are hooked to an action / filter in WordPress? How can I see all the actions attached to an "add_action" hook?
<?php
if ( ! function_exists( 'hippo_plugin_hook_info' ) ):
function hippo_plugin_hook_info( $hook_name ) {
global $wp_filter;
$docs = array();
$template = "\t - %s Priority - %s.\n\tin file %s #%s\n\n";
echo '<pre>';
@EmranAhmed
EmranAhmed / array.php
Last active March 8, 2017 17:04 — forked from igorbenic/array.php
How to use the Starter Content in your WordPress Theme WP Starter Content, Demo contents
<?php
add_theme_support( 'starter-content', array(
// Content Section for Widgets
'widgets' => array(
// Sidebar
'sidebar-1' => array(
// Widget ID
'my_text' => array(
// Widget $id -> set when creating a Widget Class
<form class="reduce-form">
  <fieldset>
    <input type="text" name="firstname" placeholder="Enter first name" /><br/>
    <input type="text" name="lastname" placeholder="Enter last name"><br/>
    <input type="email" name="email" placeholder="Enter e-mail" /><br/>
    <button type="submit">Submit</button>
  </fieldset>
</form>
@EmranAhmed
EmranAhmed / using-twitter-bootstrsp.php
Last active January 24, 2017 11:38
UPB Using Twitter Bootstrap
<?php
if ( ! function_exists( 'your_theme_prefix_upb_grid_system' ) ){
function your_theme_prefix_upb_grid_system( $grid ) {
$grid[ 'name' ] = esc_html__( 'Starter Grid', 'your_theme_textdomain' );
$grid[ 'allGridClass' ] = 'column';
$grid[ 'prefixClass' ] = 'col'; // twb col-md-6
$grid[ 'groupClass' ] = 'row'; // twb row
@EmranAhmed
EmranAhmed / cookies.js
Last active December 23, 2016 09:14 — forked from CrocoDillon/cookies.js
Export your awesome module using AMD, CommonJS, Node.js or just as global.
/*
* Inspiration (well… copy pasting more or less) from:
* https://github.com/ScottHamper/Cookies/blob/0.3.1/src/cookies.js#L127-L140
*
* Thanks Scott!
*/
(function (global) {
'use strict';
var MyModule = function () {