Skip to content

Instantly share code, notes, and snippets.

View bocharsky-bw's full-sized avatar
💔
#StandWithUkraine 🇺🇦

Victor Bocharsky bocharsky-bw

💔
#StandWithUkraine 🇺🇦
View GitHub Profile
@bocharsky-bw
bocharsky-bw / .htaccess
Created June 19, 2014 10:10
The .htaccess example for Symfony Framework project that deployed on shared hosting.
#path/to/project/.htaccess
# Rewrite all requests to subdirectory, except exists file requests
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /web/$1 [QSA,L]
</IfModule>
@bocharsky-bw
bocharsky-bw / objec-ro-array.php
Last active August 29, 2015 14:02
The method convert current object to array
<?php
/**
* Convert current object to array
*/
public function toArray()
{
$data = array();
foreach (get_object_vars($this) as $property => $value) {
@bocharsky-bw
bocharsky-bw / show-dynamic-content-by-hash.js
Last active August 29, 2015 14:02
Show dynamic content by hash changes
function getDefaultSelector() {
return '.home';
}
function hashToSelector(hash) {
return hash.match(/^#.+/)
? hash.replace(/^#/, '.')
: getDefaultSelector()
;
}
@bocharsky-bw
bocharsky-bw / set-default-column-value.php
Last active August 29, 2015 14:02
Set default column value for
<?php
/**
* @var string $name
*
* @ORM\Column(type="string")
*/
private $name = '';
public function setName($name) {
@bocharsky-bw
bocharsky-bw / multilingual-router.yml
Last active August 29, 2015 14:02
The multilingual router example with excluding default locale from URI for Symfony Framework
home_redirect:
host: "%domain%"
pattern: /%locale%/
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /
permanent: false
home_locale:
host: "%domain%"
@bocharsky-bw
bocharsky-bw / symfony.conf
Last active August 29, 2015 14:02
The Nginx with PHP5-FPM config example for Symfony Framework
server {
listen 80;
server_name symfony.localhost www.symfony.localhost;
root /var/www/symfony/web;
error_log /var/log/nginx/symfony.error.log;
access_log /var/log/nginx/symfony.access.log;
# strip app_dev.php/ prefix if exists
@bocharsky-bw
bocharsky-bw / .htaccess
Created June 3, 2014 09:20
Rewrite all requests to the index.php script, except physical file or folder requests
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php/?(.*)\s [NC]
RewriteRule ^.*$ /%1%2 [R=301,L]
# if the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
@bocharsky-bw
bocharsky-bw / add-user-to-group
Created May 5, 2014 13:46
Add existent user to existent group | Ubuntu
sudo usermod -a -G groupname username
@bocharsky-bw
bocharsky-bw / display-all-errors.php
Last active August 29, 2015 14:00
Display all errors for debug in production
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', true);
@bocharsky-bw
bocharsky-bw / to-top-button.html
Created April 21, 2014 19:22
To top button on JavaScript with jQuery library
<a id="bw_to_top" href="#top" style="
position: fixed;
left: 20px;
bottom: 20px;
display: block;
opacity: 0;
" title="To top">To top</a>
<script type="text/javascript">
var obj = $('#bw_to_top'); // object of to_top button