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
@sedaschle
sedaschle / walksat.py
Created April 30, 2024 20:11
generates 3SAT problems, performs walksat (with timeout, no max-flips param), plots avg number of satisfied problems
import numpy as np
import signal
import matplotlib.pyplot as plt
#########################################################################
######################### 3SAT GENERATION ###############################
# generate 3sat problems
def gen_3sat(c,n):
clauses = [((np.random.randint(1, n+1), np.random.randint(0, 2)),
@sedaschle
sedaschle / pcfg_grammar_aquisition.py
Created April 30, 2024 20:15
given a corpus of sentences & parses, acquires grammar and probabilities for a probabilistic context free grammar
import numpy as np
def read_corpus(filepath):
file = open(filepath, "r")
corpus_lines = []
while True:
content=file.readline()
if not content:
break
corpus_lines.append(content.rstrip())
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Z-Index Example</title>
<style>
html, body { background-color: #00787F; }
.container {
position: relative;
@bmaupin
bmaupin / free-backend-hosting.md
Last active April 30, 2024 20:13
Free backend hosting
@mjkstra
mjkstra / arch_linux_installation_guide.md
Last active April 30, 2024 20:12
A modern, updated installation guide for Arch Linux with BTRFS on an UEFI system
float circ( vec2 p){
return length(p) - 0.3;
}
void pR(inout vec2 p, float a) {
p = cos(a)*p + sin(a)*vec2(p.y, -p.x);
}
// Repeat in two dimensions
vec2 pMod2(inout vec2 p, vec2 size) {
vec2 c = floor((p + size*0.5)/size);
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active April 30, 2024 20:11
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

Note

This no longer works if you're alone in vc! Somebody else has to join you!

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory
@ghuntley
ghuntley / google-ical-backup.sh
Created October 19, 2011 13:21
google calendar backup
#!/bin/bash
#
# Wget's main Google calendar private ical file
#
# Created by: Graham van der Wielen
# Created on: 20100412
### System Setup ###
CP="$(which cp)"
ECHO="$(which echo)"
@mildmojo
mildmojo / rotate_desktop.sh
Created June 18, 2014 06:47
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation