Skip to content

Instantly share code, notes, and snippets.

@daif
daif / erpnext-installer-v13.sh
Created April 18, 2021 01:27
ERPNext v13 installer
#!/bin/bash
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
##################################################################
@daif
daif / diff_db.php
Created October 27, 2020 15:03
Compare two databases schema and generate SQL scripts
<?php
#
# diff_db() function for MySQL/MariaDB
# This function compare two databases schema and generate SQL scripts
# to update the second database.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@daif
daif / validate_saudi_id.sql
Created October 8, 2020 21:34
Validate Saudi identity card number
#
# validate_saudi_id() function for MySQL/MariaDB
# This function will validate Saudi identity card number
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# by Daif Alazmi (http://daif.net)
@daif
daif / GetRandomFromArray.php
Created October 4, 2020 09:33
Get random elements from array
<?php
// Get array elements from items file
$items = file('items.txt');
// Pick a random element from array
$item = array_rand($items);
// Save chosen element to chosen file
file_put_contents('items-chosen.txt', $items[$item], FILE_APPEND);
// print the chosen element
print $items[$item];
// unset the chosen element
@daif
daif / nextcloud-19.sh
Created July 1, 2020 16:10
Nextcloud 19 installer
#!/bin/bash
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@daif
daif / mysql-backup.sh
Created May 15, 2020 12:59
MySQL backup tool
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@daif
daif / BinarySearch.php
Created May 2, 2020 01:54
Implementation of binary search in PHP
<?php
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BinarySearch.phps 0.1
* Implementation of binary search in PHP
* by Daif Alazmi (http://daif.net)
@daif
daif / metabase-installer.sh
Created March 21, 2020 11:42
MetaBase 0.34.3 installer
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@daif
daif / lamp-ubuntu-18-04.sh
Created December 8, 2019 08:07
LAMP installer
#!/bin/bash
# Copyright (C) 2019 Daif Alazmi
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@daif
daif / erpnext-installer.sh
Created November 10, 2019 08:00
ERPNext installer
#!/bin/bash
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of