Skip to content

Commit

Permalink
2024-08-22 17:12:27.636388 new snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardocerqueira committed Aug 22, 2024
1 parent 66cf1a6 commit 9698388
Show file tree
Hide file tree
Showing 22 changed files with 633 additions and 854 deletions.
36 changes: 36 additions & 0 deletions seeker/report.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
--------------------------------------------------------------------------------
2024-08-22 17:12:27.636388
--------------------------------------------------------------------------------
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
deleted: snippet/dedup_roaster.py
deleted: snippet/file_to_env.sh
deleted: snippet/hw_m4_fake_math.py
deleted: snippet/hw_m4_true_math.py
deleted: snippet/hw_module_4_1.py
deleted: snippet/install-java.command
deleted: snippet/lab2.py
deleted: snippet/lem2gtif.py
deleted: snippet/lulu.py
deleted: snippet/new_PD.py
deleted: snippet/rockpaperscissors_infinite.py
deleted: snippet/sagemaker_studio_lifecycle_config.sh

Untracked files:
(use "git add <file>..." to include in what will be committed)
snippet/.go
snippet/Merge-XPS-Files.py
snippet/bfs2.py
snippet/check.py
snippet/compress_video
snippet/deepsparse_object_detection_cv2.py
snippet/detect_obfuscation.py
snippet/gradio_app_assistant.py
snippet/setup-ledger.sh

no changes added to commit (use "git add" and/or "git commit -a")

--------------------------------------------------------------------------------
2024-08-21 17:12:04.246171
--------------------------------------------------------------------------------
Expand Down
57 changes: 57 additions & 0 deletions seeker/snippet/.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//date: 2024-08-22T17:06:39Z
//url: https://api.github.com/gists/adeca6f4a4529ea196d5c8b0003220ed
//owner: https://api.github.com/users/vasiliyantufev

package main

import (
"fmt"
"math"
//"strings"
)

type node struct {
val int
lv *node
rv *node
}

func buildTree(depth int, value int, num int) *node {
if depth == 0 || value > num {
return nil
}

fmt.Print(depth)
fmt.Print("|")
fmt.Print(value)
fmt.Print("|")

node := node{val: value}
node.lv = buildTree(depth-1, value*2, num)
node.rv = buildTree(depth-1, value*2+1, num)

return &node
}

func main() {
numVertices := 10
depth := int(math.Log2(float64(numVertices)) + 1)

//changeVertice := "5 7 4 7 8 7"
//changeCount := 6

root := buildTree(depth, 1, numVertices)

fmt.Println("Pre-order traversal:")
preOrderTraversal(root)

}

func preOrderTraversal(root *node) {
if root == nil {
return
}
fmt.Println(root.val)
preOrderTraversal(root.lv)
preOrderTraversal(root.rv)
}
16 changes: 16 additions & 0 deletions seeker/snippet/Merge-XPS-Files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#date: 2024-08-22T16:52:00Z
#url: https://api.github.com/gists/967d657bce67703dc850da1541272d7b
#owner: https://api.github.com/users/aspose-com-gists

from aspose.page.xps import *

# Define the working directory.
data_dir = "./files"
# Initialize the XPS output stream
with open(data_dir + "mergedXPSfiles.xps", "wb") as out_stream:
# Load XPS document from the file by instantiating an instance of the XpsDocument class.
document = XpsDocument(data_dir + "input.xps", XpsLoadOptions())
# Define an array of XPS files which will be merged with the first one.
files_to_merge = [ data_dir + "Demo.xps", data_dir + "sample.xps" ]
# Invoke the merge method to merge the XPS files.
document.merge(files_to_merge, out_stream)
52 changes: 52 additions & 0 deletions seeker/snippet/bfs2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#date: 2024-08-22T17:07:27Z
#url: https://api.github.com/gists/ad2e0810e167c020bacb71a25919c9ba
#owner: https://api.github.com/users/oliviagallucci

from collections import deque

class financialGraph:
def __init__(self):
self.graph = {}

def add_instrument(self, instrument, dependencies):
# add financial instrument and its dependencies to graph
self.graph[instrument] = dependencies

