Skip to content

Instantly share code, notes, and snippets.

View lao9s's full-sized avatar

Dima Botezatu lao9s

View GitHub Profile
@javilobo8
javilobo8 / download-file.js
Last active March 17, 2025 14:25
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@peterbrinck
peterbrinck / Laravel on VestaCP.md
Last active July 2, 2023 14:49
Laravel web templates for VestaCP

I'm not using this or VestaCP anymore, so I can't confirm if still working or not.

I've made a new web template to make Laravel work easily on VestaCP, and so I wouldn't have to change my Laravel installation, if I ever wanted to deploy it elsewhere.

Each file should be put in /usr/local/vesta/data/templates/web/apache2

Then, when you edit your domain/site, you can change the web template to Laravel and just upload your whole project into public_html

If .DS_Store was never added to your git repository, simply add it to your .gitignore file.

If you don't have one, create a file called

.gitignore

In your the root directory of your app and simply write

@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active April 24, 2025 05:32
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

Laravel Developer - Interview Exercise

  • Setup a fresh Laravel 5.8 application.
  • Use Tailwind CSS as the CSS framework.
    • CDN version is fine.
    • Bonus points if installed via NPM.
  • Create a new contact page at /contact.
  • Create a contact form on the page.
  • The form should be built as a Vue component.
  • The form should submit via ajax.
@jtorvald
jtorvald / reset-audio.command
Last active April 4, 2025 23:04
Fix annoying popping crackling sound on the new MacBook Pro 16inch. Save this file and run it or copy and paste the onliner and run it in a terminal.
# if you don't understand how to save this file and execute it (open reset-audio.command)
# then copy and paste this oneliner and enter your password for privileged access:
# sudo kill -9 $(ps axc|awk "{if (\$5==\"coreaudiod\") print \$1}");
# get the process ID of coreaudio
PID=$(ps axc|awk "{if (\$5==\"coreaudiod\") print \$1}")
if [ $PID != "" ]
then
echo "Killing coreaudiod process on $PID"
@mortezashojaei
mortezashojaei / OrdersComponent.tsx
Last active March 19, 2025 12:42
Using laravel-echo in reactjs
import React, { FC } from 'react';
import { useSocket } from '@myapp/hooks';
import {Order} from '@myapp/models';
export const OrdersComponent: FC = () => {
const [orders,setOrders] = useState<Order[]>();
function addNewOrder(neworder:Order) {
@WhereJuly
WhereJuly / composer.json
Last active April 2, 2023 00:23
Standalone Laravel 8.25 validation with genuine Laravel messages
// ...some entries
"require": {
"illuminate/validation": "^8.25",
"illuminate/translation": "^8.25"
}
// ...some more entries
@waska14
waska14 / FileHelper.php
Last active September 26, 2024 21:11
Laravel: create UploadedFile object from base64 string (autoremove temp file)
<?php
namespace App\Helpers\File;
use Illuminate\Http\File;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Arr;
class FileHelper
{