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 / sphp.sh
Created June 14, 2022 08:17 — forked from rhukster/sphp.sh
Easy Brew PHP version switching
#!/bin/bash
# Creator: Phil Cook
# Modified: Andy Miller
osx_major_version=$(sw_vers -productVersion | cut -d. -f1)
osx_minor_version=$(sw_vers -productVersion | cut -d. -f2)
osx_patch_version=$(sw_vers -productVersion | cut -d. -f3)
osx_patch_version=${osx_patch_version:-0}
osx_version=$((${osx_major_version} * 10000 + ${osx_minor_version} * 100 + ${osx_patch_version}))
homebrew_path=$(brew --prefix)
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')
@qutek
qutek / index.js
Created May 19, 2022 08:06
[Medusa Local File Service] Custom service to upload files / image directly to server #medusajs #nodejs
// src/api/index.js
import express from 'express';
const uploadDir = 'static';
export default () => {
const router = express.Router();
router.use(`/${uploadDir}`, express.static(uploadDir));
@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