Skip to content

Instantly share code, notes, and snippets.

View mbmohib's full-sized avatar
🎯
Focusing

Mohammad Mohibbullah mbmohib

🎯
Focusing
View GitHub Profile
@mbmohib
mbmohib / forms.py
Created November 23, 2016 17:06
In registration menu, checking email already exist or not!
def clean_email(self):
email = self.cleaned_data.get('email')
username = self.cleaned_data.get('username')
if email and User.objects.filter(
email=email).exclude(username=username).count():
raise forms.ValidationError(
"A user with that email already exists")
return email
# Three methods of getting object's url:
<a href='/posts/{{ post.id }}'><p>{{ post.title }}</p></a> (#static)
<a href='{% url 'detail' id=post.id %}'><p>{{ post.title|title }}</p></a>
<a href='{{ post.get_absolute_url }}'><p>{{ post.title|title }}</p></a>
@mbmohib
mbmohib / forms.py
Created November 23, 2016 17:08
Checking more than one filed exist or not!
def clean(self):
try:
User.objects.get(first_name=self.cleaned_data['first_name'],
last_name=self.cleaned_data['last_name'])
raise forms.ValidationError("Exists already!")
except User.DoesNotExist:
pass
return self.cleaned_data
@mbmohib
mbmohib / style.css
Last active March 23, 2017 10:11
CSS Tricks
/* Center elements Using Position: */
element {
position:absolute;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
}
/* Centering Element in CSS */
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.click(function(event) {
// On-page links
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
&&
location.hostname == this.hostname
@mbmohib
mbmohib / Linux Software Installation.txt
Last active May 1, 2018 06:00
Linux Software Installation
Software List:
1. SM Player
2. Deluge
3. Atom
4. Java
5. nitroshare
6. Gnome Tweak Tool
7. Numix
8. Adapta
9. Cryptsetup
@mbmohib
mbmohib / PHP.txt
Created October 27, 2017 16:16
PHP
PHP - MARIA DB - LARAVEL - ATOM
# PHP + Maria DB:
$ sudo apt-add-repository ppa:ondrej/php
$ sudo apt-get install curl unzip phpunit mariadb-client mariadb-server sqlite3 php7.0 php7.0-cli php7.0-curl php7.0-mcrypt php7.0-sqlite3 php7.0-mbstring php7.0-zip php7.0-mysql php7.0-xml
$ which php
$ which mysql
# Composer + Laravel
Get the Composer first : https://getcomposer.org/download/
@mbmohib
mbmohib / addArrowIconToDropdown.js
Last active November 1, 2018 18:29
Add Arrow to nested Dropdown Menu
/**
* Find any element that has dropdown ul
* and add "down arrow" to 1st level
* and "right arrow" to 2nd level
*
* @param {*} nodeList
*/
const addArrowIconToDropdown = (nodeList) => {
const nodeListArray = Array.prototype.slice.call(nodeList)
nodeListArray.length > 0 && nodeListArray.forEach(list => {
@mbmohib
mbmohib / .block
Last active November 19, 2019 04:20
Bar Chart of Temperature in different city
license: mit
@mbmohib
mbmohib / .block
Last active November 19, 2019 04:22
Line Chart of Temperature in different city
license: mit