Skip to content

Instantly share code, notes, and snippets.

View vovanmix's full-sized avatar

Vladimir Mikhaylovskiy vovanmix

  • San Francisco Bay Area
View GitHub Profile
$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
then you can run
$ sudo composer install
  1. Style existing HTML rather than update HTML. Like, with bootstrap modal and buttons - better to use the default html and add style it with sass, because we can later use js components that will generate standard bootstrap elements and it will be hard to customize their HTML

  2. Create CSS classes that will describe semantics of elements and not their appearance. It will help with redesign later. For example, we have all buttons in green color, instead of appending ".green" class to them, better to append "primary-button", and later if we want to make all buttons purple, we just have to change CSS instead of HTML

  3. Change CSS is always more easy than change HTML. Because HTML later got split between dosens of components, but CSS(sass) is always in one place. Even more, HTML components can become reusable, and all too strict class naming will become a problem.

#Main idea Big files with code are very hard to maintain. I suggest to limit files size to 100 +- rows, splitting hard logic to smaller parts and moving them to separate files

#PHP Controllers should serve just as buffer between HTTP interface and the app. They should define Actions and call methods defined in Models, Repositories, Services etc. Processing logic related to handling one single record can be moved to Model. Processing logic related to handling a set of records of one type can be moved to Repository. Logic related to a specific subject can be moved to a separate Service. Common functionalities can be moved to parent abstract classes.

@vovanmix
vovanmix / mod_expires.conf
Last active February 5, 2016 02:44
Expires headers on apache
## run $ a2enmod expires
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
brew install npm
npm install phantom phantomjs -g
<?php
$handle = fopen ("php://stdin","r");
fscanf($handle,"%d",$t);
for($a0 = 0; $a0 < $t; $a0++){
fscanf($handle,"%d %d",$n,$k);
$a_temp = fgets($handle);
$a = explode(" ",$a_temp);
array_walk($a,'intval');
}

0-2 are necessary only if we need a user another that root to run commands for ansible

  1. Create user to run ansible.
adduser test

passwd test
  1. make it possible to run commands as root without a password
@vovanmix
vovanmix / stdin_ruby.rb
Created March 2, 2016 16:47
stdin_ruby.rb
ar1 = gets.strip.split.map {|i| i.to_i}
@vovanmix
vovanmix / mariadb.yml
Last active September 8, 2020 18:59
Install mariadb via ansible on centOS
--- # Install mariadb via ansible on centOS
- hosts: appserver
user: test
sudo: yes
vars:
mysql_root_password: passwd
tasks:
- name: Install MYSQL
yum:
name: mariadb-server #debian: mysql-server
<?php
\DB::listen(function($sql, $bindings, $time) {
var_dump( vsprintf(str_replace("?", "'%s'", $sql), $bindings) );
});