Skip to content

Instantly share code, notes, and snippets.

@lewebsimple
lewebsimple / setup-typescript.sh
Last active August 24, 2024 19:33
TypeScript / ESLint / Prettier / Vue 3
#!/bin/bash
yarn add -D @typescript-eslint/eslint-plugin \
typescript ts-node-dev \
@typescript-eslint/parser @typescript-eslint/eslint-plugin eslint eslint-config-prettier eslint-plugin-prettier eslint-plugin-vue prettier
cat > .eslintrc.js <<EOF
module.exports = {
root: true,
env: {
@zhiephie
zhiephie / AutoLogout.vue
Last active July 24, 2023 13:48
Vue Auto Logout for Laravel
<template>
<div v-if="warningZone">Are you still with us?</div>
</template>
<script>
export default {
name: 'AutoLogout',
data: function () {
return {
@loilo
loilo / pass-slots.md
Last active October 16, 2024 18:16
Vue: Pass Slots through from Parent to Child Components

Vue: Pass Slots through from Parent to Child Components

The Situation

  • We've got some components A, B and C which provide different slots.
    const A = {
      template: `<div><slot name="a">Default A Content</slot></div>`
    }

const B = {

@mul14
mul14 / laravel-new.sh
Last active March 19, 2016 09:40
Simple script to create Laravel project and cd into target directory. Put this script in your bashrc or zshrc file.
laravel-new() {
if [ -z "$1" ]; then
cat << EOF
Please provide a directory name.
Usage:
laravel-new [directory-name]
EOF
return;
@mul14
mul14 / README.md
Last active February 10, 2023 00:55
Simple Laravel Search Trait

Usage

Put SearchTrait.php in app directory. Then use SearchTrait in your model, like so

use App\SearchTrait;
use Illuminate\Database\Eloquent\Model;

class Article extends Model 
{
@varemenos
varemenos / 1.README.md
Last active October 23, 2024 13:07
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@mul14
mul14 / deploy.rb
Created March 22, 2015 00:52
Deploy Laravel 4 with mina http://mina-deploy.github.io/mina/
require 'mina/git'
# Fix the SSH password prompt problem
set :term_mode, nil
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
@noxify
noxify / PackagistDetailCommand.php
Last active August 29, 2015 14:11
Packagist Search Example
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class PackagistDetailCommand extends Command {
/**
* The console command name.
@BradEstey
BradEstey / Manager.php
Last active February 11, 2021 15:09
Use the Illuminate Validation Class outside of Laravel (With optional Translation and Database connection instances)
<?php
namespace Acme\Validation\Capsule;
use Illuminate\Container\Container;
use Illuminate\Database\ConnectionResolver;
use Illuminate\Database\ConnectionResolverInterface;
use Illuminate\Database\Connectors\ConnectionFactory;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Translation\FileLoader;
@thepsion5
thepsion5 / EloquentFooRepository.php
Created May 2, 2014 15:09
Example implementation of a Eloquent-based repository that provides a fluent interface for sorting and pagination without exposing the underlying model API.
<?php
class EloquenFooRepository
{
/**
* The base eloquent model
* @var Eloquent
*/
protected $model;