From 43f589a386334c8a444a78cf950ab3480dfc3a3e Mon Sep 17 00:00:00 2001 From: eduardocerqueira Date: Tue, 27 Aug 2024 17:11:39 +0000 Subject: [PATCH] 2024-08-27 17:11:39.834227 new snippets --- seeker/report.txt | 31 ++++ seeker/snippet/3proxy.sh | 144 ++++++++++++++++++ .../Merge Cells in Word using Python.py | 51 +++++++ seeker/snippet/Welcome-to-bulkOS.sh | 10 ++ seeker/snippet/airwork_test.py | 91 +++++++++++ seeker/snippet/airwrk.py | 50 ++++++ seeker/snippet/alpine-container.sh | 82 ++++++++++ seeker/snippet/arch-container.sh | 66 ++++++++ seeker/snippet/asdf.py | 5 + seeker/snippet/bill_req_patient.go | 87 +++++++++++ seeker/snippet/code.py | 47 ++++++ seeker/snippet/git checkout-all-branches.sh | 12 ++ seeker/snippet/install.sh | 19 +++ seeker/snippet/neovim.sh | 17 +++ seeker/snippet/pomo.py | 85 +++++++++++ seeker/snippet/sharepoint_connection.py | 93 +++++++++++ seeker/snippet/slotVerse1withgui.py | 117 ++++++++++++++ seeker/snippet/slotVerse2nogui.py | 107 +++++++++++++ seeker/snippet/ssacli_to_json.py | 52 +++++++ seeker/snippet/thirty_seven.java | 20 +++ seeker/snippet/ubuntu-container.sh | 72 +++++++++ 21 files changed, 1258 insertions(+) create mode 100644 seeker/snippet/3proxy.sh create mode 100644 seeker/snippet/Merge Cells in Word using Python.py create mode 100644 seeker/snippet/Welcome-to-bulkOS.sh create mode 100644 seeker/snippet/airwork_test.py create mode 100644 seeker/snippet/airwrk.py create mode 100644 seeker/snippet/alpine-container.sh create mode 100644 seeker/snippet/arch-container.sh create mode 100644 seeker/snippet/asdf.py create mode 100644 seeker/snippet/bill_req_patient.go create mode 100644 seeker/snippet/code.py create mode 100644 seeker/snippet/git checkout-all-branches.sh create mode 100644 seeker/snippet/install.sh create mode 100644 seeker/snippet/neovim.sh create mode 100644 seeker/snippet/pomo.py create mode 100644 seeker/snippet/sharepoint_connection.py create mode 100644 seeker/snippet/slotVerse1withgui.py create mode 100644 seeker/snippet/slotVerse2nogui.py create mode 100644 seeker/snippet/ssacli_to_json.py create mode 100644 seeker/snippet/thirty_seven.java create mode 100644 seeker/snippet/ubuntu-container.sh diff --git a/seeker/report.txt b/seeker/report.txt index cb79b576..4b899d2d 100644 --- a/seeker/report.txt +++ b/seeker/report.txt @@ -1,3 +1,34 @@ +-------------------------------------------------------------------------------- + 2024-08-27 17:11:39.834227 +-------------------------------------------------------------------------------- + On branch main +Your branch is up to date with 'origin/main'. + +Untracked files: + (use "git add ..." to include in what will be committed) + snippet/3proxy.sh + snippet/Merge Cells in Word using Python.py + snippet/Welcome-to-bulkOS.sh + snippet/airwork_test.py + snippet/airwrk.py + snippet/alpine-container.sh + snippet/arch-container.sh + snippet/asdf.py + snippet/bill_req_patient.go + snippet/code.py + snippet/git checkout-all-branches.sh + snippet/install.sh + snippet/neovim.sh + snippet/pomo.py + snippet/sharepoint_connection.py + snippet/slotVerse1withgui.py + snippet/slotVerse2nogui.py + snippet/ssacli_to_json.py + snippet/thirty_seven.java + snippet/ubuntu-container.sh + +nothing added to commit but untracked files present (use "git add" to track) + -------------------------------------------------------------------------------- 2024-08-26 17:12:12.080171 -------------------------------------------------------------------------------- diff --git a/seeker/snippet/3proxy.sh b/seeker/snippet/3proxy.sh new file mode 100644 index 00000000..f54b75c4 --- /dev/null +++ b/seeker/snippet/3proxy.sh @@ -0,0 +1,144 @@ +#date: 2024-08-27T17:07:26Z +#url: https://api.github.com/gists/bd0eb83b0ac018f200299aa140fbff55 +#owner: https://api.github.com/users/tuwibu + +#!/bin/sh +random() { + tr proxy.txt <$WORKDIR/data.txt +gen_iptables >$WORKDIR/boot_iptables.sh +gen_ifconfig >$WORKDIR/boot_ifconfig.sh +chmod +x ${WORKDIR}/boot_*.sh /etc/rc0.d + +gen_3proxy >/etc/3proxy/3proxy.cfg +ulimit -S -n 4096 +/etc/init.d/3proxy start + +gen_proxy_file_for_user + +#upload_proxy +install_jq && upload_2file \ No newline at end of file diff --git a/seeker/snippet/Merge Cells in Word using Python.py b/seeker/snippet/Merge Cells in Word using Python.py new file mode 100644 index 00000000..3a20539e --- /dev/null +++ b/seeker/snippet/Merge Cells in Word using Python.py @@ -0,0 +1,51 @@ +#date: 2024-08-27T16:59:28Z +#url: https://api.github.com/gists/7f7b7249869b6a11fbba48c57cff19e1 +#owner: https://api.github.com/users/aspose-com-kb + +import aspose.words as aw +import aspose.pydrawing as drawing + +def mergeCells(startCell: aw.tables.Cell, endCell: aw.tables.Cell): + + parentTable = startCell.parent_row.parent_table + + # Find the start and end cell position + startCellPos = drawing.Point(startCell.parent_row.index_of(startCell), parentTable.index_of(startCell.parent_row)) + endCellPos = drawing.Point(endCell.parent_row.index_of(endCell), parentTable.index_of(endCell.parent_row)) + + # Create a range of cells + mergeRange = drawing.Rectangle( + min(startCellPos.x, endCellPos.x), + min(startCellPos.y, endCellPos.y), + abs(endCellPos.x - startCellPos.x) + 1, + abs(endCellPos.y - startCellPos.y) + 1) + + for row in parentTable.rows: + row = row.as_row() + for cell in row.cells: + cell = cell.as_cell() + currentPos = drawing.Point(row.index_of(cell), parentTable.index_of(row)) + + # Merge the cell if inside the range + if mergeRange.contains(currentPos): + cell.cell_format.horizontal_merge = aw.tables.CellMerge.FIRST if currentPos.x == mergeRange.x else aw.tables.CellMerge.PREVIOUS + cell.cell_format.vertical_merge = aw.tables.CellMerge.FIRST if currentPos.y == mergeRange.y else aw.tables.CellMerge.PREVIOUS + +# Load the license +wordLic = aw.License() +wordLic.set_license("license.lic") + +tableDoc = aw.Document("Table.docx") + +table = tableDoc.first_section.body.tables[0] + +# Define start and end cell for the range +cellStartRange = table.rows[0].cells[0] +cellEndRange = table.rows[1].cells[1] + +# Merge cells +mergeCells(cellStartRange, cellEndRange) + +tableDoc.save("output.docx") + +print ("Table cells merged successfully") \ No newline at end of file diff --git a/seeker/snippet/Welcome-to-bulkOS.sh b/seeker/snippet/Welcome-to-bulkOS.sh new file mode 100644 index 00000000..180114c8 --- /dev/null +++ b/seeker/snippet/Welcome-to-bulkOS.sh @@ -0,0 +1,10 @@ +#date: 2024-08-27T17:05:27Z +#url: https://api.github.com/gists/e4b4992a3ea35e5fe5edb687c82b906e +#owner: https://api.github.com/users/rmassaroni + +echo " ________ __ __ __ __ __ _______ _______ " +echo "| | | |.-----.| |.----.-----.--------.-----. | |_.-----. | |--.--.--.| | |--.| | __|" +echo "| | | || -__|| || __| _ | | -__| | _| _ | | _ | | || | < | - |__ |" +echo "|________||_____||__||____|_____|__|__|__|_____| |____|_____| |_____|_____||__|__|__||_______|_______|" +echo -n "by RJM---------------------------------------------------------------------------------------" ; echo "$(date "+%a %b %d %Y")" +echo \ No newline at end of file diff --git a/seeker/snippet/airwork_test.py b/seeker/snippet/airwork_test.py new file mode 100644 index 00000000..125dca3b --- /dev/null +++ b/seeker/snippet/airwork_test.py @@ -0,0 +1,91 @@ +#date: 2024-08-27T16:45:31Z +#url: https://api.github.com/gists/373dd8d79f9319eccd04c979cf2a9396 +#owner: https://api.github.com/users/nahid111 + +from typing import List + +""" +Problem 1: Add Digits +Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. + +Example 1: + +Input: num = 38 +Output: 2 +Explanation: The process is as follows: 3 + 8 = 11, then 1 + 1 = 2. Since 2 has only one digit, 2 is returned. +""" + + +def add_digits(num: int) -> int: + if num == 0: + return num + + num = str(num) + + if len(num) == 1: + return int(num) + + res = 0 + for n in num: + res += int(n) + + return add_digits(res) + + +""" +Problem 2: Contains Duplicate +Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. + +Example 1: + +Input: nums = [1,2,3,1] +Output: true +Explanation: The value 1 appears twice in the array. +""" + + +def contains_duplicate(nums: List[int]) -> bool: + if not nums: + return False + + cache_ = {} + + for i in nums: + if i in cache_: + return True + else: + cache_[i] = 1 + + return False + + +""" +Problem 3: Reverse Vowels of a String +Write a function that takes a string as input and reverses only the vowels of a string. + +Example 1: + +Input: s = "algorithm" +Output: "ilgorathm" +Explanation: The vowels "e" and "o" are reversed. +""" + + +def reverse_vowels(word: str): + if word == "": + return "" + + word = list(word) + vowels = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U'] + left, right = 0, len(word)-1 + + while left < right: + if word[left] in vowels: + for c in range(right, left, -1): + if word[c] in vowels: + word[left], word[c] = word[c], word[left] + right = c-1 + break + left += 1 + return "".join(word) + diff --git a/seeker/snippet/airwrk.py b/seeker/snippet/airwrk.py new file mode 100644 index 00000000..03660173 --- /dev/null +++ b/seeker/snippet/airwrk.py @@ -0,0 +1,50 @@ +#date: 2024-08-27T16:59:54Z +#url: https://api.github.com/gists/aa376db8b841b1d90d9e0c56f6509272 +#owner: https://api.github.com/users/ahmadalsajid + +# Problem 1 +def div_sum(n): + return sum([int(i) for i in list(str(n))]) + +def solution1(num): + while num > 9: + num = div_sum(num) + print(num) + +solution1(num = 38) + + +# Problem 2 +def solution2(nums): + _set = set(nums) + if len(_set) == len(nums): + print('false') + else: + print('true') + +solution2(nums = [1,1,1,3,3,4,3,2,4,2]) + + +# Problem 3 +def solution3(s): + vowels = 'aeiouAEIOU' + _temp_vowels = list() + _temp_string = list() + + for letter in s: + if letter in vowels: + _temp_vowels.append(letter) + _temp_string.append('_') + else: + _temp_string.append(letter) + + _temp_vowels.reverse() + _index = 0 + for _indx, letter in enumerate(_temp_string): + if letter == '_': + _temp_string[_indx] = _temp_vowels[_index] + _index = _index + 1 + + print(''.join(_temp_string)) + +solution3(s = 'algorithm') diff --git a/seeker/snippet/alpine-container.sh b/seeker/snippet/alpine-container.sh new file mode 100644 index 00000000..b30b2e46 --- /dev/null +++ b/seeker/snippet/alpine-container.sh @@ -0,0 +1,82 @@ +#date: 2024-08-27T16:52:24Z +#url: https://api.github.com/gists/52bf52fa78a0aec017cd3dcefb9df41f +#owner: https://api.github.com/users/Lokawn + +#!/bin/bash -e +# Creates a systemd-nspawn container with Alpine + +MIRROR=http://dl-cdn.alpinelinux.org/alpine +VERSION=${VERSION:-v3.20} +APKTOOLS_VERSION=2.14.4-r0 + + +wget_or_curl () { + if command -v wget >/dev/null; then + wget -qO- "$1" + elif command -v curl >/dev/null; then + curl -Ls "$1" + else + echo "missing either curl or wget" >&2 + return 1 + fi +} + +if [ $UID -ne 0 ]; then + echo "run this script as root" >&2 + exit 1 +fi + +dest="$1" +if [ -z "$dest" ]; then + echo "Usage: $0 " >&2 + exit 0 +fi +if [ -e "$dest/usr/bin" ]; then + echo "destination already seems to contain a root file system" >&2 + exit 1 +fi + +if [[ "$(uname -m)" =~ ^i[3456]86|x86 ]]; then + toolarch=x86 + guestarch=$toolarch + [ "$(uname -m)" = x86_64 ] && guestarch=x86_64 +elif [[ "$(uname -m)" =~ ^arm|aarch64 ]]; then + toolarch=armv7 + guestarch=$toolarch + [ "$(uname -m)" = aarch64 ] && guestarch=aarch64 +else + echo "unsupported architecture" >&2 + exit 1 +fi +apkdir=$(mktemp -d) +trap 'rm -rf $apkdir' EXIT + +wget_or_curl "$MIRROR/latest-stable/main/$toolarch/apk-tools-static-$APKTOOLS_VERSION.apk" \ + | tar -xz -C $apkdir || \ + { echo "couldn't download apk-tools, the version might have changed..." >&2; exit 1; } + +$apkdir/sbin/apk.static \ + -X $MIRROR/$VERSION/main -U --arch $guestarch \ + --allow-untrusted --root "$dest" \ + --initdb add alpine-base + +mkdir -p "$dest"/{etc/apk,root} +# configure mirror +printf '%s/%s/main\n%s/%s/community\n' "$MIRROR" $VERSION "$MIRROR" $VERSION >"$dest"/etc/apk/repositories +for i in $(seq 0 10); do # https://github.com/systemd/systemd/issues/852 + echo "pts/$i" >>"$dest/etc/securetty" +done +# make console work +sed '/tty[0-9]:/ s/^/#/' -i "$dest"/etc/inittab +printf 'console::respawn:/sbin/getty 38400 console\n' >>"$dest"/etc/inittab +# minimal boot services +for s in hostname bootmisc syslog; do + ln -s /etc/init.d/$s "$dest"/etc/runlevels/boot/$s +done +for s in killprocs savecache; do + ln -s /etc/init.d/$s "$dest"/etc/runlevels/shutdown/$s +done + + +echo "" +echo "Alpine $VERSION $guestarch container was created successfully." diff --git a/seeker/snippet/arch-container.sh b/seeker/snippet/arch-container.sh new file mode 100644 index 00000000..bb324807 --- /dev/null +++ b/seeker/snippet/arch-container.sh @@ -0,0 +1,66 @@ +#date: 2024-08-27T16:52:24Z +#url: https://api.github.com/gists/52bf52fa78a0aec017cd3dcefb9df41f +#owner: https://api.github.com/users/Lokawn + +#!/bin/bash -e +# Creates a systemd-nspawn container with Arch Linux + +MIRROR=http://mirror.fra10.de.leaseweb.net/archlinux +ISO_DATE=latest +PKG_GROUPS="base" + + +wget_or_curl () { + if command -v wget >/dev/null; then + wget "$1" -O "$2" + elif command -v curl >/dev/null; then + curl -L "$1" -o "$2" + else + echo "missing either curl or wget" >&2 + return 1 + fi +} + +if [ $UID -ne 0 ]; then + echo "run this script as root" >&2 + exit 1 +fi + +dest="$1" +if [ -z "$dest" ]; then + echo "Usage: $0 " >&2 + exit 0 +fi +if [ -e "$dest/usr/bin" ]; then + echo "destination already seems to contain a root file system" >&2 + exit 1 +fi + +[ "$(uname -m)" = x86_64 ] || { echo "unsupported architecture" >&2; exit 1; } +tarfile=$(mktemp) +trap 'rm $tarfile' EXIT + +wget_or_curl "$MIRROR/iso/$ISO_DATE/archlinux-bootstrap-x86_64.tar.gz" $tarfile + +mkdir -p "$dest" +tar -xzf $tarfile -C "$dest" --strip-components=1 --numeric-owner + +# configure mirror +printf 'Server = %s/$repo/os/$arch\n' "$MIRROR" >"$dest"/etc/pacman.d/mirrorlist +sed '/^root: "**********" +rm "$dest/etc/resolv.conf" # systemd configures this +# https://github.com/systemd/systemd/issues/852 +[ -f "$dest/etc/securetty" ] && \ + printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty" +# seems to be this bug https://github.com/systemd/systemd/issues/3611 +systemd-machine-id-setup --root="$dest" +# install the packages +systemd-nspawn -q -D "$dest" sh -c " +pacman-key --init && pacman-key --populate +pacman -Sy --noconfirm --needed ${PKG_GROUPS} +" + + +echo "" +echo "Arch Linux container was created successfully (bootstrapped from $ISO_DATE)" +ssfully (bootstrapped from $ISO_DATE)" diff --git a/seeker/snippet/asdf.py b/seeker/snippet/asdf.py new file mode 100644 index 00000000..5b580538 --- /dev/null +++ b/seeker/snippet/asdf.py @@ -0,0 +1,5 @@ +#date: 2024-08-27T16:53:09Z +#url: https://api.github.com/gists/f8841f027353551fe345fc9b09512701 +#owner: https://api.github.com/users/KeyZox71 + +from math import * diff --git a/seeker/snippet/bill_req_patient.go b/seeker/snippet/bill_req_patient.go new file mode 100644 index 00000000..8d07403e --- /dev/null +++ b/seeker/snippet/bill_req_patient.go @@ -0,0 +1,87 @@ +//date: 2024-08-27T16:59:43Z +//url: https://api.github.com/gists/42d5d3e80b62c284432d3437c3dd2493 +//owner: https://api.github.com/users/ziyuji-pillpack + +package ncpdptypes + +import ( + "time" +) + +// BillReqPatient stores information about the patient that can be provided in a B1 (billing) request. +// See NCPDP D.0, p 67-68. +type BillReqPatient struct { + ID *PatientID `qualifier:"331-CX X(2) optional" field:"332-CY X(20) optional"` + DateOfBirth time.Time `field:"304-C4 9(8)"` + Gender GenderCode `field:"305-C5 9(1)"` + FirstName *string `field:"310-CA X(12) optional"` + LastName string `field:"311-CB X(15)"` + StreetAddress *string `field:"322-CM X(30) optional"` + City *string `field:"323-CN X(20) optional"` + State *StateOrProvinceCode `field:"324-CO X(2) optional"` + Zip *string `field:"325-CP X(15) optional"` + PlaceOfService *PlaceOfServiceCode `field:"307-C7 9(2) optional"` + EmployerID *string `field:"333-CZ X(15) optional"` + PregnancyStatus *PregnancyStatusCode `field:"335-2C X(1) optional"` + PatientResidence *PatientResidenceCode `field:"384-4X 9(2) optional"` + // 326-CQ, 350-HN: not supported because we don't support phone numbers or email addresses + // Note: we don't attempt to validate whether or not EmployerID follows the IRS-specified format. +} + +// PatientID stores an ID for a patient with an associated Kind +type PatientID struct { + Kind PatientIDKind + ID string +} + +// PatientIDKind stores the value of the "Patient ID Qualifier" field (331-CX). +type PatientIDKind eclBase + +// PatientIDKinds stores all valid values of PatientIDKind +var PatientIDKinds = struct { + SSN, + AssignedByLTCFacility, + DriversLicenseNumber, + USMilitaryID, + AssignedByPlan, + AssignedByPlanSSNBased, + MedicaidID, + StateIssuedID, + PassportID, + MedicareBeneficiaryID, + AssignedByEmployer, + AssignedByPayer, + AlienNumber, + StudentVisaNumber, + IndialTribalID, + UPI, + LexID, + Other, + MedicalRecordID PatientIDKind +}{ + SSN: PatientIDKind{"01", "Social Security Number"}, + AssignedByLTCFacility: PatientIDKind{"1J", "Facility ID Number"}, + DriversLicenseNumber: PatientIDKind{"02", "Driver's License Number"}, + USMilitaryID: PatientIDKind{"03", "U.S. Military ID"}, + AssignedByPlan: PatientIDKind{"04", "Non-SSN-based patient identifier assigned by health plan"}, + AssignedByPlanSSNBased: PatientIDKind{"05", "SSN-based patient identifier assigned by health plan"}, + MedicaidID: PatientIDKind{"06", "Medicaid ID"}, + StateIssuedID: PatientIDKind{"07", "State Issued ID"}, + PassportID: PatientIDKind{"08", "Passport ID (or other ID assigned by a national government)"}, + MedicareBeneficiaryID: PatientIDKind{"09", "Medicare Beneficiary ID"}, + AssignedByEmployer: PatientIDKind{"10", "Employer Assigned ID"}, + AssignedByPayer: PatientIDKind{"11", "Payer/PBM Assigned ID"}, + AlienNumber: PatientIDKind{"12", "Alien Number (Government Permanent Residence Number)"}, + StudentVisaNumber: PatientIDKind{"13", "Government Student VISA Number"}, + IndialTribalID: PatientIDKind{"14", "Indian Tribal ID"}, + UPI: PatientIDKind{"15", "NCPDP Universal Patient Identifier (UPI)"}, + LexID: PatientIDKind{"16", "LexID Universal Patient Identifier (UPI)"}, + Other: PatientIDKind{"99", "Other"}, + MedicalRecordID: PatientIDKind{"EA", "Medical Record Identification Number (EHR)"}, +} + +// Values returns a list of all valid values of this type +func (PatientIDKind) Values() values { return valuesFromStruct(PatientIDKinds) } + +// Code returns the serialized value +func (c PatientIDKind) Code() string { return c.code } diff --git a/seeker/snippet/code.py b/seeker/snippet/code.py new file mode 100644 index 00000000..1a404da4 --- /dev/null +++ b/seeker/snippet/code.py @@ -0,0 +1,47 @@ +#date: 2024-08-27T16:47:35Z +#url: https://api.github.com/gists/abf1e2bfe7149309acc3606cc70619a7 +#owner: https://api.github.com/users/ikeji + +print("Starting") + +from kmk.keys import KC +from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard +from kmk.modules.layers import Layers +from kmk.modules.sticky_keys import StickyKeys +from kmk.scanners.keypad import KeysScanner +import board + +_PINS = [ + board.GP2, board.GP6, board.GP10, board.GP13, + board.GP3, board.GP7, board.GP11, board.GP12, +] + +class KMKKeyboard(_KMKKeyboard): + coord_mapping = [ + 0, 1, 2, 3, + 4, 5, 6, 7, + ] + + def __init__(self): + self.matrix = KeysScanner(_PINS) + +keyboard = KMKKeyboard() + +sticky_keys = StickyKeys() + +keyboard.modules.append(Layers()) +keyboard.modules.append(sticky_keys) + +keyboard.keymap = [ + [ + KC.SK(KC.LCTL), KC.LT(1, KC.B), KC.C, KC.D, + KC.E, KC.F, KC.G, KC.H, + ], + [ + KC.I, KC.TRNS, KC.K, KC.L, + KC.M, KC.N, KC.O, KC.P, + ], +] + +if __name__ == '__main__': + keyboard.go() diff --git a/seeker/snippet/git checkout-all-branches.sh b/seeker/snippet/git checkout-all-branches.sh new file mode 100644 index 00000000..ce024f40 --- /dev/null +++ b/seeker/snippet/git checkout-all-branches.sh @@ -0,0 +1,12 @@ +#date: 2024-08-27T17:06:09Z +#url: https://api.github.com/gists/d6a4751a624b92d826c13624930f3354 +#owner: https://api.github.com/users/thiagomiranda3 + +#!/bin/bash + +#Whenever you clone a repo, you do not clone all of its branches by default. +#If you wish to do so, use the following script: + +for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do + git branch --track ${branch#remotes/origin/} $branch +done \ No newline at end of file diff --git a/seeker/snippet/install.sh b/seeker/snippet/install.sh new file mode 100644 index 00000000..08db4ec2 --- /dev/null +++ b/seeker/snippet/install.sh @@ -0,0 +1,19 @@ +#date: 2024-08-27T17:06:11Z +#url: https://api.github.com/gists/231ab631fa3f46152a2db92910d38d4b +#owner: https://api.github.com/users/thatrandomperson5 + +echo "Installing VSCode CLI in $PREFIX/bin" + +ARCHITECTURE=$(lscpu | grep "Architecture" | tr -d " \t\n\r" | cut -c 14-) # Extract the architecture +URL="" + +if ["$ARCHITECTURE" = "arm64"] || ["$ARCHITECTURE" = "aarch64"]; then + URL="https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-arm64" +elif ["$ARCHITECTURE" = "arm32"]; then + URL="https://code.visualstudio.com/sha/download?build=stable&os=cli-linux-armhf" +elif ["$ARCHITECTURE" = "x64"] || ["$ARCHITECTURE" = "x86_64"] || ["$ARCHITECTURE" = "amd64"]; then + URL="https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64" +fi + +curl -sSfL "$URL" -o "$PREFIX/bin/vscode.tar.gz" + diff --git a/seeker/snippet/neovim.sh b/seeker/snippet/neovim.sh new file mode 100644 index 00000000..c45c1f54 --- /dev/null +++ b/seeker/snippet/neovim.sh @@ -0,0 +1,17 @@ +#date: 2024-08-27T16:54:10Z +#url: https://api.github.com/gists/8fcc46f5c40c11636b086b1420c71802 +#owner: https://api.github.com/users/JanGalek + +#!/usr/bin/env sh + +sudo apt-get install ripgrep + +# installs nvm (Node Version Manager) +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash + +wget https://github.com/neovim/neovim/releases/download/v0.10.1/nvim-linux64.tar.gz +tar tar xzvf nvim-linux64.tar.gz +cd nvim-linux64 +sudo cp -R * /usr + +git clone https://github.com/NvChad/starter ~/.config/nvim && nvim \ No newline at end of file diff --git a/seeker/snippet/pomo.py b/seeker/snippet/pomo.py new file mode 100644 index 00000000..04d51991 --- /dev/null +++ b/seeker/snippet/pomo.py @@ -0,0 +1,85 @@ +#date: 2024-08-27T16:59:34Z +#url: https://api.github.com/gists/fbf95eab2ac2c6fa692603254e28aa45 +#owner: https://api.github.com/users/YigitChanson + +import tkinter as tk +from tkinter import messagebox +from tkinter import ttk # tkinter'in standart ttk modülü +import time + +WORK_TIME = 25 * 60 +SHORT_BREAK_TIME = 5 * 60 +LONG_BREAK_TIME = 15 * 60 + +class PomodoroTimer: + def __init__(self): + self.root = tk.Tk() + self.root.geometry("300x300") + self.root.title("Pomodoro Timer") + + self.timer_label = tk.Label(self.root, text="00:00", font=("TkDefaultFont", 40)) + self.timer_label.pack(pady=20) + + self.start_button = ttk.Button(self.root, text="Start", command=self.start_timer) + self.start_button.pack(pady=5) + + self.stop_button = ttk.Button(self.root, text="Stop", command=self.stop_timer, state=tk.DISABLED) + self.stop_button.pack(pady=5) + + self.reset_button = ttk.Button(self.root, text="Reset", command=self.reset_timer, state=tk.DISABLED) + self.reset_button.pack(pady=5) + + self.work_time, self.break_time = WORK_TIME, SHORT_BREAK_TIME + self.is_work_time, self.pomodoros_completed, self.is_running = True, 0, False + + self.root.mainloop() + + def start_timer(self): + self.start_button.config(state=tk.DISABLED) + self.stop_button.config(state=tk.NORMAL) + self.reset_button.config(state=tk.NORMAL) + self.is_running = True + self.update_timer() + + def stop_timer(self): + self.start_button.config(state=tk.NORMAL) + self.stop_button.config(state=tk.DISABLED) + self.reset_button.config(state=tk.NORMAL) + self.is_running = False + + def reset_timer(self): + self.is_running = False + self.start_button.config(state=tk.NORMAL) + self.stop_button.config(state=tk.DISABLED) + self.reset_button.config(state=tk.DISABLED) + self.work_time, self.break_time = WORK_TIME, SHORT_BREAK_TIME + self.is_work_time = True + self.timer_label.config(text="00:00") + + def update_timer(self): + if self.is_running: + if self.is_work_time: + self.work_time -= 1 + minutes, seconds = divmod(self.work_time, 60) + self.timer_label.config(text=f"{minutes:02}:{seconds:02}") + if self.work_time == 0: + self.is_work_time = False + self.pomodoros_completed += 1 + self.break_time = LONG_BREAK_TIME if self.pomodoros_completed % 4 == 0 else SHORT_BREAK_TIME + messagebox.showinfo( + "Good job!", + "Take a long break to rest your mind." if self.pomodoros_completed % 4 == 0 else "Take a short break and stretch your legs" + ) + else: + self.break_time -= 1 + minutes, seconds = divmod(self.break_time, 60) + self.timer_label.config(text=f"{minutes:02}:{seconds:02}") + if self.break_time == 0: + self.is_work_time = True + self.work_time = WORK_TIME + messagebox.showinfo("Break over!", "Time to get back to work!") + + self.root.after(1000, self.update_timer) + + +PomodoroTimer() \ No newline at end of file diff --git a/seeker/snippet/sharepoint_connection.py b/seeker/snippet/sharepoint_connection.py new file mode 100644 index 00000000..4fda16b8 --- /dev/null +++ b/seeker/snippet/sharepoint_connection.py @@ -0,0 +1,93 @@ +#date: 2024-08-27T16:59:37Z +#url: https://api.github.com/gists/f22337768cf3a0f9bb74fca1f8c096b0 +#owner: https://api.github.com/users/luisdelatorre012 + +""" +dynaconf settings + +# settings.toml +[default] +site_name = "Your SharePoint Site Name" + +# .secrets.toml +[default] +client_id = "your_client_id_here" +client_secret = "**********" +tenant_id = "your_tenant_id_here" +""" + +import httpx +from msal import ConfidentialClientApplication +from typing import Optional +from dynaconf import Dynaconf + +# Initialize Dynaconf +settings = Dynaconf( + settings_files= "**********" + environments=True, + load_dotenv=True, +) + +def get_access_token(client_id: "**********": str, tenant_id: str) -> Optional[str]: + authority = f"https://login.microsoftonline.com/{tenant_id}" + app = ConfidentialClientApplication( + client_id, + authority=authority, + client_credential= "**********" + ) + + scopes = ["https://graph.microsoft.com/.default"] + result = "**********"=None) + + if not result: + result = "**********"=scopes) + + "**********" "**********" "**********" "**********" "**********"i "**********"f "**********" "**********"" "**********"a "**********"c "**********"c "**********"e "**********"s "**********"s "**********"_ "**********"t "**********"o "**********"k "**********"e "**********"n "**********"" "**********" "**********"i "**********"n "**********" "**********"r "**********"e "**********"s "**********"u "**********"l "**********"t "**********": "**********" + return result["access_token"] + else: + print(result.get("error")) + print(result.get("error_description")) + print(result.get("correlation_id")) + return None + +def get_sharepoint_site_id(access_token: "**********": str) -> Optional[str]: + headers = { + "Authorization": "**********" + "Content-Type": "application/json" + } + + url = f"https://graph.microsoft.com/v1.0/sites?search={site_name}" + + with httpx.Client() as client: + response = client.get(url, headers=headers) + + if response.status_code == 200: + sites = response.json().get("value", []) + if sites: + return sites[0]["id"] + + print(f"Error: {response.status_code}") + print(response.text) + return None + +def main() -> None: + # Read configuration from Dynaconf + client_id = settings.client_id + client_secret = "**********" + tenant_id = settings.tenant_id + site_name = settings.site_name + + access_token = "**********" + + "**********" "**********" "**********" "**********" "**********"i "**********"f "**********" "**********"a "**********"c "**********"c "**********"e "**********"s "**********"s "**********"_ "**********"t "**********"o "**********"k "**********"e "**********"n "**********": "**********" + site_id = "**********" + if site_id: + print(f"Successfully connected to SharePoint site. Site ID: {site_id}") + else: + print("Failed to retrieve SharePoint site ID.") + else: + print("Failed to acquire access token.") + +if __name__ == "__main__": + main() + diff --git a/seeker/snippet/slotVerse1withgui.py b/seeker/snippet/slotVerse1withgui.py new file mode 100644 index 00000000..f4b5aeeb --- /dev/null +++ b/seeker/snippet/slotVerse1withgui.py @@ -0,0 +1,117 @@ +#date: 2024-08-27T17:07:07Z +#url: https://api.github.com/gists/93e7e976f915d42bdfc710f9d38ae691 +#owner: https://api.github.com/users/YigitChanson + +import tkinter as tk +from tkinter import messagebox +import random + +class CasinoAccount: + def __init__(self): + self.balance = 0 + + def deposit(self, amount): + self.balance += amount + + def get_balance(self): + return self.balance + +account = CasinoAccount() + +ROWS = 3 +COLS = 3 + +symbol_count = { + "A": 2, + "B": 4, + "C": 6, + "D": 8 +} + +def get_slot_machine_spin(rows, cols, symbols): + all_symbols = [] + for symbol, symbol_count in symbols.items(): + for i in range(symbol_count): + all_symbols.append(symbol) + + slots = [] + for col in range(cols): + slot = [] + current_symbols = all_symbols[:] + for _ in range(rows): + value = random.choice(current_symbols) + current_symbols.remove(value) + slot.append(value) + + slots.append(slot) + + return slots + +def deposit(): + while True: + amount = input("What would you like to deposit? (Maximum $300): ") + if amount.isdigit(): + amount = int(amount) + if 0 < amount <= 300: + account.deposit(amount) + print(f"Deposited ${amount}. Your current balance is ${account.get_balance()}.") + break + else: + print("Invalid amount.") + else: + print("Invalid input. Please enter a number.") + return account.get_balance() + +def update_balance_label(): + balance_label.config(text=f"Balance: ${account.get_balance()}") + +def place_bet(): + lines = int(lines_var.get()) + bet = int(bet_entry.get()) + total_bet = bet * lines + + if total_bet > account.get_balance(): + messagebox.showerror("Error", "You do not have enough balance to place this bet.") + return + + account.balance -= total_bet + update_balance_label() + + columns = get_slot_machine_spin(ROWS, COLS, symbol_count) + for i in range(ROWS): + for j in range(COLS): + slot_labels[i][j].config(text=columns[j][i]) + + # Slot sonuçlarını kontrol et (Bu kısım geliştirilebilir) + messagebox.showinfo("Result", "Good luck next time!") + +# Tkinter GUI +root = tk.Tk() +root.title("Casino Slot Machine") + +balance_label = tk.Label(root, text=f"Balance: ${account.get_balance()}") +balance_label.pack() + +deposit_button = tk.Button(root, text="Deposit $100", command=lambda: [account.deposit(100), update_balance_label()]) +deposit_button.pack() + +lines_var = tk.StringVar(value="1") +lines_label = tk.Label(root, text="Number of lines to bet on (1-3):") +lines_label.pack() +lines_entry = tk.Entry(root, textvariable=lines_var) +lines_entry.pack() + +bet_label = tk.Label(root, text="Bet amount per line:") +bet_label.pack() +bet_entry = tk.Entry(root) +bet_entry.pack() + +spin_button = tk.Button(root, text="Spin", command=place_bet) +spin_button.pack() + +slot_labels = [[tk.Label(root, text="") for _ in range(COLS)] for _ in range(ROWS)] +for row in slot_labels: + for label in row: + label.pack() + +root.mainloop() diff --git a/seeker/snippet/slotVerse2nogui.py b/seeker/snippet/slotVerse2nogui.py new file mode 100644 index 00000000..cb547b00 --- /dev/null +++ b/seeker/snippet/slotVerse2nogui.py @@ -0,0 +1,107 @@ +#date: 2024-08-27T17:08:41Z +#url: https://api.github.com/gists/5e1491aee45e618ca0422cd92fecda53 +#owner: https://api.github.com/users/YigitChanson + +import random + +class CasinoAccount: + def __init__(self): + self.balance = 0 + + def deposit(self, amount): + self.balance += amount + + def get_balance(self): + return self.balance + +# Sınıfın dışına çıkarıldı +account = CasinoAccount() + +ROWS = 3 +COLS = 3 + +symbol_count = { + "A": 2, + "B": 4, + "C": 6, + "D": 8 +} + +def get_slot_machine_spin(rows, cols, symbols): + all_symbols = [] + for symbol, symbol_count in symbols.items(): + for i in range(symbol_count): + all_symbols.append(symbol) + + slots = [] + for col in range(cols): + slot = [] + current_symbols = all_symbols[:] + for _ in range(rows): + value = random.choice(current_symbols) + current_symbols.remove(value) + slot.append(value) + + slots.append(slot) + + return slots + +def print_slot_machine(slots): + for row in range(len(slots[0])): + for i, slot in enumerate(slots): + if i != len(slots) - 1: + print(slot[row], "|", end=" ") + else: + print(slot[row]) + +def deposit(): + while True: + amount = input("What would you like to deposit? (Maximum $300): ") + if amount.isdigit(): + amount = int(amount) + if 0 < amount <= 300: + account.deposit(amount) + print(f"Deposited ${amount}. Your current balance is ${account.get_balance()}.") + break + else: + print("Invalid amount.") + else: + print("Invalid input. Please enter a number.") + return account.get_balance() + +def get_number_of_lines(): + while True: + lines = input("How many lines would you like to bet on? (1-3): ") + if lines.isdigit() and 1 <= int(lines) <= 3: + lines = int(lines) + return lines + else: + print("Invalid input. Please enter a number between 1 and 3.") + +def get_bet(): + while True: + amount = input("What would you like to bet on each line? ($): ") + if amount.isdigit(): + amount = int(amount) + if amount >= 1: + return amount + else: + print("The minimum bet is $1.") + else: + print("Invalid input. Please enter a number.") + +def main(): + balance = deposit() + lines = get_number_of_lines() + bet = get_bet() + total_bet = bet * lines + if total_bet > balance: + print(f"You do not have enough balance to place this bet. Your current balance is ${balance}.") + else: + print(f"You are betting ${bet} on {lines} lines. Total bet is ${total_bet}.") + print(f"Your remaining balance after this bet is ${balance - total_bet}.") + + columns = get_slot_machine_spin(ROWS, COLS, symbol_count) + print_slot_machine(columns) + +main() \ No newline at end of file diff --git a/seeker/snippet/ssacli_to_json.py b/seeker/snippet/ssacli_to_json.py new file mode 100644 index 00000000..fda59b46 --- /dev/null +++ b/seeker/snippet/ssacli_to_json.py @@ -0,0 +1,52 @@ +#date: 2024-08-27T16:54:55Z +#url: https://api.github.com/gists/bae3ba42d696e3d3d597237a680f4dff +#owner: https://api.github.com/users/IMpcuong + +#!/usr/bin/env python3 +import sys +import json + +def parse_value(value): + try: + # Try converting to integer + return int(value) + except ValueError: + try: + # Try converting to float + return float(value.strip(' C')) # Also strip ' C' in case of temperatures + except ValueError: + # Return original string if no conversion is possible + return value + +def parse_line(line): + if ':' in line: + key, value = line.split(':', 1) + return key.strip(), parse_value(value.strip()) + return None, None + +def parse_ssacli_output(ssacli_output): + data = {'Controller': {}, 'Ports': [], 'Drives': []} + current_entity = data['Controller'] + + for line in ssacli_output: + line = line.strip() + if "Port Name" in line: + current_entity = {} + data['Ports'].append(current_entity) + elif "physicaldrive" in line: + current_entity = {'ID': line.split()[-1]} + data['Drives'].append(current_entity) + else: + key, value = parse_line(line) + if key: + current_entity[key] = value + + return data + +def main(): + ssacli_output = sys.stdin.readlines() + parsed_data = parse_ssacli_output(ssacli_output) + print(json.dumps(parsed_data, indent=4, ensure_ascii=False)) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/seeker/snippet/thirty_seven.java b/seeker/snippet/thirty_seven.java new file mode 100644 index 00000000..4fbb16b0 --- /dev/null +++ b/seeker/snippet/thirty_seven.java @@ -0,0 +1,20 @@ +//date: 2024-08-27T16:51:43Z +//url: https://api.github.com/gists/91aae8961d6274e074562132fc06edc0 +//owner: https://api.github.com/users/sasub-mlp + +import java.util.Scanner; + +public class thirty_seven { + public static void main(String[] args){ + Scanner scanner=new Scanner(System.in); + int fact=1; + System.out.println("Enter the number to find the factorial of it: "); + int n= scanner.nextInt(); + int m=n; + while(n!=0){ + fact*=n; + n--; + } + System.out.println("Factorial of "+m+" is : "+fact); + } +} diff --git a/seeker/snippet/ubuntu-container.sh b/seeker/snippet/ubuntu-container.sh new file mode 100644 index 00000000..b15335ca --- /dev/null +++ b/seeker/snippet/ubuntu-container.sh @@ -0,0 +1,72 @@ +#date: 2024-08-27T16:52:24Z +#url: https://api.github.com/gists/52bf52fa78a0aec017cd3dcefb9df41f +#owner: https://api.github.com/users/Lokawn + +#!/bin/bash -e +# Creates a systemd-nspawn container with Ubuntu + +CODENAME=${CODENAME:-noble} + +wget_or_curl () { + if command -v wget >/dev/null; then + wget "$1" -O "$2" + elif command -v curl >/dev/null; then + curl -L "$1" -o "$2" + else + echo "missing either curl or wget" >&2 + return 1 + fi +} + +if [ $UID -ne 0 ]; then + echo "run this script as root" >&2 + exit 1 +fi + +dest="$1" +if [ -z "$dest" ]; then + echo "Usage: $0 " >&2 + exit 0 +fi +if [ -e "$dest/usr/bin" ]; then + echo "destination already seems to contain a root file system" >&2 + exit 1 +fi + +if [ "$(uname -m)" = x86_64 ]; then + guestarch=amd64 +elif [ "$(uname -m)" = aarch64 ]; then + guestarch=arm64 +else + echo "unsupported architecture" >&2 + exit 1 +fi +rootfs=$(mktemp) +trap 'rm $rootfs' EXIT + +wget_or_curl "http://cloud-images.ubuntu.com/${CODENAME}/current/${CODENAME}-server-cloudimg-${guestarch}-root.tar.xz" $rootfs + +mkdir -p "$dest" +tar -xaf $rootfs -C "$dest" --numeric-owner + +sed '/^root: "**********" +rm "$dest/etc/resolv.conf" # systemd configures this +# https://github.com/systemd/systemd/issues/852 +[ -f "$dest/etc/securetty" ] && \ + printf 'pts/%d\n' $(seq 0 10) >>"$dest/etc/securetty" +# container needs no mounts +>"$dest/etc/fstab" +# disable services and uninstall packages +systemd-nspawn -q -D "$dest" sh -c ' +[ -s /etc/environment ] && . /etc/environment +for unit in ssh.service ssh.socket systemd-timesyncd systemd-networkd-wait-online systemd-resolved; do + systemctl is-enabled "$unit" && systemctl disable "$unit" +done +apt-get -qq satisfy -y --purge "Conflicts: lxcfs, lxd, snapd, cloud-init" || \ +apt-get -qq purge --autoremove snapd lxcfs lxd cloud-init +' + + +echo "" +echo "Ubuntu $CODENAME $guestarch container was created successfully" +ch container was created successfully"