Skip to content

Instantly share code, notes, and snippets.

@grandmanitou
grandmanitou / TranslateShell.php
Created June 4, 2014 13:02
CakePHP : shell task allowing to import your data in translatable model
<?php
class TranslateShell extends AppShell {
public function main() {
$selection = $this->in('Start to create translated entries?', array('y', 'n', 'q'), 'y');
if (strtolower($selection) === 'y') {
$this->out('Creating entries in i18n table...');
$this->_execute();
}
@grandmanitou
grandmanitou / savetolog.php
Created June 6, 2014 12:26
CakePHP, write in the log
<?php
$this->log($data);
Cakelog::write('error', $data);
// If $data is an array
Cakelog::write('error', print_r($data, true));
?>
@grandmanitou
grandmanitou / gist:3b71a675210987c9202b
Created June 27, 2014 09:35
Extract a frame from a video to use as a thumbnail
ffmpeg -itsoffset -4 -i vts_01_1.mp4 -vcodec mjpeg -vframes 1 -an -f rawvideo vts_01_1.jpg;
.ui-datepicker {
background-color: #fff;
border: 1px solid #66AFE9;
border-radius: 4px;
box-shadow: 0 0 8px rgba(102,175,233,.6);
display: none;
margin-top: 4px;
padding: 10px;
width: 240px;
}
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@grandmanitou
grandmanitou / ChartController.php
Last active April 1, 2019 10:14
Laravel conditional validation
<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use App\Http\Controllers\Controller;
use Validator;
use Illuminate\Support\Fluent;
@grandmanitou
grandmanitou / RegistrationController.php
Created April 1, 2019 12:14
Laravel conditional eloquent condition
<?php
$registrations = Registration::whereDate('created_at', $day)->when($advisor, function($query, $advisor) {
return $query->where('conseiller', $advisor);
})->get();
?>
// Put this near the top of your resources\assets\js\app.js file.
import $ from 'jquery';
window.jQuery = $;
window.$ = $;
// Source:
// https://github.com/webpack/webpack/issues/4258#issuecomment-340240162
@grandmanitou
grandmanitou / page.html
Created May 21, 2019 08:01
Parse all dates in html tags and convert them into translated relative dates using moment.js
<!-- Datetime in iso8601 format -->
Publié <span class="timeago" data-time="2019-05-20T17:54:05+02:00"></span>
@grandmanitou
grandmanitou / custom.js
Created May 23, 2019 14:22
Valider une date au format JJ/MM/AAAA HH:MM avec jQuery validate 1.19.x
// include moment.js
// jquery
// jquery validation
$.validator.addMethod("dateFr", function(value, element) {
return this.optional(element) || moment(value, "DD/MM/YYYY", true).isValid(); ;
}, "Veuillez saisir une date valide au format JJ/MM/AAAA");
$.validator.addMethod("dateTimeFr", function(value, element) {
return this.optional(element) || moment(value, "DD/MM/YYYY HH:mm", true).isValid(); ;