Skip to content

Commit

Permalink
2024-07-12 17:12:24.016161 new snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardocerqueira committed Jul 12, 2024
1 parent d2dfd79 commit e87388b
Show file tree
Hide file tree
Showing 21 changed files with 1,133 additions and 546 deletions.
35 changes: 35 additions & 0 deletions seeker/report.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
--------------------------------------------------------------------------------
2024-07-12 17:12:24.016161
--------------------------------------------------------------------------------
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/TelegraphUp.py
deleted: snippet/api.go
deleted: snippet/dash_cards_uneven_grid.py
deleted: snippet/dash_pivot_charts.py
deleted: snippet/main.go
deleted: snippet/smaple_app_with_routes.py
deleted: snippet/surfrider.py

Untracked files:
(use "git add <file>..." to include in what will be committed)
snippet/A29.java
snippet/GPA.py
snippet/bukuserver.sh
snippet/copy_files
snippet/devbox
snippet/enc.py
snippet/example_mssql.py
snippet/fetch_chrome_bypass.py
snippet/record_camera_stream.sh
snippet/shell
snippet/spark-local.py
snippet/timer.py
snippet/vxlan_hp.py

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

--------------------------------------------------------------------------------
2024-07-11 17:12:32.067466
--------------------------------------------------------------------------------
Expand Down
72 changes: 72 additions & 0 deletions seeker/snippet/A29.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//date: 2024-07-12T16:48:43Z
//url: https://api.github.com/gists/30efee98745cf1a8dde390307da4d6a6
//owner: https://api.github.com/users/avii-7

// Max sum in sub-arrays ( 2 )

// Problem Link: https://www.geeksforgeeks.org/problems/max-sum-in-sub-arrays0824/0

// Brute Force Approch

// TC -> O(n * n)
// SC -> O(1)

// Thought Process
// 1. I will generate all the sub-arrays.
// 2. Whenever a new element is inserted into the range, check with smallest and second smallest number.
// 3. After adjusting new number, if sum is greater than maxSum then maxSum will be replaced with sum.

public static long pairWithMaxSum(long arr[], long N)
{
long maxSum = 0;

for (int i = 0; i < N; i++) {

long s = Long.MAX_VALUE, ss = Long.MAX_VALUE;

for (int j = i; j < N; j++) {

if(arr[j] < s) {
ss = s;
s = arr[j];
}
else if (arr[j] < ss) {
ss = arr[j];
}

long tSum = s + ss;

if (tSum > maxSum) {
maxSum = tSum;
}
}
}

return maxSum;
}

// Optimal Approch

// TC-> O(n)
// SC-> O(1)

// Observation
// 1. I found that smallest and second smallest number with in range i...j (where i < j)
// with maximum sum is always contigous (next to one another).

// Thought Process
// 1. According to observation, we only need to find contigous elements whose sum is greater than others contigous elements.

public static long pairWithMaxSum(long arr[], long N)
{
long maxSum = 0;

for (int i = 0; i <= N - 2; i++) {
long tSum = arr[i] + arr[i + 1];
if(tSum > maxSum) {
maxSum = tSum;
}
}

return maxSum;
}
14 changes: 14 additions & 0 deletions seeker/snippet/GPA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#date: 2024-07-12T16:43:12Z
#url: https://api.github.com/gists/7de081cf9ae2073b9603e77eadb242c3
#owner: https://api.github.com/users/MaXVoLD

students = {'Johnny', 'Bilbo', 'Steve', 'Khendrik', 'Aaron'}
grades = [[5, 3, 3, 5, 4], [2, 2, 2, 3], [4, 5, 5, 2], [4, 4, 3], [5, 5, 5, 4, 5]]
gpa = [sum(grades[0]) / len(grades[0]) ,
sum(grades[1]) / len(grades[1]) ,
sum(grades[2]) / len(grades[2]) ,
sum(grades[3]) / len(grades[3]) ,
sum(grades[4]) / len(grades[4]) ,] #Для каждого значения из списка нашел среднее значение. Составил новый список.
sorted_student = sorted(students) #Отсортировал имена по порядку A-Z. Вернул значения множества списком.
dict_gpa = dict(zip(sorted_student , gpa)) #Склеил оба списка между собой и объединил их в словарь.
print(dict_gpa)
56 changes: 0 additions & 56 deletions seeker/snippet/TelegraphUp.py

This file was deleted.

33 changes: 0 additions & 33 deletions seeker/snippet/api.go

This file was deleted.

64 changes: 64 additions & 0 deletions seeker/snippet/bukuserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#date: 2024-07-12T16:49:09Z
#url: https://api.github.com/gists/ef44453f2da72d2f55492b7d4c955d8d
#owner: https://api.github.com/users/LeXofLeviafan

