Skip to content

Instantly share code, notes, and snippets.

juice49 /
Created November 30, 2012 16:53
Using the Laravel Validator, make a field required if another field is set to a given attribute.


  • Add this file to application/libraries (or, if you are already extending the Validator class, add the contents there).
  • Remove Validator alias from config/application.php in order to avoid conflicts.
  • Add "required_if_attribute" => "The :attribute field is required." to application/language/[language]/validation.php.


Define the rule using:


hoylen /
Last active July 23, 2020 11:59
Portable getopt argument processing in shell scripts. Detects which version of getopt is installed. When available, it uses GNU enhanced getopt to support long option names and whitespaces in arguments. Otherwise, defaults to using the original getopt.
# Example showing use of getopt detection and use of GNU enhanced getopt
# to handle arguments containing whitespace.
# Written in 2004 by Hoylen Sue <>
# To the extent possible under law, the author(s) have dedicated all copyright and
# related and neighboring rights to this software to the public domain worldwide.
# This software is distributed without any warranty.
ChrisTM / block-grid.less
Last active August 25, 2022 19:53
Foundation 5's block grids for Bootstrap 3.
// # Block Grid
// Technique adapted from Foundation 5 for Bootstrap 3.0.3 to at least 3.3.1.
// # Example Usage
// To produce a grid of 2 items per row on an extra-small screen, and 3 items
// per row on a small screen:
erfanimani / .gitignore
Last active June 1, 2019 10:22
A refactored and modern .gitignore for Magento. Compatible for Git versions 2.7.0+. See this revision to use it for versions lower than 2.7.0:
# Ignore everything in media, except for the htaccess files
# Also include the Lazy Catalog Images (LCI) .htaccess if that's installed
# (
v-jacob / Mailhog Bash Script (upstart)
Last active December 5, 2018 12:22
Mailhog Bash Script
#!/usr/bin/env bash
echo ">>> Installing Mailhog"
# Download binary from github
wget --quiet -O ~/mailhog
# Make it executable
chmod +x ~/mailhog
ScottCooper92 / gist:ea11b690ba4b1278e049
Created May 4, 2015 22:17
Example of the various YouTube url formats
v-jacob / Mailhog Bash Script (systemd)
Last active January 9, 2023 08:51
Mailhog setup with systemd
#!/usr/bin/env bash
echo ">>> Installing Mailhog"
# Download binary from github
wget --quiet -O ~/mailhog
# Make it executable
chmod +x ~/mailhog
neodigm / zurb_foundation_equalizer_alternative.js
Created May 2, 2017 21:38
Lightweight Zurb Foundation Equalizer alternative
// Lightweight ZF Equalizer alternative
// Will make two or more HTML elements the same height
// Usage: eq2.makeEqual("[data-equalizer-watch='your_pattern']");
var eq2 = {
Mx: 0,
makeEqual: function( data_eqlzr_watch ){
$( data_eqlzr_watch ).each(function(){
eq2.Mx = ( this.clientHeight > eq2.Mx ) ? this.clientHeight : eq2.Mx;
$( data_eqlzr_watch ).css("height", eq2.Mx + "px");
Gustavo-Kuze /
Last active April 9, 2024 18:33
Enable copy and paste in a webpage from the browser console
  allowCopyAndPaste = function(e){
  return true;
  document.addEventListener('copy', allowCopyAndPaste, true);
  document.addEventListener('paste', allowCopyAndPaste, true);
  document.addEventListener('onpaste', allowCopyAndPaste, true);