Skip to content

Instantly share code, notes, and snippets.

View tieutantan's full-sized avatar
🍉
Focusing

Tran Ngoc Tan tieutantan

🍉
Focusing
View GitHub Profile
@tieutantan
tieutantan / file.html
Created November 29, 2018 11:58
Screen Resolution Detector Bootstrap 4
<!-- layout -->
<hr>
<small>
<div class="d-block d-sm-none">xs 576px</div>
<div class="d-none d-sm-block d-md-none">sm ≥ 576px</div>
<div class="d-none d-md-block d-lg-none">md ≥ 768px</div>
<div class="d-none d-lg-block d-xl-none">lg ≥ 992px</div>
<div class="d-none d-xl-block">xl ≥ 1200px</div>
</small>
<hr>
@tieutantan
tieutantan / file.html
Created December 4, 2018 09:19
Display Flex CSS on Bootstrap 4
<div class="col-sm-6 px-0">
<h5>Recent <span class="badge badge-secondary">New</span></h5>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
Cras justo odio
<span class="badge badge-primary badge-pill">12/12/12</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
Dapibus ac facilisis in
<span class="badge badge-primary badge-pill">12/12/12</span>
@tieutantan
tieutantan / file.css
Last active December 4, 2018 11:38
Edit a background color of the elements in Bootstrap 4
.custom-color, .custom-color:hover, .custom-color:active {
background-color: #A3DBFF !important;
border-color: #A3DBFF !important;
}
@tieutantan
tieutantan / .htaccess
Created December 9, 2018 13:06
PHP Function Base Template
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
<FilesMatch "stream\.php|README\.md|composer*">
Order allow,deny
Deny from all
</FilesMatch>
@tieutantan
tieutantan / elasticsearch.repo
Last active December 17, 2018 11:00
Elasticsearch Repository: wget -O /etc/yum.repos.d/elasticsearch.repo https://bit.ly/2QCXXVS
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
@tieutantan
tieutantan / file.html
Created December 18, 2018 17:47
Add Active Navigation Class Based on URL
<nav>
<ul>
<li><a href="http://domain.com/">Home</a></li>
<li><a href="http://domain.com/about/">About</a></li>
<li><a href="http://domain.com/clients/">Clients</a></li>
<li><a href="http://domain.com/contact/">Contact Us</a></li>
</ul>
</nav>
@tieutantan
tieutantan / custom.css
Created December 26, 2018 17:14
Custom btn-xs on Bootstrap 4
/* docs - https://github.com/twbs/bootstrap/issues/21881#issuecomment-341972830 */
.btn-group-xs > .btn, .btn-xs {
padding : .25rem .4rem;
font-size : .875rem;
line-height : .5;
border-radius : .2rem;
}
@tieutantan
tieutantan / check.php
Created January 1, 2019 20:52
PHP - Valid IP and CIDR
<?php
function valid_ip_or_cidr($input)
{
if (is_int(strpos($value, '/')))
{
/*
* https://www.regexpal.com/93987
* if ip_cidr valid return 1, else 0
*/
@tieutantan
tieutantan / index.html
Created January 3, 2019 20:23
Use jQuery Ajax with PHP
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$.ajax({
url:"info.php",
type:'POST',
data:{name:your_name,age:your_age},
dataType:"html",
success:function(res) {
console.log(res);
@tieutantan
tieutantan / get.php
Last active February 15, 2019 13:50
PHP get file size from remote URL without download
<?php
$url = 'https://speed.hetzner.de/100MB.bin';
$url = 'https://speed.hetzner.de/100MB.bin';
$url = 'https://speed.hetzner.de/10GB.bin';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);