Skip to content

Instantly share code, notes, and snippets.

View sworup's full-sized avatar
🦖
Normal

Sworup Shakya sworup

🦖
Normal
View GitHub Profile
@sworup
sworup / CustomValidation.php
Created May 18, 2016 04:43
Custom validation problem. The 'ip' never gets included in the request input object before it gets validated, hence the validation fails.
<?php
namespace App\Extentions;
use DB;
use Log;
use Illuminate\Validation\Validator;
class CustomValidation extends Validator {
@sworup
sworup / wp01.php
Last active May 4, 2016 05:13
Wordkpress: Add Custom Image Sizes to Media Uploader. https://pippinsplugins.com/add-custom-image-sizes-to-media-uploader/
<?php
function pw_add_image_sizes() {
add_image_size( 'pw-thumb', 300, 100, true );
add_image_size( 'pw-large', 600, 300, true );
}
add_action( 'init', 'pw_add_image_sizes' );
function pw_show_image_sizes($sizes) {
$sizes['pw-thumb'] = __( 'Custom Thumb', 'pippin' );
$sizes['pw-large'] = __( 'Custom Large', 'pippin' );
@sworup
sworup / make directory if doesn't exist.php
Last active May 4, 2016 05:10
Make directory if does not exist (PHP)
<?php
if (!file_exists('path/to/directory')) {
mkdir('path/to/directory', 0777, true);
}
@sworup
sworup / Datepicker Initializer (PHP) (jQuery) (jQuery UI) (Datepicker).php
Last active May 4, 2016 05:11
Datepicker Initializer (PHP) (jQuery) (jQuery UI) (Datepicker)
<?php
function createDateRangeArray($strDateFrom,$strDateTo)
{
// takes two dates formatted as YYYY-MM-DD and creates an
// inclusive array of the dates between the from and to dates.
// could test validity of dates here but I'm already doing
// that in the main script
$aryRange=array();