Skip to content

Instantly share code, notes, and snippets.

View cretueusebiu's full-sized avatar
🏔️

Eusebiu Cretu cretueusebiu

🏔️
View GitHub Profile
<?php
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
$toRawSql = fn () => addcslashes(array_reduce($this->getBindings(), function ($sql, $binding) {
return preg_replace('/\?/', is_numeric($binding) ? $binding : "'$binding'", $sql, 1);
}, $this->toSql()), '\\');
Builder::macro('toRawSql', $toRawSql);
import Vue from 'vue'
import dialogVue from './dialog.vue'
const Dialog = Vue.extend(dialogVue)
const dialog = (i18n) => {
/**
* Show a dialog.
*
* @param {Object} options
@cretueusebiu
cretueusebiu / objectToFormData.js
Created February 16, 2018 13:22
objectToFormData
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define('objectToFormData', factory) :
(global.objectToFormData = factory());
}(this, (function () { 'use strict';
function isUndefined (value) {
return value === undefined
}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
<?php
class IdentityVerifier
{
const CERT_DOWNLOAD_ERR = 1;
const CERT_PUB_KEY_ERR = 2;
const SIGNATURE_INCORRECT = 3;
const SIGNATURE_ERR = 3;
protected $error = 0;
@cretueusebiu
cretueusebiu / CurrentUserComposer.php
Last active July 14, 2016 21:20
Laravel current user & has title view composers
<?php
namespace App\ViewComposers;
use Illuminate\Contracts\View\View;
use Illuminate\Contracts\Auth\Guard;
class CurrentUserComposer
{
/**
@cretueusebiu
cretueusebiu / pagination.html
Created April 1, 2016 07:15
Pagination with tmpl.
<!-- Pagination Template -->
<script type="text/x-tmpl" id="paginationTemplate">
{% if (o.lastPage > 1) { %}
<ul class="pagination pagination-sm">
<li {% if (o.currentPage === 1) { %} class="disabled" {% } %}>
<a href="#!page={%= o.prevPage %}" data-page="{%= o.prevPage %}" title="Previous">&laquo;</a>
</li>
{% if (o.firstAdjacentPage > 1) { %}
<li><a href="#!page=1" data-page="1">1</a></li>
@cretueusebiu
cretueusebiu / background.php
Created February 19, 2016 21:37
Execute callback in background.
/**
* Execute callback in background.
*
* @param mixed $callback
* @param mixed $finishCallback
* @return mixed
*/
function executeInBackground($callback, $finishCallback = null)
{
ignore_user_abort(true);