Skip to content

Instantly share code, notes, and snippets.

View SmetDenis's full-sized avatar
🏠
Working at home

Denis Smet SmetDenis

🏠
Working at home
View GitHub Profile
################ copy/replace file to ~/.bash_aliases
################ Tuning bash ###########################################################################################
# Command line history
export HISTCONTROL=ignoredups:ignorespace
export HISTFILESIZE=10000000
export HISTSIZE=1000000
shopt -s histappend # Append to the history file, don't overwrite it
shopt -s checkwinsize # Check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
@SmetDenis
SmetDenis / hosts.md
Created December 13, 2016 10:51
Hosts no advert

127.0.0.1 rad.msn.com

127.0.0.1 apps.skype.com

-Xms600m
-Xmx1g
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
-Xmx4g
@SmetDenis
SmetDenis / .bash_profile
Last active May 30, 2018 13:31
jbzoo bashrc
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
@SmetDenis
SmetDenis / cron.sh
Last active November 23, 2016 12:21
0 0 * * * /some/path/to/a/file.php > $HOME/`date +\%Y\%m\%d\%H\%M\%S`-cron.log 2>&1
jbzoo items:items-import -vvv >> /home/vsem/logs/cron-jbzoo/`date +\%Y-\%m-\%d_\%H-\%M-\%S`-cron.log 2>&1
* * * * * /usr/local/bin/php -c /etc/php.ini ~/cli/jbzoo/vendor/jbzoo/console/bin/jbzoo items:items-import -vvv >> /home/vsem/logs/cron-jbzoo/`date +\%Y-\%m-\%d_\%H-\%M-\%S`-cron.log 2>&1
Я помню правило “хочешь запостить вакансию — приложи к ней что-нибудь интересное” :). Я расскажу историю одного тестового задания. Немного длинную, но, надеюсь, интересную.
У нас в Ecwid все тестовые задания для инженеров выложены открыто на GitHub вот тут — https://github.com/Ecwid/new-job. Можно просто начать делать любую понравившуюся задачу никого не предупреждая, а потом, когда сами будете довольны результатом, поделиться им со мной.
Одно из первых заданий что я придумал был консольный качальщик файлов по HTTP. Оно очень простое и придумывал я его именно с такой мыслью. Пусть, рассуждал я, пока такое простое повисит, а потом-то я, конечно, добавлю крутые задания. Потом-то я ого-го что выдумаю! Такие крутые тестовые выложу, что все ахнут и немедленно побегут их делать, а этот примитивный качальщик я куда-нибудь запрячу и никому больше не буду показывать. Как-то так я тогда думал.
Качальщик нужно сделать действительно очень примитивный. Судите сами — ты ему список ссылок в текстовом файле, а он скачивае
<?php
if(!function_exists('exec')) die('exec function is not available on this server');
if(!$unzip_command = exec('/usr/bin/which unzip')) die();
if(!$dir_handle = opendir(getcwd())) die ('Can\'t open dir');
while(false != ($files = readdir($dir_handle))){
if($files != '.' && $files != '..'){
if(preg_match('/.\.zip/',$files)){
exec("$unzip_command $files",$output);
echo '<b>Unzipping ',$files,' </b><br>';
@SmetDenis
SmetDenis / hexlet.js
Last active September 22, 2016 16:04
Javascript helpers for hexlet courses
const dump = (vars, label) => console.log(label ? label : 'dump', ':', vars);
// Or stringify
const dump = (vars, label = 'dump', prettyPrint = false) => {
if (prettyPrint) {
console.log(`${label}:`, JSON.stringify(vars, null, 3));
} else {
console.log(`${label}:`, vars);
}
};
#!/bin/bash
# Delete all containers
docker rm -f $(docker ps -a -q)
# Delete all images
docker rmi -f $(docker images -q)
# Enter to container
docker run -ti <IMAGE> /bin/bash