Skip to content

Instantly share code, notes, and snippets.

View amir9480's full-sized avatar
🎯
Focusing

Amir Alizadeh amir9480

🎯
Focusing
View GitHub Profile
@amir9480
amir9480 / helpers.php
Last active May 7, 2024 16:03
Laravel copy all files from one storage disk to another
<?php
if (! function_exists("copy_storage")) {
/**
* Copy files from one disk to another.
*
* @param string $from from disk name
* @param string $to to disk name
* @param string $directory if you want just copy specific directory
* @return void
@amir9480
amir9480 / tests.yml
Created January 10, 2021 19:06
Sample Mesa workflow
name: tests
on:
push:
pull_request:
jobs:
build:
runs-on: windows-latest
steps:
@amir9480
amir9480 / tests.yml
Created January 10, 2021 18:57
Install Mesa3D Github Actions workflow
- name: Install Mesa
shell: cmd
run: |
curl.exe -L --output mesa.7z --url https://github.com/pal1000/mesa-dist-win/releases/download/20.3.2/mesa3d-20.3.2-release-msvc.7z
"C:\Program Files\7-Zip\7z.exe" x mesa.7z
mklink opengl32.dll "x64\opengl32.dll"
mklink libglapi.dll "x64\libglapi.dll"
working-directory: build\tests\Debug
@amir9480
amir9480 / test.php
Created December 14, 2020 07:36
Remove Accent Characters PHP
<?php
$str = "...";
// Based on https://stackoverflow.com/a/9667752/5134885
$chars = [
"Á" => "A",
"Ă" => "A",
"Ắ" => "A",
"Ặ" => "A",
@amir9480
amir9480 / main.dart
Created September 22, 2020 13:42
Circular Image
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: HomePage(),
@amir9480
amir9480 / ImageController.php
Created January 27, 2020 18:57
Image resizer in laravel.
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\File;
use Intervention\Image\Facades\Image;
use Exception;
class ImageController extends Controller
{
@amir9480
amir9480 / main.cpp
Created January 9, 2020 13:03
Change executable file constants in C++.
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <direct.h>
const char* test[] = { "UNIQUE_START_TOKEN", "WELCOME\0------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", "UNIQUE_END_TOKEN" };
int main(int argc, const char** argv)
{
@amir9480
amir9480 / BlogPost.php
Created May 20, 2019 18:27
vasiat laravel
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BlogPost extends Model
{
public function getLinkAttribute()
{
@amir9480
amir9480 / BlogPost.php
Created May 20, 2019 18:10
vasiat laravel
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BlogComment extends Model
{
protected $casts = [
'confirmed' => 'boolean'
@amir9480
amir9480 / BlogPost.php
Created May 20, 2019 18:03
vasiat laravel
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
class BlogComment extends Model
{
protected static function boot()