Skip to content

Instantly share code, notes, and snippets.

View qutek's full-sized avatar
💻
Working from home

Lafif Astahdziq qutek

💻
Working from home
View GitHub Profile
@qutek
qutek / readme.md
Created April 20, 2022 19:21
[WebRTC] Play with WebRTC

Playing arround with WebRTC

Open 2 browsers and paste this code to the console

A - Create RTC connection

const peerConnection = new RTCPeerConnection();

peerConnection.onicecandidate = (e) => {
  console.log("Peer A onicecandidate", peerConnection.localDescription);
};
@qutek
qutek / axios.refresh_token.1.js
Created August 12, 2021 14:27 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@qutek
qutek / encryption.js
Created August 8, 2021 10:29 — forked from Tiriel/encryption.js
Symetric encryption/decryption for PHP and NodeJS communication
'use strict';
const crypto = require('crypto');
const AES_METHOD = 'aes-256-cbc';
const IV_LENGTH = 16; // For AES, this is always 16, checked with php
const password = 'lbwyBzfgzUIvXZFShJuikaWvLJhIVq36'; // Must be 256 bytes (32 characters)
function encrypt(text, password) {
@qutek
qutek / export-csv.js
Created July 28, 2021 19:06
Export csv javascript xlsx
const generateCSV = () => {
const wb = XLSX.utils.book_new()
const ws = XLSX.utils.json_to_sheet([{ a: 1, b: 2 }])
XLSX.utils.book_append_sheet(wb, ws, 'test')
XLSX.writeFile(wb, 'test.csv')
}
@qutek
qutek / iframe.html
Created July 10, 2021 16:02 — forked from cirocosta/iframe.html
Sending messages from child iframe to parent webpage
<!DOCTYPE html>
<html>
<head>
<title>My Iframe</title>
</head>
<body>
<button>Botão</button>
<script type="text/javascript">

Aws Cognito: Custom Auth (Developer Authenticated Identities)

How to get OpenID Token & IdentityId from AWS Cognito?

  • example: using bash (aws cli sdk)
  • example: using php (aws php sdk v3.*)

note

  • you need to add example.com as custom auth provider in aws console (cognito/federated)
@qutek
qutek / .gitlab-ci.yml
Last active February 12, 2024 18:26
[Gitlab CI With Rsync] Auto deploy gitlab CI with rsync
# https://gitlab.com/help/ci/quick_start/README
# https://docs.gitlab.com/ee/ci/introduction/
# https://docs.gitlab.com/ee/ci/yaml/
image: dpolyakov/docker-node-latest-with-rsync:latest
# before_script:
# - apt-get update -qq
# - apt-get install -qq git
@qutek
qutek / Steps.md
Created November 29, 2019 09:28
[Install OpenLiteSpeed] Install openlitespeed in mac using Homebrew #server #mac

Install using Homebrew

  • brew tap puleeno/openlitespeed
  • brew install openlitespeed

Directory

  • /usr/local/Cellar/openlitespeed/<version>/

Setup admin password

  • Excute script /usr/local/Cellar/openlitespeed/<version>/admin/misc/admpass.sh
  • Input username and password
@qutek
qutek / clear-node-modules.sh
Last active March 11, 2021 09:46
[Clear Node Modules] Delete all node_modules directory #bash
#!/bin/bash
#
# This script will remove all node modules
#
# Author: Lafif Astahdziq
# https://lafif.me
#
FOLDER_ROOT=${1:-.} # default to current directory
@qutek
qutek / webpack.mix.js
Created September 16, 2019 15:31 — forked from kellymears/webpack.mix.js
[Gutenberg Webpack Mix] #gutenberg #mix #js
const mix = require('laravel-mix');
const url = 'http://lab.tinypixel.test';
const app = './src';
const config = './config';
const resources = './resources';
const assets = './resources/assets';
const dist = './dist';
const externals = {