I have moved this over to the Tech Interview Cheat Sheet Repo since a gist is too difficult to maintain as an open source endevaor and there is no way to version it. I have updated below, but I will not be able to keep this one up to date so please checkout the repo instead. The below is just for some preservation for those who stumble across here.
\
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The difficult I do immediately, the impossible takes a little bit longer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$randomCode = bin2hex(openssl_random_pseudo_bytes(30)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
factory('App\User', 10)->create(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
That's always been my approach, at least. If I needed to filter results, I would have a chainable method on my repository that would apply a relatively simple key-value filter. This trait is ripped directly from a current project: | |
trait FilterableTrait | |
{ | |
protected $validFilterableFields = []; | |
protected $filters = []; | |
protected function addFilter($field, $value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After changes committed to your branch, checkout master and pull to get the changes from the repo: | |
git checkout master | |
git pull origin master | |
Then checkout your branch and rebase your changes on master : | |
git checkout RB | |
git rebase master | |
or last two commands in one line: |
Select but without duplicates
SELECT distinct name, email, acception FROM owners WHERE acception = 1 AND date >= 2015-01-01 00:00:00
Calculate total number of records
SELECT SUM([column]) FROM [table];
Count total number of [column]
and group by [category-column]
Problem:
- externalize strings of file into a seprate file
- each time a merge is made
- a request needs to be made Automatically
- create a seprate PR
- pulls all strings from the commited files
- create random variables names for each of these strings
- push them in a seprate predefine file
- replace the strings on the commited files with the generated random variables that are on the predefine file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# TASK: Refactor the following code. | |
# Exception: Do not split code into files. Keep everything in one file. | |
class Zoo { | |
private $animals = []; | |
private $db; |