#!/bin/bash
# Usage: `bukuserver` starts up the server, `bukuserver --stop` sends TERM to the already running server
# On startup, the user is offered to choose or create a new DB (cancel both to exit)
# After the server stops (via CTRL+C or `bukuserver --stop`), the choice is given again
# NOTE: requires Zenity to work

: "${BUKUSERVER=$HOME/Work/buku/}" # path to executable, or directory to run from source
: "${VENV:=$HOME/.local/share/bukuserver/venv}" # alternatively, can be set to $BUKUSERVER/venv
BUKU_CONFIG_DIR=~/.local/share/buku

# specify Web-UI settings here
export BUKUSERVER_THEME=slate
export BUKUSERVER_DISABLE_FAVICON=false
export BUKUSERVER_OPEN_IN_NEW_TAB=true


function _settermtitle { echo -en "\033]2;$1\007"; } # changes terminal title

function _select-db {
FILES=( )
while read FILE; do
[ -e "$FILE" ] && FILES+=( "$(basename "${FILE%.db}")" )
done < <(ls -1 "$BUKU_CONFIG_DIR"/{,.}*.db 2>/dev/null | sort)
FILE=
if [ ${#FILES[@]} != 0 ]; then
FILE=`zenity --list --title="Choose DB" --text="(or click Cancel to create new DB)" --column="Name" -- "${FILES[@]}"`
[ "$FILE" ] && echo "$BUKU_CONFIG_DIR/$FILE.db" && return
fi
while true; do
FILE=`zenity --entry --title="Create new DB?" --text="DB name (cannot contain '/'):" --entry-text="bookmarks"`
! [ "$FILE" ] && echo "No name given, qutting" >&2 && return
[[ "$FILE" == *'/'* ]] && zenity --error --text="DB name cannot contain '/'!" && continue
[ -e "$BUKU_CONFIG_DIR/$FILE.db" ] && ! zenity --question --text="'$FILE' exists already. Open anyway?" && continue
echo "$BUKU_CONFIG_DIR/$FILE.db"
return
done
}


if [ "$1" == '--stop' ]; then
PID=`ps -afu "$USER" | grep '/python[^ ]* .*/bukuserver run$' | awk '{print $2}'`
[ "$PID" ] && kill "$PID"
exit
fi

_settermtitle 'bukuserver'

if [ -d "$BUKUSERVER" ]; then
cd "$BUKUSERVER"
python -m venv "$VENV"
. "$VENV/bin/activate"
pip install .[server]
BUKUSERVER='bukuserver'
fi

export BUKUSERVER_DB_FILE=`_select-db`
while [ "$BUKUSERVER_DB_FILE" ]; do
"$BUKUSERVER" run
export BUKUSERVER_DB_FILE=`_select-db`
done
72 changes: 72 additions & 0 deletions seeker/snippet/copy_files
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#date: 2024-07-12T16:53:46Z
#url: https://api.github.com/gists/b1e92b1eb4241818a13d9929fa88021a
#owner: https://api.github.com/users/nyabongo

#!/bin/bash

show_help() {
echo "Usage: $(basename "$0") [-h] [-i pattern] [-e pattern] [-v]"
echo
echo "Options:"
echo " -h Show this help message"
echo " -i pattern Ignore files matching the pattern (e.g., '*.g.dart')"
echo " -e pattern Only include files matching the pattern (e.g., 'index.*')"
echo " -v Enable verbose mode to print files not ignored"
}

ignore_pattern=""
include_pattern=""
verbose=false

while getopts "hi:e:v" opt; do
case $opt in
h)
show_help
exit 0
;;
i)
ignore_pattern="$OPTARG"
;;
e)
include_pattern="$OPTARG"
;;
v)
verbose=true
;;
\?)
show_help
exit 1
;;
esac
done

output=""
while IFS= read -r file; do
# Check if the file matches the ignore pattern
if [[ -n "$ignore_pattern" && "$file" == $ignore_pattern ]]; then
continue
fi

# Check if the file matches the include pattern
if [[ -n "$include_pattern" && ! "$file" == $include_pattern ]]; then
continue
fi

if $verbose; then
echo "Processing file: $file"
fi

file_type=$(file --mime-type -b "$file")
output+="File: $file"$'\n'
output+="Path: $(realpath --relative-to="$(pwd)" "$file")"$'\n'
output+="Contents:"$'\n'
if [[ "$file_type" == text/* ]]; then
output+="\`\`\`"$'\n'
output+="$(cat "$file")"$'\n'
output+="\`\`\`"$'\n'
else
output+="<Binary file, content skipped>"$'\n'
fi
output+=$'\n'$'\n'
done < <(git ls-files)
echo "$output" | xclip -selection clipboard
Loading

0 comments on commit e87388b

Please sign in to comment.