Skip to content

Instantly share code, notes, and snippets.

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
@sancar
sancar / README.md
Last active May 23, 2024 09:33
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 / gulpfile.js
Created October 6, 2021 15:35 — forked from dyarfi/gulpfile.js
Gulp 4 gulpfile.js config
const { src, dest, parallel, series, watch } = require('gulp');
// const pug = require('gulp-pug'); // Pug default view template
const twig = require('gulp-twig');
const sass = require('gulp-sass');
const prefix = require('gulp-autoprefixer');
const data = require('gulp-data');
//const minifyCSS = require('gulp-csso');
const sourcemaps = require('gulp-sourcemaps');
const concat = require('gulp-concat');
const plumber = require('gulp-plumber');
@igorbenic
igorbenic / installer-2.php
Last active February 21, 2024 21:34
Working with Custom Tables in WordPress – Installing and Updating | https://ibenic.com
<?php
/**
* Installer class
*/
namespace MyPlugin;
class Installer {
// ... previous code
@renowncoder
renowncoder / UopzTrait.php
Created June 12, 2021 08:10 — forked from jced-artem/UopzTrait.php
Wrapper for php uopz library's functions. Very useful for unit testing for changing function's behaviour in runtime.
<?php
/**
* Trait UopzTrait
*
* Useful wrapper for uopz library's functions
*/
trait UopzTrait
{
/**
@gradosevic
gradosevic / README.md
Created May 27, 2021 10:00 — forked from nichtich/README.md
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)
@EdwardBock
EdwardBock / reading-time-wp-query-extension.php
Last active October 15, 2021 01:06
ReadingTime WP_Query Extension
<?php
namespace PublicFunctionOrg/WordPress/ReadingTime;
add_filter('posts_where', function($where, $wp_query){
$readingTime = $wp_query->get("reading_time", false);
if(is_array($readingTime) && isset($readingTime["compare"]) && isset($readingTime["value"]) ){
$db = new Database();
$value = intval($readingTime["value"]);
$compare = $readingTime["compare"]; // should be sanitized
@LiorB-D
LiorB-D / room.ejs
Created March 25, 2021 19:06
Video Chat - room.ejs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Set the ROOM_ID variable to the roomId that is passed in by server.js -->
<script>
const ROOM_ID = "<%= roomId %>"
</script>
<!-- CDN in the peerJS and socket.io libraries -->
package main
import (
"fmt"
"gorm.io/datatypes"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
@jquiterio
jquiterio / json_map.go
Last active March 11, 2024 19:53
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