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
@vovanmix
vovanmix / The Technical Interview Cheat Sheet.md
Created April 16, 2016 07:03 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
  1. install cloudflare_module
https://support.cloudflare.com/hc/en-us/articles/203656534-How-do-I-restore-original-visitor-IP-with-Apache-2-4-

mirght need to change sudo yum install httpd-devel libtool git with sudo yum install httpd24-devel libtool git

  1. put the config file to /etc/httpd/conf.d/cloudflare.conf
CloudFlareRemoteIPHeader X-Forwarded-For
<?php
\DB::listen(function($sql, $bindings, $time) {
var_dump( vsprintf(str_replace("?", "'%s'", $sql), $bindings) );
});
@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
@vovanmix
vovanmix / stdin_ruby.rb
Created March 2, 2016 16:47
stdin_ruby.rb
ar1 = gets.strip.split.map {|i| i.to_i}

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
<?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');
}
brew install npm
npm install phantom phantomjs -g
@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"

#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.