Skip to content

Instantly share code, notes, and snippets.

View cyberdev's full-sized avatar
🏠
Working from home

Nasrul Fatoni cyberdev

🏠
Working from home
View GitHub Profile
@cyberdev
cyberdev / copy.bat
Last active December 11, 2020 07:35
Batch command copy file from Quasar Project into Codeigniter 3
@ECHO OFF
SETLOCAL
SET "appdir=path\to\webroot"
SET "srcdir=.\dist\spa"
echo delete files from folders
echo ------------------------
FOR /D %%a IN (%srcdir%\*) DO (
echo .\assets\%%~nxa\*
RD /S /Q "%appdir%\assets\%%~nxa"
)
@cyberdev
cyberdev / gulpfile.js
Created December 22, 2020 16:29
Gulp file for spliting tast on gulp directory
const gulp = require('gulp');
const requireDir = require('require-dir');
// load tasks
requireDir('./gulp', {
recurse: true,
mapValue: function(value) {
if (typeof value === 'object') {
const keys = Object.keys(value);
return keys.map(taskName => {
return gulp.task(taskName, value[taskName])
@cyberdev
cyberdev / jquery.getStylesheet.js
Created December 27, 2020 14:53 — forked from james2doyle/jquery.getStylesheet.js
An implementation of $.getScript but for stylesheets. Call it $.getStylesheet
(function($) {
$.getStylesheet = function (href) {
var $d = $.Deferred();
var $link = $('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: href
}).appendTo('head');
$d.resolve($link);
return $d.promise();
@cyberdev
cyberdev / action.js
Created December 31, 2020 06:17
Commit vuex mutation from another module
export function someAction({ commit }) {
commit(
'notify/setMessage',
{
msgType: 'negative',
msgText: 'someText'
},
{ root: true }
);
}
@cyberdev
cyberdev / code.gs
Created January 21, 2021 08:28
Load data from API and Display it on Google Sheets
/*********************************************************************************************************************************************
* Get data from url
**********************************************************************************************************************************************/
function getData(url){
var options = {
'contentType' : 'application/json',
'headers' : {
'Authorization' : '<token>'
}
};
@cyberdev
cyberdev / api.php
Created February 2, 2021 04:25
CURL method to consume REST API
private function request($endpoint, $method='GET', $body=false) {
$url = "https://example.com$endpoint";
$token = 'API_TOKEN';
$headers = [
"Authorization: Token token=$token",
"Content-Type: application/json";
];
if($body!==false){
if($method=='GET'){
@cyberdev
cyberdev / parseTime.php
Created February 2, 2021 04:55
Parse Time From Slug
private function parseTimeFromSlug($slug){
$re = '/^(.*)([0-2][0-9])(-)([0-5][0-9])$/m';
$subst = '$2:$4';
$result = preg_replace($re, $subst, $slug);
return $result;
}
@cyberdev
cyberdev / hideunhide.gs
Last active February 9, 2021 03:57
Hide & Unhide Sheets Row
//col and row position of status check
const ROW_CHECK = 2
const COL_CHECK = 2
//row and col index to be hide and unhide
const ROW_TO_HIDE = 10
const COL_TO_HIDE = 1
//row count to be hide and unhide
var ROW_HIDE_COUNT = 11
@cyberdev
cyberdev / highlight.js
Last active March 3, 2021 08:48
highlight element with jquery
$.fn.highlight = function() {
$(this).each(function() {
var el = $(this);
el.before("<div/>")
el.prev()
.width(el.width())
.height(el.height())
.css({
"position": "absolute",
"background-color": "#ffff99",
@cyberdev
cyberdev / splitstring.js
Last active March 15, 2021 17:22
Get last split string
//to get id from item_12
var id = className.split('_').pop(); //output 12