Skip to content

Instantly share code, notes, and snippets.

View the94air's full-sized avatar
🐞
Looking for bugs. Pushing fixes.

Abdalla Arbab the94air

🐞
Looking for bugs. Pushing fixes.
View GitHub Profile
@the94air
the94air / config.php
Last active January 30, 2017 14:22
Get a value from a multidimensional array using the dot syntax
<?php
class Helper
{
public static function get( $arr, $key, $default=null )
{
@list( $index, $key ) = explode( '.', $key, 2 );
if ( !isset( $arr[$index] ) ) return $default;
@the94air
the94air / formjs.js
Last active February 25, 2017 10:00
I use jquery for adding events and adding element that has been ALL READY STYLED in formjs.css ( jquery will not effect any style )
function DisableErrorGlowOnFocus() {
$("input:not([type=submit]):not([type=button]):not([type=radio]):not([type=checkbox]):not([type=file]).disableonfocus").on('focus', function() {
$(this).removeClass("formjs-error");
$(this).removeClass("disableonfocus");
});
$("textarea.disableonfocus").on('focus', function() {
$(this).removeClass("formjs-error");
$(this).removeClass("disableonfocus");
});
}
@the94air
the94air / PostController.php
Created April 16, 2017 08:24
Use normal html select in Laravel
<?php
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$tags = Tag::select('name', 'id')->get(); // <------- This is very !important
return view('posts.create')->withTags($tags);
@the94air
the94air / AuthenticatesUsers.php
Created June 9, 2017 09:09
I want to log user in with email or username
<?php
namespace Illuminate\Foundation\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
trait AuthenticatesUsers
{
use RedirectsUsers, ThrottlesLogins;
@the94air
the94air / ArticlesController.php
Last active July 24, 2017 08:34
How many record I should allow to show Datatable Without making my slowing my page load.
<?php
class ArticlesController extends Controller {
public function show()
{
$count = Article::count();
if($count < [?]) {
// return the normal http view.
// the datatable will handle the dirty work.
@the94air
the94air / app.php
Created February 18, 2018 12:51 — forked from permatis/app.php
Create setting SwiftMailer in Slim Framework.
$app->mailer = function () {
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', '465', 'ssl')
->setUsername('[email protected]')
->setPassword('password');
$mailer = Swift_Mailer::newInstance($transport);
return $mailer;
};
@the94air
the94air / bootstrap4.blade.php
Created March 30, 2018 09:31
Bootstrap 4 voyager menu template
@php
if (Voyager::translatable($items)) {
$items = $items->load('translations');
}
@endphp
<ul class="navbar-nav ml-auto">
@foreach($items as $item)
@the94air
the94air / mutations.js
Created June 27, 2018 17:00 — forked from techlab23/mutations.js
Vuex mutations with add, edit and delete entries
import Vue from 'vue'
import * as types from './mutation-types'
export default {
// Mutation to set entries in state
[types.SET_ENTRIES] (state, entries) {
state.entries = entries || {}
},
// Mutation to add entry in state
public class Hello
{
   public static void Main()
   {
-      System.Console.WriteLine("Hello, World!");
+      System.Console.WriteLine("Rock all night long!");
   }
}
@the94air
the94air / validate-clean.js
Last active October 14, 2019 17:46
Tiptap json validation
.custom(value => {
const post = JSON.parse(value);
if (!post || post.type !== 'doc' ||
!Array.isArray(post.content) || post.content.length === 0
) {
return Promise.reject(errors.jsonHTML)
}
const [item] = post.content;