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 / gist:c43326c610bf0e464739
Last active December 23, 2016 12:09
Convert Unicode String to Array by character
<?php
$string = "U li cốt đây lày";
$array = preg_split('/(?<!^)(?!$)/u', $string);
print_r($array);
@tieutantan
tieutantan / gist:9fbe09c644c6230c27f2
Last active December 23, 2016 15:16
convert unicode string to reverse
<?php
function utf8_string_reverse($string){
preg_match_all('/./us', $string, $array);
return implode('',array_reverse($array[0]));
}
@tieutantan
tieutantan / gist:261c3eee0e694d9f34f9
Last active December 23, 2016 12:06
Hide iframe and only show iframe after iframe load success.
<iframe style="visibility:hidden;" onload="this.style.visibility = 'visible';" src="../examples/inlineframes1.html" > </iframe>
@tieutantan
tieutantan / gist:5337c084905bf23ec72e
Last active December 23, 2016 12:17
Set iframe show on x,y positioning ?
via CSS - http://jsfiddle.net/sNSMw/
via JS - You might want to put this part in the BODY tag, not the IFRAME tag: onload="window.frames.scrollTo(300,300)"
<iframe name="itunes" src="http://itunes.apple.com/us/album/threads/id” frameborder="0" width="500" height="600" onload="window.frames['itunes'].scrollTo(250,250)"></iframe>
@tieutantan
tieutantan / gist:26beaeba728c08d91ab3
Last active December 23, 2016 12:04
PHP remove all attribuite from html tag
<?php
$str = '
<p class="class_style" style="font-size: medium; line-height: normal; letter-spacing: normal;">content</p>
<span class="another_class_style" style="font-size: medium; line-height: normal; letter-spacing: normal;">content</span>
<ul class="another_class_style" style="background:#006;"></ul>
<li class="another_class_style" style=" list-style:circle; color:#930;">content</li>';
$clean = preg_replace('/ .*".*"/', '', $str);
@tieutantan
tieutantan / file.css
Created January 6, 2017 10:34
Truncate text by HTML, CSS
.truncate_line_text {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.truncate_paragraph_text {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
@tieutantan
tieutantan / file.php
Last active August 12, 2022 12:22
Get substring between two strings PHP
<?php
// https://stackoverflow.com/a/9826656
public static function get_string_between($string, $start, $end)
{
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini == 0)
return '';
$ini += strlen($start);
@tieutantan
tieutantan / file.php
Created January 14, 2017 15:01
Remove non-ascii characters from string in php
<?php
// http://stackoverflow.com/a/8782114
header('Content-Type: text/html; charset=UTF-8');
$str = "abqwrešđčžsff";
$res = preg_replace('/[^\x20-\x7E]/','', $str);
echo "($str)($res)";
@tieutantan
tieutantan / file.js
Last active November 8, 2017 16:40
Standard config TinyMCE for me
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.1/tinymce.min.js"></script>
<script>
tinymce.init({
selector: "textarea#description",
height: 250,
plugins: [
"fullscreen advlist autolink autosave link image lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"table contextmenu directionality emoticons template textcolor paste textcolor colorpicker textpattern"
],
@tieutantan
tieutantan / index.php
Last active November 8, 2017 16:39
Guide use custom Config in FuelPHP
<?php
// load file fuel/app/config/system.php and groupname = name of group config, TRUE = set group config same filename
Config::load('system', 'groupname');
// set value for key active in group groupname
Config::set('groupname.active', 'ok');
// delete key active in group groupname
Config::delete('groupname.active');