-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2024-08-22 17:12:27.636388 new snippets
- Loading branch information
1 parent
66cf1a6
commit 9698388
Showing
22 changed files
with
633 additions
and
854 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.