Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am scif on github.
* I am scif (https://keybase.io/scif) on keybase.
* I have a public key ASCXKLx2yTqW3j-fq-vqCA9m4WRtezvsd7oStMs9iGkAoAo
To claim this, I am signing this object:
@SCIF
SCIF / readme.md
Last active January 28, 2016 07:56
SleepingOwl admin with experimental relation support and laravel 5.2

First of all: add next section to composer.json:

  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/SCIF/admin"
    }
  ],
@SCIF
SCIF / gist:536185201ebe38727875
Last active December 3, 2015 23:11
Benchmarking trivial object is not null

Preamble

There are a lot of places in code which seems like:

public function getSomeFilteredThings(Someobj $obj = null, Someobj2 $obj2 = null)

It's restrict type by php typehint and we can don't care about type of variable but task of checking is null or object passed still available. Most common methods to check are: if ($obj), if (null === $obj) and if ($obj instanceof Someobj).

@SCIF
SCIF / gist:500a1047fbb5cc29e83d
Created August 20, 2015 07:34
jquery.draftsaver
/**
* fields: array of names of tracked fields. All inputs and textareas by default (selector: ':input')
* always_update: array of names of fields, which will be added to request always. For example: '_token'
*
* @author Zhuravlev Alexander, scif-1986@ya.ru
* @licence MIT, http://opensource.org/licenses/mit-license.php
*/
(function ($) {
$.fn.draftsaver = function (options) {
var settings = $.extend({
@SCIF
SCIF / gist:67253b935d36c66960d6
Created July 19, 2015 06:43
HWI and FOS integration
config.yml:
```
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: %mail_sender_address%
sender_name: %mail_sender_name%
@SCIF
SCIF / Phpdoc inheritance issue
Last active December 22, 2015 10:39
Very strange behavior of most popular IDE's
class t1
{
/**
* According to http://www.phpdoc.org/docs/latest/for-users/phpdoc/types.html#keyword «self» must be correct in that issue. Phpstorm works correct only if sets static, netbeans/aptana doesn't work correct
*
* @return self
*/
public function test()
{
return $this;
<?php
namespace Fuel\Tasks;
class Feedback
{
public function run()
{
\Config::load('db', true);
@SCIF
SCIF / gist:3243759
Created August 3, 2012 02:38
Fuel's paginatin config for building bootstrap-styled pagination
$config = array(
'pagination_url' => 'http://localhost/fuel/welcome/index/',
'total_items' => $count,
'per_page' => $per_page,
'offset' => $offset,
'uri_segment' => 2,
'template' => array(
'wrapper_start' => '<div class="pagination"><ul>',
'wrapper_end' => '</ul></div>',
'page_start' => '',
$total_income = DB::query('SELECT'.
. DB::expr('SUM(total)') .
'FROM `' . DB::table_prefix() . 'bookings`'.
'WHERE `user_id` = ' . $this->template->user_id . ' ' .
'AND `status` != "prospect" ' .
'AND `status` != "cancelled" ' .
'AND `status` != "refunded" '
)->execute()->as_array();
@SCIF
SCIF / FuelPHP: Migration for storing sessions in DB
Created March 3, 2012 17:17
FuelPHP: This migration create sessions table in DB. Syntax for v. 1.1
<?php
namespace Fuel\Migrations;
class Create_sessions
{
public function up()
{
\DBUtil::create_table('sessions', array(
'session_id' => array('constraint' => 40, 'type' => 'varchar', 'null' =>false),