Skip to content

Instantly share code, notes, and snippets.

@msurguy
msurguy / eloquent.md
Last active February 8, 2022 03:13
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@sindresorhus
sindresorhus / post-merge
Last active July 25, 2024 06:53
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@mrosati84
mrosati84 / devify
Last active August 29, 2015 14:04
Easily manage projects using H-ART Dev Machine
#!/bin/bash
# create Dev Machine structure
function createStructure {
# TODO
# 1- check existing folders
# 2- ask user for overwriting
if [ -d manifests ] ||
[ -d modules ] ||
[ -d xdebug ] ||
@roberto-butti
roberto-butti / install_django_virtualenv.sh
Last active August 29, 2015 14:14
My script for installing new Django project with virtualenv
PROJECTNAME=example
APPNAME=${PROJECTNAME}app
PROJECTDIR=${PROJECTNAME}_project
ENVNAME=${PROJECTNAME}env
SITENAME=${PROJECTNAME}sitename
echo "I will create ${PROJECTDIR} for${PROJECTNAME}"
mkdir ${PROJECTDIR}
cd ${PROJECTDIR}