Skip to content

Instantly share code, notes, and snippets.

View 3h5a9's full-sized avatar
🎯
Focusing

SM EHSAN 3h5a9

🎯
Focusing
View GitHub Profile
@3h5a9
3h5a9 / .bashrc
Last active May 9, 2019 19:39
Show your branch on Linux Ubuntu terminal
Open up your terminal and type.
nano ~/.bashrc
Now, scroll up to last and paste the code snippet provided below.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
@3h5a9
3h5a9 / environment.rb
Created April 30, 2019 14:45
How to remove field_with_errors wrapper in Rails
/*Add the following line of codes into config/environemnt.rb file*/
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html_tag.html_safe
end
@3h5a9
3h5a9 / posts_controller.rb
Created April 30, 2019 14:42
Rails redirect back to the same page with error message.
/*Edit the posts controller as follows*/
def create
@post = Post.create(post_params)
if @post.save
flash[:success] = "Post created successfully."
redirect_to root_path
else
flash[:danger] = @post.errors.full_messages
redirect_back(fallback_location: root_path)
@3h5a9
3h5a9 / validemailregex.rb
Created May 28, 2018 12:01
valid email regex
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
@3h5a9
3h5a9 / _navbar.html.erb
Created May 17, 2018 06:49
Problem with login and logout link
<nav class="navbar sticky-top navbar-expand-lg navbar-dark bg-danger">
<div class="container">
<%= link_to root_path do%>
<%= image_tag ('Ruby_On_Rails_Logo.svg'), width: 100 %>
<% end %>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
@3h5a9
3h5a9 / gitbranch.md
Last active May 11, 2018 17:59
Add git branch name to ubuntu terminal

Add following lines to your .bashrc file.

You can find that file in home directory,

Please check the show hidden file


parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
@3h5a9
3h5a9 / laravel
Created February 27, 2018 20:38
laravel form problem
@extends('main')
@section('title', ' | Create new post')
@section('content')
<div class="col-md- offset-2 col-md-8">
{!! Form::open(['route' => 'posts.store']) !!}
<div class="form-group">
{!! Form::label('title', 'Title:') !!}
{!! Form::text('title', null, ['class'=>'form-control', 'placeholder' => 'Title']) !!}
@3h5a9
3h5a9 / index.html
Created October 21, 2017 18:05
problem in gallery.
<section class="panel" id="fourth">
<div class="intro color2">
<h2 class="major">Few of my works</h2>
<p>Sed vel nibh libero. Mauris et lorem pharetra massa lorem turpis congue pulvinar. Vivamus sed feugiat finibus. Duis amet bibendum amet sed. Duis mauris ex, dapibus sed ligula tempus volutpat magna etiam.</p>
</div>
<div class="gallery">
<div class="group span-3">
<a href="images/gallery/fulls/01.jpg" class="image filtered span-3" data-position="bottom" alt="This is a test sentense.">
<img src="images/gallery/thumbs/01.jpg" alt="" />
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repudiandae, similique, natus? Vero quisquam aperiam ipsa esse vitae voluptatum, obcaecati expedita illum consequuntur autem non nihil, voluptate maiores suscipit saepe magnam.</p>
@3h5a9
3h5a9 / AuthController.php
Last active September 12, 2017 13:57
Problem on Sending email on user registration
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Student;