Skip to content

Instantly share code, notes, and snippets.

View akhileshdarjee's full-sized avatar
😉
Unstoppable Today

Akhilesh Darjee akhileshdarjee

😉
Unstoppable Today
View GitHub Profile
@akhileshdarjee
akhileshdarjee / always keep cursor horizontally and vertically center of the dragging object.js
Created April 22, 2019 14:32
Always keep cursor horizontally and vertically center of the dragging object
$('body').find('.draggable').draggable({
stack: ".draggable",
helper: 'clone',
start: function(event, ui) {
$(this).draggable('instance').offset.click = {
left: Math.floor(ui.helper.width() / 2),
top: Math.floor(ui.helper.height() / 2)
};
ui.helper.css('cursor', 'move');
@akhileshdarjee
akhileshdarjee / laravel 5 manually create password reset record in db the laravel way.php
Created April 22, 2019 14:34
Laravel 5 manually create password reset record in DB the laravel way
$token = app('auth.password.broker')->createToken(auth()->user());
OR
$token = app('auth.password.broker')->createToken($user);
$user must implement App\User
@akhileshdarjee
akhileshdarjee / base64.js
Created April 22, 2019 14:35
Convert any string to base64 string in Javascript
var str = "Hello World!";
var base64_str = window.btoa(str);
// or
var base64_str = btoa(str);
@akhileshdarjee
akhileshdarjee / set width and height while dragging object in jquery.js
Created April 22, 2019 14:39
Set width and height while dragging object in jquery
$('body').find('.draggable').draggable({
revert: true,
revertDuration: 0,
stack: ".draggable",
helper: 'clone',
start: function(event, ui) {
$(ui.helper).removeAttr('width');
$(ui.helper).removeAttr('height');
var ele_width = $('body').find('.square').width();
@akhileshdarjee
akhileshdarjee / render image file in html5.html
Created April 22, 2019 12:56
Render image file in HTML5
<!DOCTYPE html>
<html lang="en">
<body>
<form name="user-form" id="user-form" enctype="multipart/form-data">
<input type="file" name="image_file">
<input type="text" name="name">
<img src="" id="image_file">
<button type="button" title="Save" id="save-user">Save</button>
</form>
<script type="text/javascript">
@akhileshdarjee
akhileshdarjee / send files images and documents via ajax.html
Last active January 2, 2021 14:43
send files, images or documents via AJAX
<!DOCTYPE html>
<html lang="en">
<head>
<title>User Form</title>
</head>
<body>
<input type="hidden" name="user_id" value="1">
<form name="user-form" id="user-form" enctype="multipart/form-data">
<input type="file" name="image_file">
<input type="text" name="name">
@akhileshdarjee
akhileshdarjee / clean and correct way to call a request internally in laravel 5.php
Created April 22, 2019 14:20
Clean and correct way to call a request internally in Laravel 5
// GET request
$request = Request::create(config('app.url') . '/your-url-here', 'GET');
$response = Route::dispatch($request);
return $response;
// POST request
$params = array(
'product_code' => 'GYU16R',
'qty' => '1',
'price' => 660,
@akhileshdarjee
akhileshdarjee / Responsive Modal LightBox with CSS & JS (no plugins).html
Last active January 2, 2021 14:46
Responsive Modal LightBox with CSS & JS (no plugins)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fancybox</title>
<style type="text/css">
/* Fancybox */
.fancyimg {
border-radius: 5px;
cursor: pointer;
transition: 0.3s;
@akhileshdarjee
akhileshdarjee / best htaccess file for Apache2
Created April 22, 2019 12:39
Best htaccess file for Apache2
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
# Enable Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
@akhileshdarjee
akhileshdarjee / change_php_version_system_wide.txt
Last active November 30, 2021 07:52
Change PHP version system wide
## Interactive Mode
sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar
## Manual Mode
Apache (Webserver):
sudo a2dismod php7.4 -> PHP version which is currently enabled `php -v`