Skip to content

Instantly share code, notes, and snippets.

View mazfreelance's full-sized avatar
🎯
Focusing

nimza mazfreelance

🎯
Focusing
View GitHub Profile
@mazfreelance
mazfreelance / PHP: Listed date between two dates
Created December 20, 2017 07:27
PHP: Listed date between two dates
function getDatesFromRange($start, $end, $format = 'Y-m-d') {
$array = array();
$interval = new DateInterval('P1D');
$realEnd = new DateTime($end);
$realEnd->add($interval);
$period = new DatePeriod(new DateTime($start), $interval, $realEnd);
foreach($period as $date) {
@mazfreelance
mazfreelance / JS: Calc business days Monday to Friday
Created December 26, 2017 06:16
Javascript : Calculate business days between two (2) dates, business days (Monday to Friday)
function calculateBusinessDays(startDate, endDate){
// Validate input
if (endDate < startDate)
return 0;
// Calculate days between dates
var millisecondsPerDay = 86400 * 1000; // Day in milliseconds
startDate.setHours(0,0,0,1); // Start just after midnight
endDate.setHours(23,59,59,999); // End just before midnight
var diff = endDate - startDate; // Milliseconds between datetime objects
@mazfreelance
mazfreelance / JQUERY checkbox validation
Created April 13, 2018 01:49
validation checkbox select atleast one
//html
<input type="checkbox" class="checkbox" name="checkbox[]" value="checkbox 1"/>
<input type="checkbox" class="checkbox" name="checkbox[]" value="checkbox 2"/>
<p id="validation"></p>
//form submit
$('#form-id').submit(function(evt){
evt.preventDefault();
...
if(!$('.checkbox').is(":checked")) {
@mazfreelance
mazfreelance / Dynamic List Laravel
Created September 6, 2018 03:15
Dynamic List Laravel
//Model
namespace App;
use Illuminate\Database\Eloquent\Model;
class ModelName extends Model
{
protected $table = 'table_name_dB';
}
@mazfreelance
mazfreelance / deleteimagepost
Last active August 20, 2019 10:25
PHP - Summernote library: Store uploaded image file into folder server.
$file_name = str_replace(base_url().'/uploads/email/', '', $src); // striping host to get relative path
if(unlink($file_name))
{
echo 'File Delete Successfully';
}
@mazfreelance
mazfreelance / append data to selection form
Created January 14, 2020 04:02
append data to selection form using ajax
$.ajax({
url: '../example.php',
type: 'post',
data: {},
success: function( data, textStatus, jQxhr ){
// console.log(data);
var itemID = <?php echo json_encode($item_id); ?>;
// console.log(itemID);
$.each(data['data'], function(key, value) {
$('select#select_item').append($("<option></option>").attr("value",key).text(value)).trigger('change');
@mazfreelance
mazfreelance / README.md
Last active January 22, 2020 04:19
JQUERY: multiselect list swap
@mazfreelance
mazfreelance / README.md
Last active January 30, 2020 09:17
Javascript: Month range picker using daterangepicker()
@mazfreelance
mazfreelance / NEW GIT url
Last active October 8, 2021 07:35
Github shut down password authentication. u should change repo url if want clone , pull , push and so on.
old : https://github.com/<username>/<username/project_name.git>
new : https://<username>:<personal_token>@github.com/<username/project_name.git>
- generate personal token
Settings > Developer settings > Personal access tokens
git remote set-url origin <url>
git remote -v (view remote url)
@mazfreelance
mazfreelance / add-local-dependency-composer.md
Last active September 26, 2023 02:14
add local dependencies into composer.json

the following directory structure in your repository

├── apps
│   └── my-app
│       └── composer.json
├── packages
│   └── my-custom-package
│       └── composer.json