Skip to content

Instantly share code, notes, and snippets.

View coder618's full-sized avatar
🎯
Focusing

Ahadul Islam coder618

🎯
Focusing
View GitHub Profile
@coder618
coder618 / django-json-example.py
Created August 14, 2019 04:49 — forked from cspanring/django-json-example.py
Basic example for iterating over a Django queryset and returning JSON objects.
import json
from .models import MyModel
def get_json(request):
# Return JSON for filtered MyModel objects
records = MyModel.objects.filter(myproperty=myvalue)
@coder618
coder618 / phpmyadmin fix
Last active August 16, 2019 12:31
phpmyadmin problem in php7.2
/**
* Function to check whether to remember the sorting order or not
*
* @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
*
* @return boolean
*/
function PMA_isRememberSortingOrder($analyzed_sql_results)
{
@coder618
coder618 / Render Posts Post template Function
Last active December 7, 2019 02:58
Render Posts , template for: post type
// following function will be use when you apply this shortcode: [render-posts type="post"]
function post_template($id){
$c_id = $id;
$post_img_url = get_the_post_thumbnail_url($c_id, 'large');
$title = esc_html(get_the_title($c_id));
$html = '';
$html .= '<a href="'.get_permalink($c_id).'" class="default-post-template">';
if($post_img_url):
$html .= '<img src="'.$post_img_url.'" alt="'.$title.'">';
endif;
/**
* This function will return array start and end index
* which can be use in array slice Method
* @param {int} pageNumber
* @param {int} posts_per_page
* Logic Behind it
* 5
0 0 5
1 5 10
2 10 15
@coder618
coder618 / add Mailchimp email address by CURL
Created May 26, 2020 12:23
Mailchimp Add E-Email Address CURL PHP
<?php
// require 'auth.php';
$username = 'username';
$password = 'password';
$url = 'https://us19.api.mailchimp.com';
// $postvars = "[email protected]&status=subscribed";
$postvars = [
"email_address"=> "[email protected]",
"status"=> "subscribed",
"merge_fields" => [
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
@coder618
coder618 / Gutenberg Sample Block form carbon field
Created June 18, 2020 07:08
Gutenberg Sample Block form carbon field wordpress plugin
<?php
use Carbon_Fields\Container;
use Carbon_Fields\Field;
use Carbon_Fields\Block;
add_action( 'carbon_fields_register_fields', 'dd' );
function dd(){
// var_dump( WP_Block_Type_Registry::get_instance()->get_all_registered() );
Block::make( __( 'My Shiny Gutenberg Block' ) )
@coder618
coder618 / VS Code essential spinet
Last active November 7, 2020 10:29
vs code spinet
HTML, PHP
{
"php tag": {
"prefix": "php",
"body": ["<?php $1 ?>"],
"description": "php"
},
"coder618_print": {
"prefix": "coder618_print_markup",
"body": ["<?php coder618_print_markup($1) ?>"],
@coder618
coder618 / return pagination index
Created July 10, 2020 10:28
Return pagination index for array
function returnIndex() {
var postsPerPage = 12;
console.log('return start endindex ', page, postsPerPage);
let startIndex = postsPerPage * page;
let endIndex = startIndex + postsPerPage;
return [ startIndex, endIndex ];
}
@coder618
coder618 / Wordpress Remove all unnecessary tags from head
Created August 3, 2020 12:36
this pieces of code will remove all unnecessary tags from which generated between <head></head> by WordPress. Use with caution
add_action( 'after_setup_theme', 'prefix_remove_unnecessary_tags' );
function prefix_remove_unnecessary_tags(){
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );