Skip to content

Instantly share code, notes, and snippets.

View itzikbenh's full-sized avatar

Isaac Ben Hutta itzikbenh

View GitHub Profile
@itzikbenh
itzikbenh / table.js
Created February 7, 2017 18:57
datatables
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();
@itzikbenh
itzikbenh / BackupCRM.php
Created February 9, 2017 17:36
Laravel backup command to amazon S3
<?php
namespace App\Console\Commands;
use Aws\S3\MultipartUploader;
use Aws\Exception\MultipartUploadException;
use Illuminate\Console\Command;
use Storage;
class BackupCRM extends Command
@itzikbenh
itzikbenh / media.js
Created February 19, 2017 14:51
Test
//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 / admin.js
Created February 27, 2017 01:45
Webpack config
import '../scss/admin.scss';
@itzikbenh
itzikbenh / admin.js
Last active December 21, 2018 06:25
Webpack config. Asset files are in assets/src/{js/scss} and they are being compiled to public/{js/css}
import '../scss/admin.scss';
<?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 / gulpfile.js
Last active December 21, 2018 06:25
gulp-webpack
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');
@itzikbenh
itzikbenh / .block
Created June 3, 2017 13:13
fresh block
license: mit
@itzikbenh
itzikbenh / exampleOne.php
Last active January 9, 2020 20:12
Datatables Sample
<?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 = [
@itzikbenh
itzikbenh / projectController.php
Last active June 18, 2017 00:47
Laravel - project update with revision
<?php
public function update(Request $request, $id)
{
$this->validate($request, [
'number' => 'required',
'client_id' => 'required',
'location_id' => 'required',
'priority_id' => 'required',
'status_id' => 'required',