Skip to content

Instantly share code, notes, and snippets.

View cawa87's full-sized avatar
🤡
bip bip

Aleksandr Zamiatin cawa87

🤡
bip bip
View GitHub Profile
@cawa87
cawa87 / gist:a512c3d319cfb17470cb
Last active August 29, 2015 14:04
mopa-bootstrap collection.js fix
// Indexes must be different for every Collection
if(typeof this.options.index === 'undefined') {
this.options.index = {};
}
// var elements = $('.collection-items');
//console.log(elements.children().length);
this.options.index[this.options.collection_id] = $('.collection-items').children().length;
<?php
namespace VswSystem\CmsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use VswSystem\CmsBundle\Entity\SliderImage;
use Doctrine\Common\Collections\ArrayCollection;
use VswSystem\CmsBundle\Entity\Traits\IdentificationalEntity;
use VswSystem\CmsBundle\Entity\Traits\NamedEntity;
@cawa87
cawa87 / gist:19e4c7c94e258d812f33
Created September 5, 2014 06:47
Lastest tweets
<?php
$consumerKey = '--------------------';
$consumerSecret = '----------------------';
$accessToken = '-------------------------------------';
$accessTokenSecret = '-----------------------------';
$twitter = new \TwitterPhp\RestApi($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
/*
* Connect as application
@cawa87
cawa87 / gist:69bdeaea476a036b842f
Created September 18, 2014 07:23
pdo create table
<?php
// get params
try{
$dsn = "mysql:host=$host;dbname=$db";
$dbh = new PDO($dsn, $username, $password);
$sql_create_dept_tbl = <<<EOSQL
CREATE TABLE departments(
department_no int(11) NOT NULL AUTO_INCREMENT,
name varchar(255) DEFAULT NULL,
<?php
function mb_ucfirst($string, $encoding)
{
$strlen = mb_strlen($string, $encoding);
$firstChar = mb_substr($string, 0, 1, $encoding);
$then = mb_substr($string, 1, $strlen - 1, $encoding);
return mb_strtoupper($firstChar, $encoding) . $then;
}
<table id="table">
<tr><td class="first_cell rbt rbl ltc">Buto Nr.</td> <td class="a1c st<?php echo $apartments[0]->status; ?> rbt"><?php echo CHtml::link($apartments[0]->id,array('site/apartment2','id'=>$apartments[0]->id)); ?></td> <td class="a2c rbt st<?php echo $apartments[1]->status; ?>"><?php echo CHtml::link($apartments[1]->id,array('site/apartment2','id'=>$apartments[1]->id)); ?></td> <td class="a3c rbt st<?php echo $apartments[2]->status; ?>"><?php echo CHtml::link($apartments[2]->id,array('site/apartment2','id'=>$apartments[2]->id)); ?></td> <td class="a4c st<?php echo $apartments[3]->status; ?> rbr rbt rtc"><?php echo CHtml::link($apartments[3]->id,array('site/apartment2','id'=>$apartments[3]->id)); ?></td> </tr>
<tr><td class="first_cell rbl">Buto statusas</td> <td class="a1c st<?php echo $apartments[0]->status; ?> s<?php echo $apartments[0]->status; ?>"><?php echo CHtml::link($apartments[0]->getStatusName(),array('site/apartment2','id'=>$apartment
@cawa87
cawa87 / gist:057f82ccc143e678a20c
Created November 9, 2014 17:51
psr-4 autoload
<?php
require_once 'Psr4AutoloaderClass.php';
$loader = new Psr4AutoloaderClass;
// регистрируем загрузчик
$loader->register();
// регистрируем базовые директории для префикса пространства имён
$loader->addNamespace('FirstNamespace', './src');
@cawa87
cawa87 / PDOp
Last active August 29, 2015 14:09
pdo class
<?php
class PDOp
{
protected $PDO;
public $numExecutes;
public $numStatements;
public function __construct($dsn, $user=NULL, $pass=NULL, $driver_options=NULL) {
$this->PDO = new PDO($dsn, $user, $pass, $driver_options);
$this->numExecutes = 0;
@cawa87
cawa87 / gist:3c4e3d4b03671d7b4e02
Last active August 29, 2015 14:10
Abstract entity
<?php
namespace VswSystem\CmsBundle\Entity\AbstractEntity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use VswSystem\CmsBundle\Entity\Block;
use VswSystem\CmsBundle\Entity\Traits\IdentificationalEntity;
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>
{{ app_name }} - {% block title %}{% endblock %}
</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- Latest compiled and minified CSS -->