Skip to content

Instantly share code, notes, and snippets.

View escapeboy's full-sized avatar
🪲
Deploying fresh bugs

Nikola Katsarov escapeboy

🪲
Deploying fresh bugs
View GitHub Profile
@escapeboy
escapeboy / codeigniter-rating-lib.php
Last active October 2, 2020 17:35
CodeIgniter Rating Library + Microdata (optional)
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Rating Library
* Using jQuery Raty plugin to rate products
* @author Nikola Katsarov
* @website http://katsarov.biz
*/
class Rating {
@escapeboy
escapeboy / ci-events-library.php
Created April 26, 2014 17:27
CodeIgniter Event Library
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Logs Library
* Loging some events from user activity
* @author Nikola Katsarov
* @website http://katsarov.biz
*/
class Events {
@escapeboy
escapeboy / laravel-paginator-links-limit
Created January 4, 2015 22:49
Limit laravel paginator links
@escapeboy
escapeboy / truncate-text-preserve-html
Created January 27, 2015 09:40
PHP Truncate text preserving html tags by Jonas Raoni Soares Silva
<?php
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com
function truncate($text, $length, $suffix = '&hellip;', $isHTML = true) {
$i = 0;
$simpleTags=array('br'=>true,'hr'=>true,'input'=>true,'image'=>true,'link'=>true,'meta'=>true);
$tags = array();
if($isHTML){
preg_match_all('/<[^>]+>([^<]*)/', $text, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
foreach($m as $o){
@escapeboy
escapeboy / laravel-truncate-text-preserve-html
Created January 27, 2015 09:43
Laravel truncate text and preserve html tags
<?php
public function substr_text_only($string, $limit, $end='...')
{
$with_html_count = strlen($string);
$without_html_count = strlen(strip_tags($string));
$html_tags_length = $with_html_count-$without_html_count;
return str_limit($string, $limit+$html_tags_length, $end);
}
?>
@escapeboy
escapeboy / Translations_model.php
Last active October 19, 2018 06:17
Laravel method for database driven localization
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Translations extends Model {

Keybase proof

I hereby claim:

  • I am escapeboy on github.
  • I am katsarov (https://keybase.io/katsarov) on keybase.
  • I have a public key ASBBbBICT5LnVLqH025U1NqV1hB5B7zTfWoD8_at-2FGVgo

To claim this, I am signing this object:

<?php namespace ZeroController\Controllers;
use CustomRequest, CustomResponse, CustomModel;
use App\Http\Controllers\Controller;
class ZeroController extends Controller
{
public $list_view, $form_view, $model, $policy;
public $response = 'ZeroController\Responses\ZeroResponse';
@escapeboy
escapeboy / Item.php
Created September 10, 2019 21:11
POS Scanner
<?php
declare(strict_types=1);
namespace Src\PackItems;
final class Item
{
/**
* @var int
*/
@escapeboy
escapeboy / typewriter.js
Created July 18, 2020 18:43
Simple animated input typewriter
let speed = 100;
let input = document.getElementById('searchInput');
let i = 0;
let j = 0;
let texts = [
'Macbook Pro',
'iPhone 11 Pro',
'lorem ipsum im silor daler ipsilom'
];
let text = texts[j];