Skip to content

Instantly share code, notes, and snippets.

@tuckbloor
tuckbloor / gist:2f403e07bf1aecd1d495
Last active August 29, 2015 14:25
while file exists update the file revision number
$path = public_path() . '/directory/' . $file_name;
$i = 0;
while(file_exists($path)) {
$i++;
if($i == 1) {
$file_name = pathinfo($path, PATHINFO_FILENAME);
$file_extension = pathinfo($path, PATHINFO_EXTENSION);
$file_name = $file_name . '-r' . $i . '.' . $file_extension;
$path = public_path() . '/directory'/' . $file_name;
@tuckbloor
tuckbloor / gist:5fb1f7fa6804ad4c2933
Last active August 29, 2015 14:26
javascript check if file exists in a loop of table rows
$(selector).on('click', '#id or .class name', function() {
var id = $(this).closest('tr').find('#id').val();
//post the id to a url to update
$.post('/url', {
id: id
});
});
setInterval(function () { update() }, 10000);
@tuckbloor
tuckbloor / javascript
Last active August 29, 2015 14:27
How To Open A PDF File With JSONP
<script>
$('.pdf').on('click', function() {
var revision_id = $(this).data('revision');
$.ajax({
url:'URL/?revision_id=' +revision_id,
dataType: 'JSONP',
jsonpCallback: 'callback',
jsonp: 'callback',
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
@tuckbloor
tuckbloor / angular select
Created November 25, 2015 08:36
angular select
<select class="form-control" ng-options="cat.id as cat.name for cat in categories" ng-model="categoryId"></select>
@tuckbloor
tuckbloor / gist:f0af5cc07e5870fcda74
Created January 7, 2016 13:52
angular track index
<div ng-repeat="technician in techniciansArr track by $index">
@tuckbloor
tuckbloor / gist:e385c54537fd6b607690
Created January 9, 2016 09:32
allow access to php
<?php header('Access-Control-Allow-Origin: *'); ?>
@tuckbloor
tuckbloor / gist:fce5b18001c5bba639ab
Created February 15, 2016 07:47
Angular Digest
if(!$scope.$$phase) { $scope.$apply() };
@tuckbloor
tuckbloor / gist:9908ab0f556381bfee2f
Last active March 2, 2016 09:25
angular datepicker instance for multiple datepickers
html
<p class="input-group">
<input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="latestRevision(dValue).date_returned" close-text="Close" datepicker-options="datePicker.options" is-open="datePicker.instances['returned'+dValue.document_id]" />
<span class="input-group-btn">
<button type="button" class="btn btn-sm btn-default no-border" datepicker-options="datePicker.options" close-text="Close" ng-click="datePicker.open($event, 'returned'+dValue.document_id)"><i class="fa fa-calendar"></i></button>
</span>
</p>
js
$scope.datePicker = (function() {
@tuckbloor
tuckbloor / app\User.php
Last active April 19, 2016 08:11
laravel 5.2 user model with jenssegers monngo
<?php
namespace App;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
//use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Auth\Authenticatable as AuthenticableTrait;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;