Skip to content

Instantly share code, notes, and snippets.

View saber13812002's full-sized avatar
💭
stackoverflow+codegrepper.com

Saber tabatabaee yazdi saber13812002

💭
stackoverflow+codegrepper.com
View GitHub Profile
@saber13812002
saber13812002 / UserModel.php
Last active October 26, 2020 07:50
set all information of user or model to null after restore Laravel Setting null values only on certain fields
// BaseModel Class
protected $nullable = [];
/**
* Listen for save event
*/
protected static function boot()
{
parent::boot();
/**
* Set empty nullable fields to null
* @param object $model
*/
protected static function setNullables(object $model): void
{
foreach ($model->nullable as $field) {
if (empty($model->{$field})) {
$model->{$field} = null;
}
@saber13812002
saber13812002 / gist:2f88cdb8bc75387ff5a698da7bc21ead
Created December 1, 2020 16:53
bouncer from child department
$user = Auth::user();
if ($user->can($ability, $modelOrItem)) {
return true;
}
$descendants = $user->departments()->with('descendants')->get();
foreach ($descendants as $descendant) {
if ($descendant->can($ability, $modelOrItem)) {
@saber13812002
saber13812002 / codemelli.cs
Last active December 6, 2020 10:43 — forked from ebraminio/gist:5292017
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir
// Check Iranian National Code Validity - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy, Rust, Haskell, Erlang, Elixir
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، روبی، جاوااسکریپت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو، سوئیفت، کاتلین، گرووی، راست، هسکل، ارلنگ، الکسیر
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست http://www.fardanews.com/fa/news/127747
// بعضی از پیاده‌سازی‌ها سریع نیستند، می‌توانید نسخهٔ خود را بر پایهٔ
// نسخهٔ سی یا گو ایجاد کنید که بهترین سرعت را داشته باشد
/**
@saber13812002
saber13812002 / README.md
Last active April 11, 2021 09:25
customize The add new item link in SharePoint

How can we create one to many relation by two or more lists in sharepoint

1- first you need two lists (please create them) neming: parent and child

2- in child list you need to have a look up field to ( to the parent column)

NOTE: PLEASE SELECT :ID field as extra field to your list

what we expected:

@saber13812002
saber13812002 / .env
Created May 4, 2021 19:23
laravel cpanel problem with public_path storage folder voyager نحوه صحیح آپلود فایل در هاست لاراول
// add these two lines into .env
FILESYSTEM_DRIVER=parswebserver
STORAGE_PATH="/home/pardisa2/public_html"
@saber13812002
saber13812002 / gist:b89f8e30d489d1644e27101397be76db
Created May 15, 2021 11:21
How can I find the latest commit from forked repos on github?
Intuitive way to view most active fork in GitHub [closed]
javascript:!function(){if(title=document.title,title)if(thing=title.split(/(GitHub\s-\s)*([^:]*)/)[2],thing){var t="https://techgaun.github.io/active-forks/index.html#"+thing;window.open(t)}else window.alert("Not%20a%20valid%20GitHub%20page")}();
@saber13812002
saber13812002 / composer_path.json
Created June 30, 2021 04:57 — forked from ziadoz/composer_path.json
Composer Using Local Repositories and Branches
{
"repositories": [
{
"type": "path",
"url": "../relative/project/path"
}
],
"require": {
"${project}": "dev-${branch}"
}
@saber13812002
saber13812002 / index.php
Created November 4, 2021 15:15 — forked from vsoch/index.php
Generate RSS feed for files in a directory folder. Put this file in a folder with files, modify the $allowed_ext variable to customize your extensions, and $feedName, $feedDesc, $feedURL, and $feedBaseURL. Then navigate to the folder on the web to see the xml feed. Done!
<?php
header('Content-type: text/xml');
/*
Runs from a directory containing files to provide an
RSS 2.0 feed that contains the list and modification times for all the
files.
*/
$feedName = "My Audio Feed";
$feedDesc = "Feed for the my audio files in some server folder";
[options]
#
# WARNING:
# If you use the Odoo Database utility to change the master password be aware
# that the formatting of this file WILL be LOST! A copy of this file named
# /etc/odoo/openerp-server.conf.template has been made in case this happens
# Note that the copy does not have any first boot changes
#-----------------------------------------------------------------------------
# Odoo Server Config File - TurnKey Linux