Posted
on February 13, 2018, 2:00 pm,
by admin,
under
docker.
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
Output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
327eb315fd8d ubuntu:latest "/bin/bash" About a minute ago Up About a minute sharp_yonath
2e27eb9e09b6 ubuntu:latest "/bin/bash" 7 minutes ago Up 7 minutes quizzical_jang |
4. Check docker server status
/etc/init.d/docker status
service docker status |
5. Start|Stop|Restart docker server
/etc/init.d/docker start|stop|restart
service docker start|stop|restart |
6. Docker remove image
7. Docker start and stop container
docker start mycontainer
docker stop mycontainer |
8. Docker remove container
9. Docker remove all exiting containers
docker rm $(docker ps -q -f status=exited) |
10. Copy docker log file out of container for debugging purposes
docker cp 04421c5455b9:/var/log/mysql/error.log /home/imran/myimages |
Posted
on February 9, 2018, 2:17 pm,
by admin,
under
git.
Add new tag:
git tag -a 1.1.0 -m "Version 1.1.0";
git push --tags |
List tags:
Delete local tag:
Delete remote tag:
git push origin :refs/tags/1.0 |
Posted
on February 8, 2018, 4:03 pm,
by admin,
under
laravel.
composer create-project laravel/laravel myproject 5.1 |
Posted
on February 5, 2018, 3:16 pm,
by admin,
under
php,
tips.
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.
Another more human, maybe simpler, way to ‘read’ the not not:
The first ‘!’ does 2 things: ‘convert’ the value to boolean, then output its opposite. So it will give true if the value is a ‘falsy’ one.
The second ‘!’ is just to output the opposite of the first.
Posted
on February 5, 2018, 1:54 pm,
by admin,
under
java.
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) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} |
2. Compile and run
javac Simple.java;
java Simple |
Posted
on February 2, 2018, 3:58 pm,
by admin,
under
laravel.
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 |
Posted
on January 30, 2018, 9:48 am,
by admin,
under
java.
Posted
on January 26, 2018, 2:31 pm,
by admin,
under
php.
$data['message'] = 'Simple Message';
$data['status'] = 'success';
header('Content-Type: application/json');
echo json_encode($data); |
Posted
on January 23, 2018, 4:27 pm,
by admin,
under
dictionary,
php.
Abstract class – is something between a regular class and a pure interface. The purpose of this is to provide a kind of template to inherit from and to force the inheriting class to implement the abstract methods.
Interface – is a special case of abstract classes where ALL methods are abstract.
Posted
on January 18, 2018, 9:37 am,
by admin,
under
bash.
Show next line after matched line
grep -A1 searchpattern filename |
Show next 2 lines after matched line
grep -A2 searchpattern filename |
Show previous line after matched line
grep -B1 searchpattern filename |