-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
803 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Snippet | ||
|
||
## Check Internet Connection | ||
|
||
```java | ||
|
||
public Boolean getConnection() { | ||
|
||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | ||
if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || | ||
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) { | ||
//we are connected to a network | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
``` | ||
|
||
## Detect Device Rotation | ||
|
||
```java | ||
|
||
@Override | ||
public void onConfigurationChanged(Configuration newConfig) { | ||
|
||
Log.d(TAG, "config changed"); | ||
super.onConfigurationChanged(newConfig); | ||
int orientation = newConfig.orientation; | ||
if (orientation == Configuration.ORIENTATION_PORTRAIT) { | ||
// restore = true; | ||
Log.d(TAG, "Portrait"); | ||
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { | ||
// restore = true; | ||
Log.d(TAG, "Landscape"); | ||
} | ||
else { | ||
// restore = true; | ||
Log.w(TAG, "other: " + orientation); | ||
} | ||
|
||
} | ||
|
||
|
||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Unit of Measurement | ||
|
||
## Pixel | ||
|
||
Symbol is `px` | ||
|
||
Corresponds to actual pixels on the screen | ||
|
||
## Scale Independent Pixel | ||
|
||
Symbol is `sp` | ||
|
||
This is like the dp unit, but it is also scaled by the user's font size preference. It is recommend you use this unit when specifying font sizes, so they will be adjusted for both the screen density and user's preference. | ||
|
||
Use for Font Size only | ||
|
||
## Density Independent Pixel | ||
|
||
Symbol is `dip` | ||
|
||
An abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion. Note: The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp". | ||
|
||
Use for everything else |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Snippet | ||
|
||
## Background Image + Overlay | ||
|
||
Use gradient linear | ||
|
||
```css | ||
|
||
.desired-bg { | ||
background:linear-gradient( rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.8) ),url(''); | ||
} | ||
|
||
``` | ||
|
||
## Drop shadow on PNG image | ||
|
||
```css | ||
|
||
.img-png-drop-shadow { | ||
-webkit-filter: drop-shadow(5px 5px 5px #222); filter: drop-shadow(5px 5px 5px #222); | ||
} | ||
|
||
``` | ||
|
||
## Common Media Query | ||
|
||
```css | ||
|
||
@media (max-width: 768px ) { | ||
|
||
} | ||
|
||
@media (max-width: 992px) { | ||
|
||
} | ||
|
||
@media (max-width: 1200px) { | ||
|
||
} | ||
|
||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Init | ||
|
||
## Installation | ||
|
||
### Vagrant | ||
|
||
[https://atlas.hashicorp.com/centos/boxes/7](https://atlas.hashicorp.com/centos/boxes/7) | ||
|
||
```txt | ||
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory | ||
``` | ||
|
||
`yum reinstall glibc-common` | ||
|
||
## Fetch all available package | ||
|
||
`yum -y update` | ||
|
||
## Nginx | ||
|
||
[https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7) | ||
|
||
Add CentOS 7 EPEL repository | ||
|
||
`sudo yum install epel-release` | ||
|
||
Install nginx | ||
|
||
`sudo yum install nginx` | ||
|
||
Start Nginx | ||
|
||
`sudo systemctl start nginx` | ||
|
||
Run nginx when server start | ||
|
||
`sudo systemctl enable nginx` | ||
|
||
## Maria DB | ||
|
||
Install Maria DB | ||
|
||
`sudo yum install mariadb-server mariadb` | ||
|
||
Start Maria DB | ||
|
||
`sudo systemctl start mariadb` | ||
|
||
Change root password | ||
|
||
`sudo mysql_secure_installation` | ||
|
||
Run mariadb when server start | ||
|
||
`sudo systemctl enable mariadb` | ||
|
||
## Nano | ||
|
||
Install nano | ||
|
||
`sudo yum install nano` | ||
|
||
## Php | ||
|
||
Install PHP | ||
|
||
Subscribing to the IUS Community Project Repository | ||
|
||
`cd ~` | ||
|
||
`curl 'https://setup.ius.io/' -o setup-ius.sh` | ||
|
||
`sudo bash setup-ius.sh` | ||
|
||
Install PHP | ||
|
||
`sudo yum install php70u-fpm-nginx php70u-cli php70u-mysqlnd` | ||
|
||
Configure PHP | ||
|
||
`sudo nano /etc/php-fpm.d/www.conf` | ||
|
||
Look for the block containing listen = 127.0.0.1:9000, which tells PHP-FPM to listen on the loopback address at port 9000. Comment this line with a semicolon, and uncomment | ||
|
||
`listen = /run/php-fpm/www.sock a few lines below` | ||
|
||
Next, look for the block containing listen.acl_users values, and uncomment listen.acl_users = nginx: | ||
|
||
Next, make sure that Nginx is using the correct socket path to handle PHP files. Start by opening /etc/nginx/conf.d/default.conf | ||
|
||
`sudo nano /etc/nginx/conf.d/php-fpm.conf` | ||
|
||
php-fpm.conf defines an upstream, which can be referenced by other Nginx configuration directives. Inside of the upstream block, use a # to comment out server 127.0.0.1:9000;, and uncomment server unix:/run/php-fpm/www.sock; | ||
|
||
Restart php and nginx | ||
|
||
`sudo systemctl restart php-fpm` | ||
|
||
`sudo systemctl restart nginx` | ||
|
||
Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available | ||
[https://github.com/dotless-de/vagrant-vbguest](https://github.com/dotless-de/vagrant-vbguest) | ||
|
||
## Reference | ||
|
||
* [https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps](https://www.digitalocean.com/community/tutorials/how-to-configure-logging-and-log-rotation-in-nginx-on-an-ubuntu-vps) | ||
* [https://www.linode.com/docs/websites/nginx/how-to-configure-nginx](https://www.linode.com/docs/websites/nginx/how-to-configure-nginx) | ||
* [https://www.godaddy.com/garage/tech/config/how-to-install-and-configure-nginx-on-centos-6/](https://www.godaddy.com/garage/tech/config/how-to-install-and-configure-nginx-on-centos-6/) | ||
* [https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Lamp | ||
|
||
Lamp stand for Linux, Apache, Mysql and Php | ||
|
||
[https://www.atlantic.net/community/howto/install-lamp-centos-6/](https://www.atlantic.net/community/howto/install-lamp-centos-6/) | ||
|
||
## Apache | ||
|
||
Install Apache | ||
|
||
`sudo yum install httpd` | ||
|
||
Start Server | ||
|
||
`sudo service httpd start` | ||
|
||
## Php | ||
|
||
[https://www.mojowill.com/geek/howto-install-php-5-4-5-5-or-5-6-on-centos-6-and-centos-7/](https://www.mojowill.com/geek/howto-install-php-5-4-5-5-or-5-6-on-centos-6-and-centos-7/) | ||
|
||
Check Php package | ||
|
||
`php -m` | ||
|
||
Install MB String extension | ||
|
||
`yum install php-mbstring` | ||
|
||
If exist conflict | ||
|
||
[http://stackoverflow.com/questions/31580464/php-installation-conflicts-on-centos6](http://stackoverflow.com/questions/31580464/php-installation-conflicts-on-centos6) | ||
|
||
install ext dom , restart server afterward, [http://smartwebdeveloper.com/centos/install-the-php-dom-extension-on-centos](http://smartwebdeveloper.com/centos/install-the-php-dom-extension-on-centos) | ||
|
||
`sudo yum install php-xml` | ||
|
||
## Mysql | ||
|
||
Use any below link, skip configure phpmyadmin.conf, those setup will allow only single ip gain access to phpmyadmin | ||
|
||
* [http://www.liquidweb.com/kb/how-to-install-and-configure-phpmyadmin-on-centos-6](http://www.liquidweb.com/kb/how-to-install-and-configure-phpmyadmin-on-centos-6) | ||
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-a-centos-6-4-vps](https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-a-centos-6-4-vps) | ||
|
||
Install Mysql | ||
|
||
`sudo yum install mysql-server` | ||
|
||
Start Mysql | ||
|
||
`sudo service mysqld start` | ||
|
||
Set Mysql root password, set yes to everything | ||
|
||
`/usr/bin/mysql_secure_installation` | ||
|
||
Optional - run httpd and mysql everytime server start | ||
|
||
`sudo chkconfig httpd on` | ||
|
||
`sudo chkconfig mysqld on` | ||
|
||
## PhpMyAdmin | ||
|
||
[http://ask.xmodulo.com/install-phpmyadmin-centos.html](http://ask.xmodulo.com/install-phpmyadmin-centos.html) | ||
|
||
Follow this link instead, granted all url to phpmyadmin, skip blowfish part. | ||
|
||
Add EPEL repo | ||
|
||
`rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm` | ||
|
||
Install PhpMyAdmin | ||
|
||
`yum -y install phpmyadmin` | ||
|
||
Configure PhpMyAdmin | ||
|
||
`nano /etc/httpd/conf.d/phpMyAdmin.conf` | ||
|
||
```conf | ||
<Directory /usr/share/phpMyAdmin/> | ||
AddDefaultCharset UTF-8 | ||
<IfModule mod_authz_core.c> | ||
# Apache 2.4 | ||
<RequireAny> | ||
#Require ip 127.0.0.1 | ||
#Require ip ::1 | ||
Require all granted | ||
</RequireAny> | ||
</IfModule> | ||
<IfModule !mod_authz_core.c> | ||
# Apache 2.2 | ||
Order Deny,Allow | ||
#Deny from All | ||
Allow from 0.0.0.0 | ||
#Allow from ::1 | ||
</IfModule> | ||
</Directory> | ||
<Directory /usr/share/phpMyAdmin/setup/> | ||
<IfModule mod_authz_core.c> | ||
# Apache 2.4 | ||
<RequireAny> | ||
#Require ip 127.0.0.1 | ||
#Require ip ::1 | ||
Require all granted | ||
</RequireAny> | ||
</IfModule> | ||
<IfModule !mod_authz_core.c> | ||
# Apache 2.2 | ||
Order Deny,Allow | ||
#Deny from All | ||
Allow from 0.0.0.0 | ||
#Allow from ::1 | ||
</IfModule> | ||
</Directory> | ||
``` |
Oops, something went wrong.