Skip to content

Instantly share code, notes, and snippets.

@zby
zby / gpt_google.py
Last active September 15, 2023 06:20
chatbot with google search
import requests
import json
from string import Template
#question = input("Enter your question: ")
question = "What was the first major battle in the Ukrainian War?"
# load the api key from a file
with open("config.json", "r") as f:
@zby
zby / object_detection_setup.sh
Last active July 26, 2021 08:57
Installation of Python TensorFlow Object Detection libs
# tested on Ubuntu 20.04 and 21.04
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
# UNZIP INSTALLATION
sudo apt-get -y install unzip
# PYTHON 3 INSTALLATION
@zby
zby / quine.pl
Created October 6, 2012 07:20
a simple perl quine
my $x = 'my $x = X;
$y = chr(39) . $x . chr(39);
$x =~ s/X/$y/;
print $x;
';
$y = chr(39) . $x . chr(39);
$x =~ s/X/$y/;
print $x;
@zby
zby / session-test
Created January 20, 2013 10:27
The referer changes correctly, but the session is first {} and then always: {:x nil}
(ns login-app.ex)
(use 'ring.middleware.session
'ring.util.response)
(defn handl [{session :session uri :uri headers :headers}]
(let [body
(str
"<html><body>"
session "<br>\n"
$ cat src/login_app/core.clj
(ns login-app.core)
(defn handler [request]
{:status 200
:headers {"Content-Type" "text/html"}
:body "Hello World"})
[ snip ]
sub frobnicate {
my( $self, $data ) = @_;
...
$self->twiddle( $data );
...
}
sub twiddle {
my( $self, $data ) = @_;
...
@zby
zby / gist:4509300
Last active December 10, 2015 23:28
while ( my $data = $self->next ) {
my $featues = Text::FeatureCount->new->analyze($data->{content});
sub frobnicate {
#...
my $dbh = MyApp->dbh;
#...
}
# or
sub frobnicate {
#...
@zby
zby / gist:2623798
Created May 6, 2012 18:55
new api writer
Dim f As New FileObject
f.Open(OpenMode.Write, "TextFile.txt")
f.WriteLine("A line of text")
f.Close()
Dim sv As StreamWriter = New StreamWriter("TextFile.txt")
sw.WriteLine("A line of text")
sw.Close()