Skip to content

Instantly share code, notes, and snippets.

View rwaddin's full-sized avatar
🖥️
Freelance Full-stack web developer

addin rwaddin

🖥️
Freelance Full-stack web developer
View GitHub Profile
@rwaddin
rwaddin / Child.vue
Last active March 18, 2021 07:31
Parsing data child to parent vuejs with emit
<template>
<div class="child">
<!-- Simplest - call `$emit()` inline-->
<button type="button" name="button" v-on:click="$emit('increment')">Click me to increment!</button>
<!-- set a variable then trigger a method which calls `$emit()` -->
<label for="child-input">Child input: </label>
<input id="child-input" type="text" name="msg" v-model="childMessage" v-on:keyup="emitToParent">
</div>
</template>
@rwaddin
rwaddin / set-active-adminlte.js
Last active May 4, 2021 15:30
set active adminlte
$(document).ready(function(){
/** add active class and stay opened when selected */
let url = window.location;
// for sidebar menu entirely but not cover treeview
$('ul.sidebar-menu a').filter(function() {
return this.href === url.href;
}).parent().addClass('active');
// for treeview
$('ul.treeview-menu a').filter(function() {
@rwaddin
rwaddin / contact_check.php
Last active September 11, 2020 06:54
for update google contact API, with ci 3.1.1 but you can use anywhere :D
<?php
if (! function_exists('contact_check'))
{
function contact_check()
{
$CI =& get_instance();
$client = new Google_Client();
$client->setApplicationName('Whatsapp');
$client->setScopes([
"https://www.google.com/m8/feeds",
<?php
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"){
$config['base_url'] = "https://".$_SERVER['HTTP_HOST'];
}else{
$httphost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "";
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == "https"){
$config['base_url'] = "https://".$httphost;
}else{
$config['base_url'] = "http://".$httphost;
}
@rwaddin
rwaddin / script.js
Created July 10, 2020 03:10
ketika redirect langsung buka tab sesuai url
// 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 July 4, 2020 07:35
add, remove class javascript
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 June 29, 2020 01:53
Membuat kontak pada google menggunakan API offline access
<?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 June 29, 2020 01:49
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
<?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([
<!-- 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">
<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">