Skip to content

Instantly share code, notes, and snippets.

View rslahmed's full-sized avatar
🏠
Working from home

Rasel Ahmed rslahmed

🏠
Working from home
View GitHub Profile
@rslahmed
rslahmed / upload-image-with-laravel
Created May 15, 2020 20:47
Upload image with laravel
//insert image
$file = $request->image;
$path = '/backend/upload/';
$image = $path.uniqid().time().'.'.$file->getClientOriginalExtension();
$file->move(public_path().($path), $image);
$data['image'] = $image;
//update image
$file = $request->file('image');
if ($file){
@rslahmed
rslahmed / croppie-image-upload
Last active May 15, 2020 20:35
Croppie image upload
*** html
// form
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">Profile picture</span>
</div>
<div class="custom-file">
<input name="image" type="hidden" id="crop_img">
<input type="file" class="custom-file-input" id="upload_image">
<input onchange="document.getElementById('ins_preview_img').src = window.URL.createObjectURL(this.files[0])">
<img src="" alt="" id="ins_preview_img" >
@rslahmed
rslahmed / get location
Last active October 23, 2020 14:53
Get location with geolocation
//get latitude and longitude
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position) {
console.log(position.coords.latitude, position.coords.longitude)
});
}
@rslahmed
rslahmed / custom right click menu
Last active March 15, 2020 08:37
Custom right click menu
//html
<ul class='custom-menu'>
<li>First thing</li>
<li>Second thing</li>
<li>Third thing</li>
</ul>
//css
/* The whole thing */
.custom-menu {
@rslahmed
rslahmed / Custom accordian
Last active March 15, 2020 08:37
accordion one open only
var acc = document.getElementsByClassName("sh-box-content");
var panel = document.getElementsByClassName('sh-details');
for (var i = 0; i < acc.length; i++) {
acc[i].onclick = function() {
var setClasses = !this.classList.contains('active');
setClass(acc, 'active', 'remove');
setClass(panel, 'show', 'remove');
if (setClasses) {
@rslahmed
rslahmed / SVG Color change
Last active July 15, 2023 06:46
change SVG Color with img class
// way 1:
/**
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
@rslahmed
rslahmed / ajax call
Last active September 5, 2020 19:21
Ajax call with jQuery
$('#add').click(function () {
var id = $(this).attr("target-id");
var data = {id : id};
// if type post
// { _token: "{{ csrf_token() }}", id: id}
@rslahmed
rslahmed / get_ip&mac
Created January 26, 2020 16:29
Get IP and Mac Address
<?php
// get mac address
$MAC = exec('getmac');
$MAC = strtok($MAC,' ');
echo $MAC;
// get ip address
$IP = $_SERVER['REMOTE_ADDR'];
echo $IP;
for clone: git clone [link]
for create branch: git checkout -b [branchname]
for change branch: git checkout [branchname]
for branch check: git branch
for pull files: git pull (must be from master branch)
for push: git push (from your own branch and must pull from master before push)
for push from new branch: git push --set-upstream origin (branch Name) [for the first time]
if you want all master code: git merge master [from your branch]