Skip to content

Instantly share code, notes, and snippets.

@renowncoder
renowncoder / json_read.go
Created January 27, 2024 06:42 — forked from sugab/json_read.go
Read JSON File form a filePath. American movies dataset can be found here: https://raw.githubusercontent.com/prust/wikipedia-movie-data/master/movies.json. 200,000+ Jeopardy question dataset can be found here: https://www.reddit.com/r/datasets/comments/1uyd0t/200000_jeopardy_questions_in_a_json_file/.
package main
import (
"encoding/json"
"io/ioutil"
)
func readJSON(fileName string, filter func(map[string]interface{}) bool) []map[string]interface{} {
datas := []map[string]interface{}{}
@renowncoder
renowncoder / main.ts
Created January 25, 2024 07:58 — forked from zicklag/main.ts
Deno TLS Proxy Using Traefik `acme.json` File For Certificates
import { copy } from "https://deno.land/std@0.153.0/streams/conversion.ts";
const DATA_FILE = Deno.args[0];
const LISTEN_PORT = Deno.args[1];
const TARGET_ADDR = Deno.args[2];
const DOMAIN = Deno.args[3];
interface AcmeJsonFile {
letsencrypt: {
Certificates: {
package main
import (
"fmt"
"gorm.io/datatypes"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
@renowncoder
renowncoder / json_map.go
Created January 3, 2024 21:57 — forked from jquiterio/json_map.go
JSONMap definition for gorm
import (
"database/sql/driver"
"encoding/json"
"errors"
"fmt"
"gorm.io/gorm"
"gorm.io/gorm/schema"
)
// JSONMap defiend JSON data type, need to implements driver.Valuer, sql.Scanner interface
@renowncoder
renowncoder / nullHandle_extends.go
Created January 3, 2024 21:46 — forked from rsudip90/nullHandle_extends.go
database rows null handling in go by extending types
package main
import (
"database/sql"
"encoding/json"
"fmt"
"log"
"time"
"github.com/go-sql-driver/mysql"
@renowncoder
renowncoder / README.md
Created January 3, 2024 00:32 — forked from sancar/README.md
An upgradable read write lock for go

And upgradable read write lock for go

UpgradableRWMutex is an enhanced version of the standard sync.RWMutex. It has the all methods sync.RWMutex with exact same semantics. It gives more methods to give upgradable-read feature.

The new semantics for upgradable-read are as follows:

  • Multiple goroutines can get read-lock together with a single upgradable-read-lock.
  • Only one goroutine can have a write-lock and no read-lock/upgradable-read-lock can be acquired in this state.
@renowncoder
renowncoder / docker-iptables-fix.sh
Created January 2, 2024 22:51 — forked from pedrolamas/docker-iptables-fix.sh
Script to fix Docker iptables on Synology NAS
#!/bin/bash
currentAttempt=0
totalAttempts=10
delay=15
while [ $currentAttempt -lt $totalAttempts ]
do
currentAttempt=$(( $currentAttempt + 1 ))
echo "Attempt $currentAttempt of $totalAttempts..."

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@renowncoder
renowncoder / nginx.conf
Created December 19, 2023 20:37 — forked from coltenkrauter/nginx.conf
Nginx configuration for SPAs (Single page applications) such as React or Angular
# https://www.zeolearn.com/magazine/setting-caching-headers-for-a-spa-in-nginx-cache
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
# X-Frame-Options is to prevent from clickJacking attack
add_header X-Frame-Options SAMEORIGIN;
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
import requests
from bs4 import BeautifulSoup
from langchain.schema.runnable import RunnablePassthrough, RunnableLambda
from langchain.utilities import DuckDuckGoSearchAPIWrapper
import json
RESULTS_PER_QUESTION = 3