Skip to content

Instantly share code, notes, and snippets.

View hassanjamal's full-sized avatar
🚀
Working from home

Hassan Jamal hassanjamal

🚀
Working from home
View GitHub Profile
@hassanjamal
hassanjamal / mysql-docker.sh
Created December 5, 2021 07:56 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@hassanjamal
hassanjamal / Laravel-Container.md
Created September 2, 2019 14:04
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

@hassanjamal
hassanjamal / Validator.php
Created January 26, 2018 16:57 — forked from waleedrehmankhan/Validator.php
Custom Laravel Alphanumeric Validator that allow spaces
Paste this Code in Validator.php
public function validateAlphaSpaces($attribute, $value, $params)
{
return preg_match('/^[\pL\s]+$/u', $value);
}
Create Custom Message some where at bottom in Validation.php
/*
@hassanjamal
hassanjamal / php-code-inspection.md
Created October 3, 2017 10:23
How to install PHP code inspection tools using homebrew-php and how to integrate with JetBrain's IntelliJ or PhpStorm

#Inspection Tools with homebrew-php#

##Prerequisites##

  • Homebrew is installed

##Step 1: Installing homebrew-php##

  1. brew tap homebrew/dupes
  2. brew tap josegonzalez/homebrew-php
  3. brew install PHP53 (or other version of your choice)

Sprint - meeting :

  1. In this meeting we will be deciding all possible features which can be done in upcoming sprint.
  2. Discussion will be whole day. Where we have to decide all possibilities.
  3. Estimate task and decided UI for app. If there is any issue in UI this is the time to point out the mistakes
  4. If there is any issue in API this is the time to point out the issues.
  5. If there is any R&D task, please mention and estimate the R&D task.

How to estimate any task?

  1. Think about the efforts and possibilities. Its not easy to estimate but it comes only with experience. So keep estimating on regular basis one day you will reach there.
  2. Check for existing, if any. To save time and efforts. (Please refer to question how to choose Third party lib)
@hassanjamal
hassanjamal / overview-for-angular-apps-with-roles-and-permissions.md
Last active September 12, 2015 11:24 — forked from bvaughn/overview-for-angular-apps-with-roles-and-permissions.md
RE: Reddit Angular JS question "Advice on separating the logical parts of an application"

This gist is in response to a question asked on the Reddit Angular JS forum about how to structure an Angular app with roles and permissions.

There are many ways to approach this, but I'll share one that I've used before and maybe it will give you an idea. I'd combine all of the above into a single app and control who gets to see what using permissions. There are a few components to this approach...

A local session service

First off I'd advise creating some sort of local session management service. This should be able to track whether you have an authenticated user and- if so- what types of permissions that user has. (Lots of ways to manage permissions. I'll assume your user object has either a 'role' enum or something simple like an array of string permissions.) You could roll your own session service or you could check out something like satellizer.

Let's assume yo

@hassanjamal
hassanjamal / digital_ocean_setup.md
Last active August 29, 2015 14:27 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions

DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3

SSH into Root

$ ssh root@123.123.123.123

Change Root Password

@hassanjamal
hassanjamal / uninstall_gems.sh
Last active August 29, 2015 14:27 — forked from IanVaughan/uninstall_gems.sh
Uninstall all rbenv gems
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug
<?php
$browsers = array('firefox','chrome','safari','opera','msie');
$browser = new stdClass();
preg_match('#('.implode('|',$browsers).')(/| )([^ ]+)#i',$_SERVER['HTTP_USER_AGENT'],$match);
$browser->version = round((int)$match[3]);
$match = strtolower($match[1]);
foreach($browsers as $val)
{