Skip to content

Instantly share code, notes, and snippets.

View maksbd19's full-sized avatar

Mahbub Alam maksbd19

View GitHub Profile
@maksbd19
maksbd19 / pmpro_default_role.php
Created February 16, 2015 11:24
Assign a default role with the PMPro membership plan
/*
subscriber will be assigned to default role when they sign up
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
if($level_id > 0){
$role = get_option('pmpro_role_for_id_'.$level_id);
@maksbd19
maksbd19 / contry_phone_code
Last active August 21, 2016 07:30
A dropdown select box containing all the countries with their phone code
<select name="" id="" >
<option value="995|QZ" title="Abkhazia +995">Abkhazia +995</option>
<option value="93|AF" title="Afghanistan +93">Afghanistan +93</option>
<option value="358|AX" title="Aland Islands +358">Aland Islands +358</option>
<option value="355|AL" title="Albania +355">Albania +355</option>
<?php
// if you need a settings page where you want to put the upload images button
add_action( 'admin_menu', 'register_media_selector_settings_page' );
function register_media_selector_settings_page() {
add_submenu_page( 'options-general.php', 'Media Selector', 'Media Selector', 'manage_options', 'media-selector', 'media_selector_settings_page_callback' );
}
// this is the callback for the uploader button. You can use anywhere
-- MySQL dump 10.13 Distrib 5.6.35, for osx10.9 (x86_64)
--
-- Host: localhost Database: student_test
-- ------------------------------------------------------
-- Server version 5.6.35
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
then you can run
$ sudo composer install
@maksbd19
maksbd19 / .gitignore
Created August 15, 2017 04:42 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
// https://stackoverflow.com/questions/55320737/how-to-wait-for-a-promise-to-resolve-or-reject-then-move-to-next-command#55320737
// your original code
const validatePreconditions = ({ exitOnFailure = true } = {}) => {
let portSuccess = true
checkIfPortIsAvailable(3000).then((val) => portSuccess = val , (err) => console.log("DEBUG1:",err))
console.log("DEBUG2:",portSuccess)
if (! portSuccess && exitOnFailure) {
logger.error(colors.red('Exiting due to unsatisfied precondition!'))
const hash = {};
const hash = {};
// to get the value for a particular index
const get = index => typeof hash[index] !== "undefined" ? hash[index] : null;
// add a new value in a particular index
const set = (index, data) => {
if( typeof hash[index] === "undefined"){
hash[index] = [];
}
const fs = require('fs');
const path = require('path');
const dbFilePath = path.join(__dirname, 'db.json'); // path to the json file where we are storing our hash data
const MAX_TRY_COUNT = 5; // Maximum numebr of attempts in case of failure
let readTryCount = 0; // hold the read try count
let writeTryCount = 0; // hold the write try count
const hash = {};