Skip to content

Instantly share code, notes, and snippets.

View AliMilani's full-sized avatar

Ali Milani AliMilani

View GitHub Profile
@AliMilani
AliMilani / postman_test.js
Last active July 22, 2023 08:41
This Postman test extracts the "authorization" and "x-refresh-token" headers from the response and stores them in environment variables "USER_ACCESS_TOKEN" and "USER_REFRESH_TOKEN" if they exist.
// let data = JSON.parse(responseBody);
var authorization = pm.response.headers.get('authorization')
var refreshToken = pm.response.headers.get('x-refresh-token')
if (!authorization) return
if (authorization) pm.environment.set("USER_ACCESS_TOKEN", authorization?.split(' ')[1]);
if (refreshToken) pm.environment.set("USER_REFRESH_TOKEN", refreshToken);
@AliMilani
AliMilani / torob.js
Last active July 7, 2023 15:42
torob
const axios = require("axios");
require("dotenv").config();
const { toToman } = require("./helpers");
class TorobProduct {
/**
* @type {[Object]}
*/
#url;
@AliMilani
AliMilani / regex.js
Created April 16, 2023 12:15
filter persian and english words and numbers
/[^\w\s\-|\u0621-\u064A\u0660-\u0669\u06F0-\u06F9|\u06Af|\u067E|\u0698|\u0686|\u06CC|\u06A9|\u200C]/g
@AliMilani
AliMilani / whois.php
Last active April 15, 2023 08:20 — forked from kshitiz621/whois.php
PHP code to get WHOIS information of a domain
<?php
/*************************************************************************
php easy :: whois lookup script
==========================================================================
Author: php easy code, www.phpeasycode.com
Web Site: http://www.phpeasycode.com
Contact: webmaster@phpeasycode.com
*************************************************************************/
$domain = $_GET['domain'];
/^\S+@\S+\.\S+$/
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@AliMilani
AliMilani / set-gateway-proxy.ps1
Last active February 13, 2023 10:32
set windows and cmd proxy with powershell (default gateway)
# https://martin.hoppenheit.info/blog/2015/set-windows-proxy-with-powershell/
$reg = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$settings = Get-ItemProperty -Path $reg
$port = 10809
# select the gateway ip address from the default route and extract the ip address
$gateway = Get-NetRoute |
where {$_.DestinationPrefix -eq '0.0.0.0/0'} |
select { $_.NextHop }
module.exports = (to = "World!") => {
console.log(`Hello ${to}`);
}
swaggerOptions: {
persistAuthorization: true,
responseInterceptor: function (response) {
if (!response.url.includes("auth/signin")) return response;
const accessToken = response.headers["x-access-token"];
console.log(response, accessToken);
if (!accessToken) return response;
let oldAuth = JSON.parse(localStorage.getItem("authorized"));
if (oldAuth && oldAuth.accessToken) {
oldAuth.accessToken.value = accessToken;