Skip to content

Instantly share code, notes, and snippets.

@mahbubur001
mahbubur001 / install_mongodb.md
Last active October 12, 2024 05:40 — forked from royz/install_mongodb.md
Install MongoDb on ec2 and configure authentication for remote access

Install MongoDb on ec2 and configure authentication for remote access

1. Install and start mongo service [official docs]

1.1 Import the public key used by the package management system

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
@mahbubur001
mahbubur001 / functions.php
Created May 6, 2024 05:00 — forked from alokstha1/functions.php
WordPress custom pagination with $wpdb->get_results
<?php
$items_per_page = 2;
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
$offset = ( $page * $items_per_page ) - $items_per_page;
$query = 'SELECT * FROM '.$table_name;
$total_query = "SELECT COUNT(1) FROM (${query}) AS combined_table";
$total = $wpdb->get_var( $total_query );
@mahbubur001
mahbubur001 / upload.js
Created December 10, 2020 17:18 — forked from jakehasler/upload.js
POST an image as `multipart/form-data`
// Function form the react-native-image-picker library
ImagePicker.showImagePicker({ title: 'Select Image' }, (response) => {
// format the image data
const image = {
uri: response.uri,
type: 'image/jpeg',
name: 'myImage' + '-' + Date.now() + '.jpg'
}
// Instantiate a FormData() object
const imgBody = new FormData();
alexcvzz.vscode-sqlite
andys8.jest-snippets
apollographql.vscode-apollo
austincummings.razor-plus
bobsparadox.seti-black
BriteSnow.vscode-toggle-quotes
christian-kohler.npm-intellisense
christian-kohler.path-intellisense
CoenraadS.bracket-pair-colorizer
dbaeumer.vscode-eslint
<?php
/*
* https://wpml.org/wpml-hook/wpml_active_languages/
*/
function press_wpml_language_selector() {
if (!is_front_page() && is_home()) {
$url = get_post_type_archive_link('post');
$output = '';
$langs = [
@mahbubur001
mahbubur001 / reCAPTCHA-responsive-scaling.js
Created November 13, 2019 04:42
reCAPTCHA Responsive Scaling
(function ($) {
function scaleCaptcha() {
$('.ginput_container.ginput_recaptcha').each(function () {
var self = $(this),
width = $(this).parent().width();
if (width < 302) {
var scale = width / 302;
self.css('transform', 'scale(' + scale + ')');
self.css('-webkit-transform', 'scale(' + scale + ')');
@mahbubur001
mahbubur001 / zshrc
Last active October 27, 2020 07:09 — forked from LukeSmithxyz/zshrc
# Enable colors and change prompt:
# apple
autoload -U colors && colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
# History in cache directory:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
/*
* WP REST API version 2.0-beta7
* API base url ishttp://www.example.com/wp-json
*
* Reference
* https://wordpress.org/support/topic/new-post-with-image
*/
/*
* Get Guzzle HTTP Client. That client has been authenticated.
*/
@mahbubur001
mahbubur001 / php-block.js
Created October 23, 2018 17:29 — forked from pento/php-block.js
Converting a shortcode to a block: this method is fast to do, but a mediocre UX. You should only use this as a stopgap until you can implement a full block UI.
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@mahbubur001
mahbubur001 / add-to-cart-variations.js
Created October 18, 2018 13:35 — forked from mohsinrasool/add-to-cart-variations.js
WooCommerce fix when product variations get removed after load.
/**
* This file contains the fix.
*/
/*global wc_add_to_cart_variation_params, wc_cart_fragments_params */
/*!
* Variations Plugin
*/
;(function ( $, window, document, undefined ) {