Archive for February 2018

Remove duplicates

DELETE FROM main_table USING main_table, main_table e1 WHERE main_table.id > e1.id AND main_table.entity_id = e1.entity_id;

Как правильно установить, настроить и работать перед монитором

Рекомендации с сайта computer-ergonomics.blogspot.com 1. Офисное кресло с подлокотниками. Подлокотники должны быть регулируемыми по высоте, и само кресло должно регулироваться по высоте и наклону вперед назад. У кресла должна быть специальная поддержка поясничного отдела 2. Расположите монитор на расстоянии вытянутой руки. Примечание: Мне все же надо монитор распологать на 5 см дальше вытянутой руки. Когда […]

Awk Insert into table

cat file.csv | awk -F, ‘{print "INSERT INTO mytable VALUES ("$1",*"$2"*,"$3");"}’ echo https://api.trustpilot.com/tagname/tags | awk -F/ ‘{print $2}’

Docker run new container

1. Run docker bash in server mode for latest ubuntu image, with port proxying external 80 to internal 3128, under name myhub, passing through external folder /home/imran docker run -d -t -p 81:3128 -v /home/imran/Projects:/home –name mycontainer ubuntu:latest /bin/bash Output: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES eea3ed22b802 ubuntu:latest "/bin/bash" 6 seconds ago Up […]

Docker Basic Instructions

Docker Image – Read only layer Docker Container – Read/Write layer 1. Run docker bash in interactive mode for latest ubuntu image docker run -i -t ubuntu:latest /bin/bash 2. Run docker bash in server mode for latest ubuntu image docker run -d -t ubuntu:latest /bin/bash 3. Check running containers docker ps Output: CONTAINER ID IMAGE […]

Git tag

Add new tag: git tag -a 1.1.0 -m "Version 1.1.0"; git push –tags List tags: git tag Delete local tag: git tag -d 1.0 Delete remote tag: git push origin :refs/tags/1.0

Laravel install particular version

composer create-project laravel/laravel myproject 5.1

Php double exclamation operator (!!) or double not operator

The right ! will result in a boolean, regardless of the operand. Then the left ! will be applied to that boolean. It means if $row has a truthy value, it will return true, otherwise false, converting to a boolean value. It is equalent of casting to boolean as it convert anything to boolean. return […]

Java keeping config values in property file

1. File Simple.java import java.io.FileInputStream; import java.util.Properties; import java.io.IOException; import java.io.FileNotFoundException;   class Simple {   public static void main(String[] args) {   try {   Properties config = new Properties();   String configFile = "config.properties"; FileInputStream input = new FileInputStream("config.properties");   config.load(input);   String valueStr = config.getProperty("textlocal_key"); System.out.println(valueStr);   } catch (FileNotFoundException e) { […]

Laravel new console command

1. Create php artisan make:command MyApp –command=myapp:perform 2. Edit vi app/Console/Commands/MyApp.php …. /** * Execute the console command. * * @return mixed */ public function handle() { echo ‘My App’; } 3. Run php artisan myapp:perform