Skip to content

Instantly share code, notes, and snippets.

View somerongit's full-sized avatar
🐬
Deploying 🚀

Someron Bakuli somerongit

🐬
Deploying 🚀
View GitHub Profile
maps.google.com/?q=lat,lon
maps.google.com/?q=22.215331111111112,88.12334222222222
// Install Typescript at Global Scope
npm install -g typescript
// Prints Current Version Tsc
tsc -v
// Create the tsconfig.json
tsc --init
// Create build
import { tz } from "moment-timezone"
export function IstTimeStrToGmtTimeStr(timeZone: string, h: number, m: number) {
const time = { hour: h, minutes: m }
const timeon = timeZone.split(' ')[1]
tz.setDefault("Etc/UTC")
let user_time = tz(time, timeon).utc().format("HH:mm:ss") //("HH:MM:SS") will not work
const redis = require("redis")
async function main() {
const client = redis.createClient({
socket: {
host: "redis.com",
port: 1338
},
@somerongit
somerongit / dotenv
Created August 25, 2022 09:58
node:internal/modules/cjs/loader:936 throw err; Error: Cannot find module 'dotenv'
npm install dotenv
JS ==> require('dotenv').config()
TS ==> import 'dotenv/config'
process.env.PORT
# Signup into ibm cloud and get your free api keys
# pip install ibm_watson
apikey = 'YOUR WATSON API KEY HERE'
url = 'YOUR WATSON URL HERE'
input_text ='Wir sinken.'
# Authenticate
authenticator = IAMAuthenticator(apikey)
tts = TextToSpeechV1(authenticator=authenticator)
@somerongit
somerongit / trigger.txt
Created July 21, 2022 03:44
Insert trigger to Update another table using PostgreSQL
https://stackoverflow.com/questions/12343984/insert-trigger-to-update-another-table-using-postgresql
Here we have two tables named table1 and table2. Using a trigger I'll update table2 on insertion into table1.\
Create the tables:
CREATE TABLE table1
(
id integer NOT NULL,
name character varying,
CONSTRAINT table1_pkey PRIMARY KEY (id)
@somerongit
somerongit / mail.go
Created July 7, 2022 08:01
Send mail with Golang
package main
import (
"fmt"
"log"
"net/smtp"
// "os"
)
func sendMail() {
import { createTransport } from "nodemailer";
async function sendMail( msg: string) {
var transporter = createTransport({
service: 'gmail',
auth: {
user: GetMailUserId(),
pass: GetMailPass()
}
});
@somerongit
somerongit / PassworHashBcrypt.txt
Created June 22, 2022 07:56
Password Hashing with bcrypt in Type Script
npm i bcrypt@5.0.1 @types/bcrypt@3.0.0
import * as bcrypt from "bcrypt"
function getHash(password: string): string {
const saltRounds = bcrypt.genSaltSync(12)
const hash = bcrypt.hashSync(password,saltRounds)
return hash
}