Skip to content

Instantly share code, notes, and snippets.

View VishalTaj's full-sized avatar
🎯
Focusing

Vishal Taj PM VishalTaj

🎯
Focusing
  • Kuala Lampur, Malaysia
View GitHub Profile
@VishalTaj
VishalTaj / countires.json
Last active December 12, 2022 14:03
JSON Collection
[
{
"code": "AED",
"name": "UAE Dirham",
"country": "United Arab Emirates",
"countryCode": "AE",
"flag": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAG5SURBVHja7JdLihRBEEBfVqUU6rQNggiCFxA8gswFRNy49gAeQdx4G8HbuHDvRkRUnKxPZ2dGhous6Y9TtavPZmITtYggXsWPSKOqrCkFK8stgAFKoOr1kiKAt8CD76/f/KYYj//u7bPpU28Mn199eGiBLabg7uWLUePLp08mB/j66xvA1gKVSkK9J/29guuxNCZrVX60905qZlD0xvd5XbPvmN22uo+XCFDZXI2Idjt0txuk9TFM+ve7Yk9MAkAPIKSuI3XdoEMX/aQAd4qSfYpHAI0RbVt0FGA/KYAtyvMMaBTUObRpBh2a0E3cgspewkkJQkDqGm3bQfNPL9/PtIQ+cmjC5OqbTaj9qppRcglCAFej3h9H8P9xnBUgCtRNBllYDj0QmxbWAkgxggiktFjg60PosAeMJnQtAIkRq7poBlIfK5cgRBQdzYC1dtLgVVVRluUJgEQo7XH0RminlBDCKUDK99AIwByXs4gcb0JJafaFc7aCjTlktQBIqpiVAPIYas5AcXEx6LCRzaxjKAn4465GjZ1zs13GBngMPAceLbyFfwJfTP8m2PR6SfGAM7eP07UB/g0Aw73uXdMbeJMAAAAASUVORK5CYII="
},
{
"code": "AFN",
@VishalTaj
VishalTaj / colorize.rb
Created October 30, 2022 05:02
colorize
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def black; "\e[30m#{self}\e[0m" end
def red; "\e[31m#{self}\e[0m" end
def green; "\e[32m#{self}\e[0m" end
def brown; "\e[33m#{self}\e[0m" end
def blue; "\e[34m#{self}\e[0m" end
@VishalTaj
VishalTaj / redis-resque-stuff.md
Created June 28, 2022 05:33 — forked from kany/redis-resque-stuff.md
Clearing dead/stuck/zombie Resque workers redis resque delayed_job

$ rails c

Loading development environment (Rails 3.1.3)
1.9.3p0 :002 > Resque::Worker.working.each{|w| w.done_working}

$ redis-cli

# Removes data from your connection's CURRENT database.
@VishalTaj
VishalTaj / Wappalyzer
Created June 8, 2022 07:22
Wappalyzer Json
{
"categories":{
"1":"cms",
"2":"message-boards",
"3":"database-managers",
"4":"documentation-tools",
"5":"widgets",
"6":"web-shops",
"7":"photo-galleries",
"8":"wikis",
@VishalTaj
VishalTaj / response_example.rb
Created March 31, 2022 11:41 — forked from yesnik/response_example.rb
Ruby on Rails request.env variable content
# This is the content of variable request.env
# We get this content in controller:
# class BlogsController < ApplicationController
# def index
# render plain: "Response: #{ YAML::dump(request.env) }"
# end
# end
@VishalTaj
VishalTaj / graphql-proxy.js
Last active September 18, 2022 04:30
Cloudflare Worker acts as a proxy and push to response payload to CF Cache.
async function sha256(message) {
// encode as UTF-8
const msgBuffer = new TextEncoder().encode(message)
// hash the message
const hashBuffer = await crypto.subtle.digest("SHA-256", msgBuffer)
// convert ArrayBuffer to Array
const hashArray = Array.from(new Uint8Array(hashBuffer))
@VishalTaj
VishalTaj / components-AdSlot.js
Last active October 17, 2021 03:37
Next.js GPT
import { useEffect, useState } from 'react'
import { adDevice } from "./lib/dfp/const"
export default function AdSlot (props) {
const { id, customStyle } = props
const [showAdd, setShowAdd] = useState(false)
useEffect(() => {
if ((window.screen.width < 768 && adDevice[id] !== "d") ||
@VishalTaj
VishalTaj / cloudflare_resolver.js
Last active May 27, 2022 05:51
Cloudflare Worker to rewrite the response
async function handleRequest(req) {
const res = await fetch(req)
if (res.status == 404) {
let init = {...res};
init.status = 200;
init.statusText = "OK";
init.webSocket = init.webSocket || undefined;
let response = await (new Response(res.body, init))
console.log('overwrite status', response.status)
@VishalTaj
VishalTaj / chatbot.py
Created February 21, 2021 15:01
Rulebased chat bot.
import re
keywords = {
'greet': ['.*hello.*', '.*hi.*', '.*howdy.*', '.*hullo.*', '.*how-do-you-do.*'],
'track': ['.*shipment.*', '.*track.*', '.*estimated.*delivery.*'],
'tracking_fullfilment': ['.*myorder:*.'],
'stock': ['.*stock.*', '.*out-of-stock.*'],
'stock_fullfilment': ['.*product_stock:.*']
}
@VishalTaj
VishalTaj / phone.rb
Created January 16, 2021 04:42
phone number formatter
class Phone
attr_accessor :num, :code
def initialize(num, code)
self.code = code
self.num = num
end
def to_num
rec = num.gsub(/[^\d]/, '')