Skip to content

Instantly share code, notes, and snippets.

@hmbilal
hmbilal / README.md
Created December 4, 2021 13:11
The most simple php 8, mysql 8, nginx docker setup.

Notes

  • You can replace dockerproject with whatever project namespace you are using.
  • Be sure to use same value for network in docker-compose.
  • In docker-compose files are referenced in an existing directory docker.
    • Make sure to create these files inside docker directory on same level of docker-compose.yml file and replace - with subdirectory from this gist. For exmaple:
      • Create docker/nginx/dockerproject.conf file to use docker-nginx-dockerproject.conf.
  • Make sure that the root path matches public directory of your framework/code that will serve the fronte page of application.
  • Access mysql database on port 3307 assuming you might already have a local instance running at 3306.
  • Access application in your browser at port 8001. You can change this under nginx section in docker-compose file.
@hmbilal
hmbilal / _mixins.scss
Created January 25, 2016 07:45
Includes clearfix, border, center-block, 3D Text,
// clearfix
@mixin clearFix() {
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
}
@hmbilal
hmbilal / regex
Created January 17, 2016 08:33
Regular expression to validate 3 phone number formats. The formats are 0551234567, +971557357625, 00971557357625
/(^[+][0-9]{11,12})$|^(^0{1}(?![0])[0-9]{9})$|(^0{2}[0-9]{11,12})$/g
@hmbilal
hmbilal / README.md
Last active June 18, 2019 15:05
Long polling service in AngularJS

Then in your controller, inject $polling and start polling like this.

General use

$polling.startPolling({name_of_this_polling}, {url_to_fetch_data_from}, {time_in_milli_seconds}, {callback});

Example,

$polling.startPolling('fetchNotifications', 'http://localserver.local/fetch/notifications', 10000, $scope.processData);

Setting up github and bitbucket on the same computer

Github will be the main account and bitbucket the secondary.

Create SSH Keys

ssh-keygen -t rsa -C "github email"

Enter passphrase when prompted. If you see an option to save the passphrase in your keychain, do it for an easier life.

@hmbilal
hmbilal / csv-importer.php
Created April 18, 2015 09:19
importing csv file into mysql using php
<?php
define("DB_HOST", "localhost");
define("DB_NAME", "db_name");
define("DB_USER", "root");
define("DB_PASSWORD", "");
define("CSV_FILE", "file.csv");
$db = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . "," . DB_USER . "," . DB_PASSWORD);
@hmbilal
hmbilal / IndexController.php
Last active May 23, 2018 10:17
Uploading multiple files in Zend Framework 2 (solution for file is uploaded illegally in zf2)
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController,
Lists\Entity\Lists;
class IndexController extends AbstractActionController
{
public function indexAction()
{
@hmbilal
hmbilal / debug-ui-router.js
Last active December 13, 2023 14:42
Debugging Angular ui-router routes in browser console.
// Paste this code in browser console to debug ui-router problems when navigating through states.
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart from '+fromState.name+'- fired when the transition begins. fromState,fromParams : \n',fromState, fromParams);
console.log('$stateChangeStart to '+toState.name+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
});
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){