Skip to content

Instantly share code, notes, and snippets.

View avikaco's full-sized avatar

ǟʟʄɨ avikaco

  • Private
  • Jakarta, Indonesia
View GitHub Profile
@avikaco
avikaco / ktp-extractor.js
Created January 28, 2021 09:34
Extract data dari nomer KTP elektronik
/*******************************************************
* #### nik_parse.js ####
* Parse & Validasi Nomor Induk Kependudukan (NIK) KTP
* Coded by @bachors 2018.
* https://github.com/bachors/nik_parse.js
* Updates will be posted to this site.
*******************************************************/
// example:
// const nik = "3204110609970001";
@avikaco
avikaco / global.js
Created March 26, 2020 23:54
catch error and send to Google Analytics
window.addEventListener('error', function (e) {
ga('send', 'exception', {
exDescription: 'JavaScript Error ' + e.message + ' ' + e.filename + ': ' + e.lineno
});
});
jQuery(document).ajaxError(function (e, request, settings) {
ga('send', 'exception', {
exDescription: 'Ajax Error ' + settings.url + ' ' + e.result
});
});
@avikaco
avikaco / functions.php
Created September 20, 2019 08:20
Cara sederhana merubah PHP date ke bahasa indonesia
<?php
function dateIndonesia($formatedDate) {
$patterns = array(
'/January/' => 'Januari',
'/February/' => 'Februari',
'/March/' => 'Maret',
'/May/' => 'Mei',
'/June/' => 'Juni',
'/July/' => 'Juli',
@avikaco
avikaco / hosts
Created January 16, 2019 22:48
Block Ads Domain
# copy code below to your hosts file
## BEGIN BLOCK ADS
127.0.0.1 ad.atdmt.com
127.0.0.1 adclick.g.doublecklick.net
127.0.0.1 adeventtracker.spotify.com
127.0.0.1 adlab.spotify.com
127.0.0.1 adnxs.com
127.0.0.1 adnxs.comadplexmedia.adk2x.com
127.0.0.1 ads-akp.spotify.com
@avikaco
avikaco / regexCheatsheet.js
Created January 10, 2019 23:45 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@avikaco
avikaco / pandas_dataframe_info.py
Created December 14, 2018 13:47
Get dataframe more information
# ... your Python code
def getDataframeInfo(df):
dfInfo = pd.DataFrame(data={'DataFeatures':list(df)})
dfInfo['DataType'] = dfInfo['DataFeatures'].apply(lambda col: df.dtypes[col])
dfInfo['Null'] = dfInfo['DataFeatures'].apply(lambda col: df[col].isnull().sum(axis='index'))
dfInfo['NullPercentage'] = dfInfo['Null'].apply(lambda nullCount: nullCount / df.shape[0])
dfInfo['Unique'] = dfInfo['DataFeatures'].apply(lambda col: df[col].nunique())
dfInfo['UniqueSample'] = dfInfo['DataFeatures'].apply(lambda col: df[col].unique()[0:5])
@avikaco
avikaco / TestController.php
Last active November 16, 2018 21:42
Get Elequent Query
<?php
// ...
$query = User::select('username');
$sql = str_replace('?', '\'%s\'', str_replace('%', '%%', $query->toSql()));
$sql = vsprintf($sql, $query->getBindings());
die($sql);
@avikaco
avikaco / console-example.php
Created May 18, 2018 16:49 — forked from sallar/console-example.php
PHP Colored CLI Output Script.
<?php
// Output screenshot:
// http://cl.ly/NsqF
// -------------------------------------------------------
include_once 'console.php';
// ::log method usage
// -------------------------------------------------------
Console::log('Im Red!', 'red');
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
@avikaco
avikaco / detect-mobile.js
Created December 9, 2013 09:43
Simple code to detect mobile with javascript
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},