def bfs(self, start_instrument):
visited = set()
queue = deque([start_instrument])

print("bfs traversal:")
while queue:
current_instrument = queue.popleft()

if current_instrument not in visited:
print(current_instrument)

# mark current instrument as visited
visited.add(current_instrument)

# enqueue dependencies for exploration
if current_instrument in self.graph:
queue.extend(self.graph[current_instrument])

# example usage:
if __name__ == "__main__":
# create financial graph
financial_graph = financialGraph()

# add instruments and dependencies to graph
financial_graph.add_instrument("stock A", ["stock B", "option C"])
financial_graph.add_instrument("stock B", ["bond D"])
financial_graph.add_instrument("option C", ["stock D"])
financial_graph.add_instrument("bond D", [])

# perform bfs traversal starting from specific instrument
financial_graph.bfs("stock A")

# bfs traversal:
# stock A
# stock B
# option C
# bond D
# stock D
29 changes: 29 additions & 0 deletions seeker/snippet/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#date: 2024-08-22T17:02:51Z
#url: https://api.github.com/gists/25346ca99e95a509aa8b5e374818253a
#owner: https://api.github.com/users/atiabjobayer

import requests
import json

# API Endpoint and Token
ACCESS_TOKEN = "**********"
CLIENT_ID = "saas_stern_trisso_com"
API_ENDPOINT = "https://askrobot.azurewebsites.net"

response = requests.post(
API_ENDPOINT,
headers={
"Content-Type": "application/json",
"Authorization": "**********"
},
json={
"api": True,
"engine": "answer", # Use "answer" for RAG, "search" for searching
"client": CLIENT_ID,
"question": "What does God want for me?", # Your natural language query
},
)

# Print the raw response and processed data
print(response.text)
response_json_full = json.loads(response.text)oads(response.text)
86 changes: 86 additions & 0 deletions seeker/snippet/compress_video
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#date: 2024-08-22T16:52:52Z
#url: https://api.github.com/gists/1bb1a080547fb13199ae9c8538bc5c4b
#owner: https://api.github.com/users/sharibeast

#!/bin/sh

print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}

get_extension() {
f="${1##*/}"
case "$f" in
.*) get_extension "${f#.}" && return 0 ;;
esac
case "$f" in
.*.*) echo "${f#.}" ;;
*.*) echo "${f#*.}" ;;
*) return 0 ;;
esac
}

get_filepath_without_extension() {
ext=$(get_extension "$1")
echo "${1%."$ext"}"
}

if [ $# -ne 1 ]; then
echo "ERROR: input file is required"
print_usage
exit 1
fi

input_file="$1"
if [ ! -f "$input_file" ]; then
echo "ERROR: input file '$input_file' does not exist"
exit 1
fi

input_file_ext="$(get_extension "$input_file")"
output_file="$(get_filepath_without_extension "$input_file")_compressed.$input_file_ext"

# Default to libx264 and aac for unknown formats
vcodec="libx264"
acodec="aac"
format_opt=""

case $input_file_ext in
mp4)
vcodec="libx264"
acodec="aac"
;;
mov)
vcodec="libx264"
acodec="aac"
format_opt="-f mov"
;;
webm)
vcodec="libvpx-vp9"
acodec="libopus"
;;
mkv)
vcodec="libx265"
acodec="libopus"
;;
avi|flv)
vcodec="libx264"
acodec="aac"
format_opt="-f mp4"
output_file="$(get_filepath_without_extension "$input_file")_compressed.mp4"
;;
*)
echo "WARNING: unsupported video format - trying with default codecs"
;;
esac


echo "compressing video. this could take a while..."
if ffmpeg -i "$input_file" -c:v $vcodec -crf 23 -preset medium -c:a $acodec $format_opt "$output_file"; then
echo "compression completed successfully"
echo "output file: $output_file"
else
echo "ERROR: compression failed"
exit 1
fi
55 changes: 0 additions & 55 deletions seeker/snippet/dedup_roaster.py

This file was deleted.

Loading

0 comments on commit 9698388

Please sign in to comment.