Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working from home

rwaddin

🏡
Working from home
View GitHub Profile
@rwaddin
rwaddin / script.js
Created Jul 10, 2020
ketika redirect langsung buka tab sesuai url
View script.js
// ref : https://stackoverflow.com/questions/43584707/bootstrap-tab-throws-dataoption-is-not-a-function-error
jQuery(document).ready(function($) {
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
var name = url.split('#')[1]
$('.nav-tabs a[href="#' + name + '"]').tab('show');
}
});
@rwaddin
rwaddin / Manipulate element .js
Created Jul 4, 2020
add, remove class javascript
View Manipulate element .js
var el = this.$refs[index][0]; // your element
if (el.classList.contains("btn-added")) {
el.classList.remove("btn-added")
el.innerHTML = "order"
}else{
el.innerHTML = "batal"
el.classList.add("btn-added")
}
@rwaddin
rwaddin / Create Contact API Google.php
Created Jun 29, 2020
Membuat kontak pada google menggunakan API offline access
View Create Contact API Google.php
<?php
if (! function_exists('contact_create'))
{
function contact_create($params = false)
{
if (isset($params["phone"])) {
$CI =& get_instance();
$nama = $params["nama"];
$phone = formatPhone($params["phone"]);
@rwaddin
rwaddin / Access API Google Offline.php
Created Jun 29, 2020
Cara menggunakan token google dengan offline, di google dev console buat oaut 2 API untuk versi desktop. Kalau oauth versi web setelah login google akan diredirect
View Access API Google Offline.php
<?php
/**
* check ke goole apakah sudah pernah login
* init path ke secret & auth penggunaan offline apps
*/
public function ajx_checkAuth()
{
$client = new Google_Client();
$client->setApplicationName('MyAPP');
$client->setScopes([
View bootstrap modal.html
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
View bootstrap form-horizontal.html
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Email:</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Password:</label>
<div class="col-sm-10">
@rwaddin
rwaddin / Retrieve Contact Google API .php
Created Jun 17, 2020
iam use codeigniter depend composer google api client
View Retrieve Contact Google API .php
<?php
public function index()
{
$google_redirect_uri = 'your url callback';
//setup new google client
$client = new Google_Client();
$client -> setApplicationName('My application name');
$client->setAuthConfigFile("./client_secret.json");
View switch bootstrap 3.html
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
Bootstrap Switch Default
<div class="material-switch pull-right">
<input id="someSwitchOptionDefault" name="someSwitchOption001" type="checkbox"/>
<label for="someSwitchOptionDefault" class="label-default"></label>
</div>
</li>
<li class="list-group-item">
@rwaddin
rwaddin / validasi-email.php
Created May 19, 2020
To validate email with php
View validasi-email.php
<?php
# sample 1
function isValidEmail($email){
return filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
}
# sample2
function isValidEmail($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL)
&& preg_match('/@.+\./', $email);
@rwaddin
rwaddin / swal-confirm.js
Created May 19, 2020
Use sweetalert confirm in v 7x. if you use sweetalert v8x must use Swal.fire()
View swal-confirm.js
swal({title:"Sukses", text :"Setting berhasil dihapus", type : "success", showCancelButton : true}).then((result)=>{
if (result.value) {
location.reload();
}
})
You can’t perform that action at this time.