Skip to content

Instantly share code, notes, and snippets.

View mazfreelance's full-sized avatar
🎯
Focusing

nimza mazfreelance

🎯
Focusing
View GitHub Profile
@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

first commit with tag

  • <tag> - eg: v0.0.1
$ git add.
$ git commit -m "Initial release"
$ git tag <tag> 
$ git push origin master --tags
@mazfreelance
mazfreelance / gist:9afe62cfb4c69d880ed5bf27cb1260ef
Last active September 19, 2023 04:10
setup PostgresSQL database
# Access PostgreSQL: Once PostgreSQL is installed, you can access it using the command-line tool psql.
# Open your terminal or command prompt and run:
psql -U postgres
# Create a Database: To create a new database, you can use the following SQL command inside the psql prompt:
CREATE DATABASE yourdbname;
# Create a User with a Password: You can create a new user and set a password for that user using the following SQL commands:
CREATE USER yourusername WITH PASSWORD 'yourpassword';
@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 / PHP: get next month date from today's date
Created December 20, 2017 06:49
PHP: get next month date from today's date
//expected output
Current Date | +1 month
-----------------------------------------------------
2015-01-01 | 2015-02-01 (+31 days)
2015-01-15 | 2015-02-15 (+31 days)
2015-01-30 | 2015-03-02 (+31 days, skips Feb)
2015-01-31 | 2015-03-03 (+31 days, skips Feb)
2015-02-15 | 2015-03-15 (+28 days)
2015-03-31 | 2015-05-01 (+31 days, skips April)
2015-12-31 | 2016-01-31 (+31 days)
@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 / JQUERY: using moment.js
Last active May 27, 2021 19:47
JQUERY: get value from malaysian identification card number using moment.js
$('#ic1,#ic2,#ic3').keyup(function(){
/*get value from form*/
var dob = $('#ic1').val(); // eg: 850510 - 10/05/1985
var code = $('#ic2').val(); // eg: 14 - Wilayah Persekutuan
var icno = $('#ic3').val(); // eg: 0000 - ic number
//check gender using ic number
if (icno % 2 == 0){
$('#gender_F').prop("checked", true);
}
@mazfreelance
mazfreelance / README.md
Last active January 30, 2020 09:17
Javascript: Month range picker using daterangepicker()
@mazfreelance
mazfreelance / README.md
Last active January 22, 2020 04:19
JQUERY: multiselect list swap
@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');