Skip to content

Instantly share code, notes, and snippets.

View ifirmawan's full-sized avatar
🎯
Focusing

Iwan firmawan ifirmawan

🎯
Focusing
View GitHub Profile
@ifirmawan
ifirmawan / new_mysqli_fetch_bind_param.php
Created March 20, 2018 10:41
Get values from prepare bind param query with new mysqli connection
<?php
$servername = "localhost";
$username = "root";
$password = "secret";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
@ifirmawan
ifirmawan / CostumSql.php
Created April 2, 2018 05:04
Laravel class to get enum values
<?php
namespace App;
use Illuminate\Support\Facades\DB;
class CostumSql {
protected $_table;
public function __construct($table_name){
@ifirmawan
ifirmawan / audio_partial.html
Created April 5, 2018 07:34
Menyalakan bunyi notifikasi melalui jquery
<audio id="notif_audio">
<source src="<?php echo base_url('sounds/notify.ogg');?>" type="audio/ogg">
<source src="<?php echo base_url('sounds/notify.mp3');?>" type="audio/mpeg">
<source src="<?php echo base_url('sounds/notify.wav');?>" type="audio/wav">
</audio>
<button type="button" class="btn-play">
Play !
</button>
@ifirmawan
ifirmawan / odd_even_section.php
Last active May 31, 2018 02:03
Group section with odd even method
<?php $number =1; ?>
@foreach($links as $key => $value)
@if($number % 4 == 1 )
[
@endif
<h1>{{ $number.'-' }}</h1>
@if($number % 4 == 0 && $number > 0)
]
@endif
<?php $number++; ?>
<?php
$route = Route::getCurrentRoute();
$route->prefix; //ex: api/
$route->action['as']; //ex : api.items.index
@ifirmawan
ifirmawan / html_tags_to_text.php
Created July 9, 2018 02:42
Open html file to get content inside the tags
<?php
$file = 'index.html';
$handle = @fopen($file, "r");
$content = '';
if ($handle) {
while (!feof($handle)) {
$buffer = fgetss($handle, 4096);
$content .= $buffer;
}
fclose($handle);
@ifirmawan
ifirmawan / auto-format-date.js
Created July 18, 2018 08:53
input auto set format medium date
$("input[name='birthdate']:first").keyup(function(e){
var key=String.fromCharCode(e.keyCode);
if(!(key>=0&&key<=9))$(this).val($(this).val().substr(0,$(this).val().length-1));
var value=$(this).val();
if(value.length==2||value.length==5)$(this).val($(this).val()+'/');
});
@ifirmawan
ifirmawan / remove_number_from_sentences.php
Created July 18, 2018 13:01
Regex to delete all words containing numbers from a sentence
<?php
$str = 'This is S3F8G m7j34m h98H40D-3D39 90843-432423 LSDF3 4X4it very good 343c3.';;
preg_match_all("/(^[\D]+\s|\s[\D]+\s|\s[\D]+$|^[\D]+$)+/",$str,$result);
$result = implode('',$result[0]);
echo $result;
@ifirmawan
ifirmawan / get_values_inside_html_tags.php
Created July 20, 2018 01:57
Preg match text in php between html tags
<?php
preg_match("'<p class=\"review\">(.*?)</p>'si", $source, $match);
if($match) echo "result=".$match[1];
$(document).ready(function(){
$("#formattedNumberField").on('keyup', function(evt){
if (evt.which != 110 ){//not a fullstop
var n = parseFloat($(this).val().replace(/\,/g,''),10);
$(this).val(n.toLocaleString());
}
});
});