Skip to content

Instantly share code, notes, and snippets.

Avatar

Isaac Ben Hutta itzikbenh

View GitHub Profile
@itzikbenh
itzikbenh / projectController.php
Last active Jun 18, 2017
Laravel - project update with revision
View projectController.php
<?php
public function update(Request $request, $id)
{
$this->validate($request, [
'number' => 'required',
'client_id' => 'required',
'location_id' => 'required',
'priority_id' => 'required',
'status_id' => 'required',
@itzikbenh
itzikbenh / exampleOne.php
Last active Jan 9, 2020
Datatables Sample
View exampleOne.php
<?php
function athdata_get_companies( WP_REST_Request $request ) {
$draw = $request['draw'];
$start = $request['start']; //Start is the offset
$length = $request['length']; //How many records to show
$column = $request['order'][0]['column']; //Column to orderBy
$dir = $request['order'][0]['dir']; //Direction of orderBy
$searchValue = $request['search']['value']; //Text search value
$args = [
View .block
license: mit
@itzikbenh
itzikbenh / gulpfile.js
Last active Dec 21, 2018
gulp-webpack
View gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var watch = require('gulp-watch');
var browserSync = require('browser-sync');
var csso = require('gulp-csso');
var uglify = require('gulp-uglify');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var postcssAnt = require('postcss-ant');
var webpack = require('webpack');
View register.php
<?php
function api_register_user( WP_REST_Request $request ) {
$username = sanitize_text_field( trim( $request['username'] ) );
$email = sanitize_email( trim( $request['email'] ) );
$password = sanitize_text_field( trim( $request['password'] ) );
$confirm_password = sanitize_text_field( trim( $request['confirm_password'] ) );
$captcha = $request['captcha'];
$errors = [];
if( ! $captcha ) {
@itzikbenh
itzikbenh / admin.js
Last active Dec 21, 2018
Webpack config. Asset files are in assets/src/{js/scss} and they are being compiled to public/{js/css}
View admin.js
import '../scss/admin.scss';
View admin.js
import '../scss/admin.scss';
View media.js
//Helper function for getting the exif data.
function base64ToArrayBuffer (base64) {
base64 = base64.replace(/^data\:([^\;]+)\;base64,/gmi, '');
var binaryString = atob(base64);
var len = binaryString.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes.buffer;
@itzikbenh
itzikbenh / BackupCRM.php
Created Feb 9, 2017
Laravel backup command to amazon S3
View BackupCRM.php
<?php
namespace App\Console\Commands;
use Aws\S3\MultipartUploader;
use Aws\Exception\MultipartUploadException;
use Illuminate\Console\Command;
use Storage;
class BackupCRM extends Command
View table.js
var invoicesTable = $('table.invoices-table').DataTable({
processing: true,
serverSide: true,
lengthChange: true,
rowId: 'id',
"ajax": {
"url": '/invoices',
"dataSrc": "data.data",
data: function ( d ) {
var dateType = $('#dateType').val();