Skip to content

Instantly share code, notes, and snippets.

View tzookb's full-sized avatar

Tzook Bar Noy tzookb

View GitHub Profile
@tzookb
tzookb / main.py
Created June 5, 2023 01:28
find waldo in an image
### This file sets up a conversational agent that uses OpenAI's language model and Meta's SAM image segmentation to describe the appearance of Waldo in a given image.
### The user inputs a prompt asking to find Waldo and the agent provides a response with a description of his appearance.
import pathlib
from langchain.agents import initialize_agent
from langchain.llms import OpenAI
from gradio_tools.tools import SAMImageSegmentationTool
from langchain.memory import ConversationBufferMemory
openAiApiKey = "sk-xxxxxxx"
llm = OpenAI(temperature=0, openai_api_key=openAiApiKey)
@tzookb
tzookb / main.py
Created June 5, 2023 01:03
create icons with letters AA, AB, ..., ZZ
from PIL import Image, ImageDraw, ImageFont
# Create a blank image with a white background
width, height = 60, 60
background_color = (255, 255, 255) # White
image = Image.new("RGB", (width, height), background_color)
# Create a draw object
draw = ImageDraw.Draw(image)
@tzookb
tzookb / main.py
Created September 15, 2022 15:02
matchsticks
from typing import Counter, List, Optional
class Solution:
def makesquare(self, matchsticks: List[int]) -> bool:
matchsticks.sort()
perimeter = sum(matchsticks)
if perimeter % 4 > 0:
return False
side = perimeter / 4
// Identify Graph Solution
(function () {
var cordialAccountKey = 'cordialdev';
var traverse = {
advertiserId: "64ea99ec-de50-4c40-ab11-fb064620ab22",
campaignId: "61c8349c-1668-4422-9171-99b2bd4e989b",
};
/**
* will read the cookie value and return that specific cookie name
@tzookb
tzookb / 2sum.md
Last active September 1, 2021 17:48

Given an array of integers nums and an integer target, return values of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.

Example 1:

@tzookb
tzookb / channels-loop.go
Last active April 8, 2021 18:52
run go routines in a loop to get all the values
package main
import "fmt"
type Person struct {
name string
}
func onbg(theChannel chan Person, theName string) {
fmt.Println(theName)
@tzookb
tzookb / main.go
Last active February 22, 2021 22:38
running ads on queue
package main
import (
"fmt"
"time"
)
func handleSpecificAd(wg *sync.WaitGroup, dId int) {
defer wg.Done()
@tzookb
tzookb / fb.py
Created December 20, 2020 14:19
fb marketing api - agency
def claim_page_to_business(page: Page, business: Business):
"""
We claim the page into the business.
The business is set as agency for the page.
In case the page is already claimed, we will skip the error,
as the result we want to achieve is already set.
"""
try:
# this adds the business through the page
params = {
interface SorterObj {
sorts: string[][],
addSort(by?: string, how?: string): SorterObj;
}
const getSorter = function(): SorterObj {
const modal: SorterObj = {
sorts: [],
addSort: function(this: SorterObj, by: string, how?: string): SorterObj {
if (by) {
@tzookb
tzookb / func.js
Created March 19, 2019 02:17
toggle full screen
const _toggleFullScreen = function _toggleFullScreen() {
if (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement) {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else {
if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else {
if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();