diff --git a/seeker/report.txt b/seeker/report.txt index abccd269..ccf9b80b 100644 --- a/seeker/report.txt +++ b/seeker/report.txt @@ -1,3 +1,45 @@ +-------------------------------------------------------------------------------- + 2024-11-21 17:15:28.395503 +-------------------------------------------------------------------------------- + On branch main +Your branch is up to date with 'origin/main'. + +Changes not staged for commit: + (use "git add/rm ..." to update what will be committed) + (use "git restore ..." to discard changes in working directory) + deleted: snippet/.bashrc + deleted: snippet/Setup Android build environment on Fedora + deleted: snippet/arc_unpacker.py + deleted: snippet/code.py + deleted: snippet/convert_archive.py + deleted: snippet/exercises.py + deleted: snippet/extract_table_example.py + modified: snippet/gistfile1.txt + deleted: snippet/interactive_gradio_using_blocks.py + modified: snippet/main.py + deleted: snippet/openwrt-lede-on-pogoplug-mobile.sh + deleted: snippet/ping_starter.py + deleted: snippet/process_better.py + deleted: snippet/simple_gradio_interface.py + deleted: snippet/simple_interactive_gradio_interface.py + deleted: snippet/torch_device.py + deleted: snippet/validate.go + +Untracked files: + (use "git add ..." to include in what will be committed) + snippet/BCreate.java + snippet/BCreate.py + snippet/BUpdate.py + snippet/BValidate.java + snippet/BValidate.py + snippet/BValidateForm.java + snippet/BValidateForm.py + snippet/WorkSeven.py + snippet/bottle_song.py + snippet/phton.py + +no changes added to commit (use "git add" and/or "git commit -a") + -------------------------------------------------------------------------------- 2024-11-20 17:15:33.737339 -------------------------------------------------------------------------------- diff --git a/seeker/snippet/.bashrc b/seeker/snippet/.bashrc deleted file mode 100644 index 0c2960a5..00000000 --- a/seeker/snippet/.bashrc +++ /dev/null @@ -1,13 +0,0 @@ -#date: 2024-11-19T16:56:33Z -#url: https://api.github.com/gists/4f249c47d75bd9d7fa9745c5bed8f15e -#owner: https://api.github.com/users/matteopessina - -# Terminal -export PROMPT_COMMAND='PS1_CMD1=$(git branch --show-current 2>/dev/null)' -export PS1='\[\033]0;${PWD/#$HOME/\~}\007\]\[\033[32m\]\u@\h \[\033[35m\]\[\033[33m\]\W \[\033[36m\](${PS1_CMD1}) \[\033[0m\]$ ' - -# Kubernetes -source <(kubectl completion bash) -alias k=kubectl -complete -F __start_kubectl k -export KUBE_EDITOR=vim diff --git a/seeker/snippet/BCreate.java b/seeker/snippet/BCreate.java new file mode 100644 index 00000000..a0e954b0 --- /dev/null +++ b/seeker/snippet/BCreate.java @@ -0,0 +1,168 @@ +//date: 2024-11-21T17:02:35Z +//url: https://api.github.com/gists/a0ab8ccb8b3a8db6f8b8b8360a90592c +//owner: https://api.github.com/users/sts-developer + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +public class Main { + public static void main(String[] args) throws Exception { + String url = "https://testapi.taxbandits.com/v1.7.3/Form1099B/Create"; + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // Setting basic post request headers + con.setRequestMethod("POST"); + con.setRequestProperty("Authorization", "YOUR_AUTH_TOKEN_HERE"); + con.setRequestProperty("Content-Type", "application/json"); + + // Enabling POST parameters + con.setDoOutput(true); + + // JSON payload as a single-line string (Updated JSON) + String postData = "{" + + "\"SubmissionManifest\": {" + + "\"TaxYear\": \"2024\"," + + "\"IRSFilingType\":\"IRIS\"," + + "\"IsFederalFiling\": true," + + "\"IsPostal\": true," + + "\"IsOnlineAccess\": true," + + "\"IsScheduleFiling\": false," + + "\"ScheduleFiling\": null" + + "}," + + "\"ReturnHeader\": {" + + "\"Business\": {" + + "\"BusinessId\": null," + + "\"BusinessNm\": \"Snowdaze LLC\"," + + "\"FirstNm\": null," + + "\"MiddleNm\": null," + + "\"LastNm\": null," + + "\"Suffix\": null," + + "\"PayerRef\": \"Snow123\"," + + "\"TradeNm\": \"Iceberg Icecreams\"," + + "\"IsEIN\": true," + + "\"EINorSSN\": \"71-3787159\"," + + "\"Email\": \"james@sample.com\"," + + "\"ContactNm\": null," + + "\"Phone\": \"6634567890\"," + + "\"PhoneExtn\": \"12345\"," + + "\"Fax\": \"6634567890\"," + + "\"BusinessType\": \"ESTE\"," + + "\"SigningAuthority\": null," + + "\"KindOfEmployer\": \"FederalGovt\"," + + "\"KindOfPayer\": \"REGULAR941\"," + + "\"IsBusinessTerminated\": true," + + "\"IsForeign\": false," + + "\"USAddress\": {" + + "\"Address1\": \"3576 AIRPORT WAY\"," + + "\"Address2\": \"UNIT 9\"," + + "\"City\": \"FAIRBANKS\"," + + "\"State\": \"AK\"," + + "\"ZipCd\": \"99709\"" + + "}," + + "\"ForeignAddress\": null" + + "}" + + "}," + + "\"ReturnData\": [" + + "{" + + "\"SequenceId\": \"1\"," + + "\"IsPostal\": true," + + "\"IsOnlineAccess\": true," + + "\"IsForced\": true," + + "\"Recipient\": {" + + "\"RecipientId\": null," + + "\"TINType\": \"EIN\"," + + "\"TIN\": \"36-3814577\"," + + "\"FirstPayeeNm\": \"Dairy Delights LLC\"," + + "\"SecondPayeeNm\": \"Coco Milk\"," + + "\"FirstNm\": null," + + "\"MiddleNm\": null," + + "\"LastNm\": null," + + "\"Suffix\": null," + + "\"IsForeign\": true," + + "\"USAddress\": null," + + "\"ForeignAddress\": {" + + "\"Address1\": \"120 Bremner Blvd\"," + + "\"Address2\": \"Suite 800\"," + + "\"City\": \"Toronto\"," + + "\"ProvinceOrStateNm\": \"Ontario\"," + + "\"Country\": \"CA\"," + + "\"PostalCd\": \"4168682600\"" + + "}," + + "\"Email\": \"shawn09@sample.com\"," + + "\"Fax\": \"6834567890\"," + + "\"Phone\": \"7634567890\"" + + "}," + + "\"BFormData\": {" + + "\"B1aDescrOfProp\": \"RFC\"," + + "\"B1bDateAcquired\": \"07/01/2022\"," + + "\"B1cDateSoldOrDisposed\": \"09/04/2021\"," + + "\"B1dProceeds\": 40.55," + + "\"B1eCostOrOtherBasis\": 30.89," + + "\"B1fAccruedMktDisc\": 20.11," + + "\"B1gWashsaleLossDisallowed\": 4.25," + + "\"B2TypeOfGainLoss\": \"ordinary short term\"," + + "\"B3IsProceedsFromCollectibles\": true," + + "\"B3IsProceedsFromQOF\": false," + + "\"B4FedTaxWH\": 0," + + "\"B5IsNonCoveredSecurityNotReported\": false," + + "\"B5IsNonCoveredSecurityReported\": false," + + "\"B6IsGrossProceeds\": true," + + "\"B6IsNetProceeds\": false," + + "\"B7IsLossNotAllowedbasedOn1d\": false," + + "\"B8PLRealizedOnClosedContract\": 0," + + "\"B9PLUnrealizedOnOpenContractPrevTy\": 0," + + "\"B10UnrealizedPLOnOpenContractCurTy\": 0," + + "\"B11AggPLOnContract\": 0," + + "\"B12IsBasisReportedToIRS\": false," + + "\"B13Bartering\": 43," + + "\"AccountNum\": \"789121\"," + + "\"CUSIPNum\": \"8988932143534\"," + + "\"IsFATCA\": true," + + "\"Form8949Code\": \"X\"," + + "\"Is2ndTINnot\": true," + + "\"States\": [" + + "{" + + "\"StateCd\": \"WV\"," + + "\"StateIdNum\": \"99999999\"," + + "\"StateWH\": 257.94" + + "}," + + "{" + + "\"StateCd\": \"ID\"," + + "\"StateIdNum\": \"999999999\"," + + "\"StateWH\": 15" + + "}" + + "]" + + "}" + + "}" + + "]" + + "}"; + + // Writing the POST data to the request + try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { + wr.writeBytes(postData); + wr.flush(); + } + + // Reading the response + int responseCode = con.getResponseCode(); + BufferedReader in; + if (responseCode >= 200 && responseCode <= 300) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } else { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } + String inputLine; + StringBuilder response = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + // Printing the response + System.out.println(response.toString()); + } +} \ No newline at end of file diff --git a/seeker/snippet/BCreate.py b/seeker/snippet/BCreate.py new file mode 100644 index 00000000..67971dd5 --- /dev/null +++ b/seeker/snippet/BCreate.py @@ -0,0 +1,133 @@ +#date: 2024-11-21T17:01:50Z +#url: https://api.github.com/gists/5b03d929935ccdcc1915c2625ca7639e +#owner: https://api.github.com/users/sts-developer + +import http.client +import json + +conn = http.client.HTTPSConnection("testapi.taxbandits.com") +payload = json.dumps({ + "SubmissionManifest": { + "TaxYear": "2024", + "IRSFilingType": "IRIS", + "IsFederalFiling": True, + "IsPostal": True, + "IsOnlineAccess": True, + "IsScheduleFiling": False, + "ScheduleFiling": None + }, + "ReturnHeader": { + "Business": { + "BusinessId": None, + "BusinessNm": "Snowdaze LLC", + "FirstNm": None, + "MiddleNm": None, + "LastNm": None, + "Suffix": None, + "PayerRef": "Snow123", + "TradeNm": "Iceberg Icecreams", + "IsEIN": True, + "EINorSSN": "71-3787159", + "Email": "james@sample.com", + "ContactNm": None, + "Phone": "6634567890", + "PhoneExtn": "12345", + "Fax": "6634567890", + "BusinessType": "ESTE", + "SigningAuthority": None, + "KindOfEmployer": "FederalGovt", + "KindOfPayer": "REGULAR941", + "IsBusinessTerminated": True, + "IsForeign": False, + "USAddress": { + "Address1": "3576 AIRPORT WAY", + "Address2": "UNIT 9", + "City": "FAIRBANKS", + "State": "AK", + "ZipCd": "99709" + }, + "ForeignAddress": None + } + }, + "ReturnData": [ + { + "SequenceId": "1", + "IsPostal": True, + "IsOnlineAccess": True, + "IsForced": True, + "Recipient": { + "RecipientId": None, + "TINType": "EIN", + "TIN": "36-3814577", + "FirstPayeeNm": "Dairy Delights LLC", + "SecondPayeeNm": "Coco Milk", + "FirstNm": None, + "MiddleNm": None, + "LastNm": None, + "Suffix": None, + "IsForeign": True, + "USAddress": None, + "ForeignAddress": { + "Address1": "120 Bremner Blvd", + "Address2": "Suite 800", + "City": "Toronto", + "ProvinceOrStateNm": "Ontario", + "Country": "CA", + "PostalCd": "4168682600" + }, + "Email": "shawnjr@sample.com", + "Fax": "6834567890", + "Phone": "7634567890" + }, + "BFormData": { + "B1aDescrOfProp": "RFC", + "B1bDateAcquired": "07/01/2022", + "B1cDateSoldOrDisposed": "09/04/2021", + "B1dProceeds": 40.55, + "B1eCostOrOtherBasis": 30.89, + "B1fAccruedMktDisc": 20.11, + "B1gWashsaleLossDisallowed": 4.25, + "B2TypeOfGainLoss": "ordinary short term", + "B3IsProceedsFromCollectibles": True, + "B3IsProceedsFromQOF": False, + "B4FedTaxWH": 0, + "B5IsNonCoveredSecurityNotReported": False, + "B5IsNonCoveredSecurityReported": False, + "B6IsGrossProceeds": True, + "B6IsNetProceeds": False, + "B7IsLossNotAllowedbasedOn1d": False, + "B8PLRealizedOnClosedContract": 0, + "B9PLUnrealizedOnOpenContractPrevTy": 0, + "B10UnrealizedPLOnOpenContractCurTy": 0, + "B11AggPLOnContract": 0, + "B12IsBasisReportedToIRS": False, + "B13Bartering": 43, + "AccountNum": "789121", + "CUSIPNum": "8988932143534", + "IsFATCA": True, + "Form8949Code": "X", + "Is2ndTINnot": True, + "States": [ + { + "StateCd": "WV", + "StateIdNum": "99999999", + "StateWH": 257.94 + }, + { + "StateCd": "ID", + "StateIdNum": "999999999", + "StateWH": 15 + } + ] + } + } + ] +}) +headers = { + 'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJlNDdhN2I3MGMwNTY0NjI2OTU0M2RhNzQwZmNiNTZmNCIsImV4cCI6MTczMjAxNjY0OCwiaWF0IjoxNzMyMDEzMDQ4LCJpc3MiOiJodHRwczovL3Ricy1vYXV0aC5zdHNzcHJpbnQuY29tL3YyLyIsInN1YiI6ImJlZWQ0ZTAxYzM2NmQ4MjIiLCJ1c2VydW5pcXVlaWQiOiIifQ.S6hAjN56eo7fQuFL810aody1M-22xvhWj8ewVAHRxDU', + 'Content-Type': 'application/json' +} +conn.request("POST", "/V1.7.3/form1099B/create", payload, headers) +res = conn.getresponse() +data = res.read() +print(data.decode("utf-8")) \ No newline at end of file diff --git a/seeker/snippet/BUpdate.py b/seeker/snippet/BUpdate.py new file mode 100644 index 00000000..b560eefb --- /dev/null +++ b/seeker/snippet/BUpdate.py @@ -0,0 +1,135 @@ +#date: 2024-11-21T17:13:24Z +#url: https://api.github.com/gists/eabd8e45845d024af397944fce9d1d67 +#owner: https://api.github.com/users/sts-developer + +import http.client +import json + +conn = http.client.HTTPSConnection("testapi.taxbandits.com") +payload = json.dumps({ + "SubmissionManifest": { + "SubmissionId": "b5bdb3ba-aed8-41e2-8f18-ed3c761d26bf", + "TaxYear": "2024", + "IRSFilingType": "IRIS", + "IsFederalFiling": True, + "IsPostal": True, + "IsOnlineAccess": True, + "IsScheduleFiling": False, + "ScheduleFiling": None + }, + "ReturnHeader": { + "Business": { + "BusinessId": None, + "BusinessNm": "Snowdaze LLC", + "FirstNm": None, + "MiddleNm": None, + "LastNm": None, + "Suffix": None, + "PayerRef": "Snow123", + "TradeNm": "Iceberg Icecreams", + "IsEIN": True, + "EINorSSN": "71-3787159", + "Email": "james@sample.com", + "ContactNm": None, + "Phone": "6634567890", + "PhoneExtn": "12345", + "Fax": "6634567890", + "BusinessType": "ESTE", + "SigningAuthority": None, + "KindOfEmployer": "FederalGovt", + "KindOfPayer": "REGULAR941", + "IsBusinessTerminated": True, + "IsForeign": False, + "USAddress": { + "Address1": "3576 AIRPORT WAY", + "Address2": "UNIT 9", + "City": "FAIRBANKS", + "State": "AK", + "ZipCd": "99709" + }, + "ForeignAddress": None + } + }, + "ReturnData": [ + { + "RecordId": "f22c477a-9680-456d-b7a5-a39342e4362a", + "SequenceId": "1", + "IsPostal": True, + "IsOnlineAccess": True, + "IsForced": True, + "Recipient": { + "RecipientId": None, + "TINType": "EIN", + "TIN": "36-3814577", + "FirstPayeeNm": "Dairy Delights LLC", + "SecondPayeeNm": "Coco Milk", + "FirstNm": None, + "MiddleNm": None, + "LastNm": None, + "Suffix": None, + "IsForeign": True, + "USAddress": None, + "ForeignAddress": { + "Address1": "120 Bremner Blvd", + "Address2": "Suite 800", + "City": "Toronto", + "ProvinceOrStateNm": "Ontario", + "Country": "CA", + "PostalCd": "4168682600" + }, + "Email": "shawn08@sample.com", + "Fax": "6834567890", + "Phone": "7634567890" + }, + "BFormData": { + "B1aDescrOfProp": "RFC", + "B1bDateAcquired": "07/01/2022", + "B1cDateSoldOrDisposed": "09/04/2021", + "B1dProceeds": 40.55, + "B1eCostOrOtherBasis": 30.89, + "B1fAccruedMktDisc": 20.11, + "B1gWashsaleLossDisallowed": 4.25, + "B2TypeOfGainLoss": "ordinary short term", + "B3IsProceedsFromCollectibles": True, + "B3IsProceedsFromQOF": False, + "B4FedTaxWH": 0, + "B5IsNonCoveredSecurityNotReported": False, + "B5IsNonCoveredSecurityReported": False, + "B6IsGrossProceeds": True, + "B6IsNetProceeds": False, + "B7IsLossNotAllowedbasedOn1d": False, + "B8PLRealizedOnClosedContract": 0, + "B9PLUnrealizedOnOpenContractPrevTy": 0, + "B10UnrealizedPLOnOpenContractCurTy": 0, + "B11AggPLOnContract": 0, + "B12IsBasisReportedToIRS": False, + "B13Bartering": 43, + "AccountNum": "789121", + "CUSIPNum": "8988932143534", + "IsFATCA": True, + "Form8949Code": "X", + "Is2ndTINnot": True, + "States": [ + { + "StateCd": "WV", + "StateIdNum": "99999999", + "StateWH": 257.94 + }, + { + "StateCd": "ID", + "StateIdNum": "999999999", + "StateWH": 15 + } + ] + } + } + ] +}) +headers = { + 'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJlNDdhN2I3MGMwNTY0NjI2OTU0M2RhNzQwZmNiNTZmNCIsImV4cCI6MTczMjAxNjY0OCwiaWF0IjoxNzMyMDEzMDQ4LCJpc3MiOiJodHRwczovL3Ricy1vYXV0aC5zdHNzcHJpbnQuY29tL3YyLyIsInN1YiI6ImJlZWQ0ZTAxYzM2NmQ4MjIiLCJ1c2VydW5pcXVlaWQiOiIifQ.S6hAjN56eo7fQuFL810aody1M-22xvhWj8ewVAHRxDU', + 'Content-Type': 'application/json' +} +conn.request("PUT", "/V1.7.3/form1099B/Update", payload, headers) +res = conn.getresponse() +data = res.read() +print(data.decode("utf-8")) \ No newline at end of file diff --git a/seeker/snippet/BValidate.java b/seeker/snippet/BValidate.java new file mode 100644 index 00000000..ad154683 --- /dev/null +++ b/seeker/snippet/BValidate.java @@ -0,0 +1,43 @@ +//date: 2024-11-21T17:10:26Z +//url: https://api.github.com/gists/2b36d690b951e3bc20f38f0d586abc0d +//owner: https://api.github.com/users/sts-developer + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +public class Main { + public static void main(String[] args) throws Exception { + // Define the URL with the query parameter + String url = "https://testapi.taxbandits.com/v1.7.3/form1099B/Validate?SubmissionId=d259edc3-b59a-4771-926d-1f68269a5473"; + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // Set the request method to GET + con.setRequestMethod("GET"); + + // Set request headers (e.g., Authorization, Content-Type) + con.setRequestProperty("Authorization", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJlYzE0NTIxYjMxNGY0N2RhOTc5ODMzYjVlZjkxNDU5ZSIsImV4cCI6MTcyMTIwNjk3NywiaWF0IjoxNzIxMjAzMzc3LCJpc3MiOiJodHRwczovL3Rlc3RvYXV0aC5leHByZXNzYXV0aC5uZXQvdjIvIiwic3ViIjoiYTQyMWE2MWUzOWUyY2U3ZSJ9.YjQP2gkoecj6tqyXJRcJ8LeeAsP0zwkQYk7iD0QHKW8"); + con.setRequestProperty("Content-Type", "application/json"); + + // Get the response code and handle response + int responseCode = con.getResponseCode(); + BufferedReader in; + if (responseCode >= 200 && responseCode < 300) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } else { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } + + String inputLine; + StringBuffer response = new StringBuffer(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + // Print the response from the API + System.out.println(response.toString()); + } +} \ No newline at end of file diff --git a/seeker/snippet/BValidate.py b/seeker/snippet/BValidate.py new file mode 100644 index 00000000..e3d9491e --- /dev/null +++ b/seeker/snippet/BValidate.py @@ -0,0 +1,15 @@ +#date: 2024-11-21T17:09:41Z +#url: https://api.github.com/gists/e0fd90d8c4ca9d89cb3200558a7c2249 +#owner: https://api.github.com/users/sts-developer + +import http.client + +conn = http.client.HTTPSConnection("testapi.taxbandits.com") +payload = '' +headers = { + 'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJlNDdhN2I3MGMwNTY0NjI2OTU0M2RhNzQwZmNiNTZmNCIsImV4cCI6MTczMTkxMDcxOSwiaWF0IjoxNzMxOTA3MTE5LCJpc3MiOiJodHRwczovL3Ricy1vYXV0aC5zdHNzcHJpbnQuY29tL3YyLyIsInN1YiI6ImJlZWQ0ZTAxYzM2NmQ4MjIiLCJ1c2VydW5pcXVlaWQiOiIifQ.ojZn07OhqPpuVGpcb5wInE-Y5z7IkXqHtpOIRSV8zqo' +} +conn.request("GET", "/V1.7.3/form1099B/Validate?SubmissionId=d259edc3-b59a-4771-926d-1f68269a5473", payload, headers) +res = conn.getresponse() +data = res.read() +print(data.decode("utf-8")) \ No newline at end of file diff --git a/seeker/snippet/BValidateForm.java b/seeker/snippet/BValidateForm.java new file mode 100644 index 00000000..a126ac41 --- /dev/null +++ b/seeker/snippet/BValidateForm.java @@ -0,0 +1,168 @@ +//date: 2024-11-21T17:06:29Z +//url: https://api.github.com/gists/e67759f96ff9272a2e559622086bc09d +//owner: https://api.github.com/users/sts-developer + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +public class Main { + public static void main(String[] args) throws Exception { + String url = "https://testapi.taxbandits.com/v1.7.3/Form1099B/ValidateForm"; + URL obj = new URL(url); + HttpURLConnection con = (HttpURLConnection) obj.openConnection(); + + // Setting basic post request headers + con.setRequestMethod("POST"); + con.setRequestProperty("Authorization", "YOUR_AUTH_TOKEN_HERE"); + con.setRequestProperty("Content-Type", "application/json"); + + // Enabling POST parameters + con.setDoOutput(true); + + // JSON payload as a single-line string (Updated JSON) + String postData = "{" + + "\"SubmissionManifest\": {" + + "\"TaxYear\": \"2024\"," + + "\"IRSFilingType\":\"IRIS\"," + + "\"IsFederalFiling\": true," + + "\"IsPostal\": true," + + "\"IsOnlineAccess\": true," + + "\"IsScheduleFiling\": false," + + "\"ScheduleFiling\": null" + + "}," + + "\"ReturnHeader\": {" + + "\"Business\": {" + + "\"BusinessId\": null," + + "\"BusinessNm\": \"Snowdaze LLC\"," + + "\"FirstNm\": null," + + "\"MiddleNm\": null," + + "\"LastNm\": null," + + "\"Suffix\": null," + + "\"PayerRef\": \"Snow123\"," + + "\"TradeNm\": \"Iceberg Icecreams\"," + + "\"IsEIN\": true," + + "\"EINorSSN\": \"71-3787159\"," + + "\"Email\": \"james@sample.com\"," + + "\"ContactNm\": null," + + "\"Phone\": \"6634567890\"," + + "\"PhoneExtn\": \"12345\"," + + "\"Fax\": \"6634567890\"," + + "\"BusinessType\": \"ESTE\"," + + "\"SigningAuthority\": null," + + "\"KindOfEmployer\": \"FederalGovt\"," + + "\"KindOfPayer\": \"REGULAR941\"," + + "\"IsBusinessTerminated\": true," + + "\"IsForeign\": false," + + "\"USAddress\": {" + + "\"Address1\": \"3576 AIRPORT WAY\"," + + "\"Address2\": \"UNIT 9\"," + + "\"City\": \"FAIRBANKS\"," + + "\"State\": \"AK\"," + + "\"ZipCd\": \"99709\"" + + "}," + + "\"ForeignAddress\": null" + + "}" + + "}," + + "\"ReturnData\": [" + + "{" + + "\"SequenceId\": \"1\"," + + "\"IsPostal\": true," + + "\"IsOnlineAccess\": true," + + "\"IsForced\": true," + + "\"Recipient\": {" + + "\"RecipientId\": null," + + "\"TINType\": \"EIN\"," + + "\"TIN\": \"36-3814577\"," + + "\"FirstPayeeNm\": \"Dairy Delights LLC\"," + + "\"SecondPayeeNm\": \"Coco Milk\"," + + "\"FirstNm\": null," + + "\"MiddleNm\": null," + + "\"LastNm\": null," + + "\"Suffix\": null," + + "\"IsForeign\": true," + + "\"USAddress\": null," + + "\"ForeignAddress\": {" + + "\"Address1\": \"120 Bremner Blvd\"," + + "\"Address2\": \"Suite 800\"," + + "\"City\": \"Toronto\"," + + "\"ProvinceOrStateNm\": \"Ontario\"," + + "\"Country\": \"CA\"," + + "\"PostalCd\": \"4168682600\"" + + "}," + + "\"Email\": \"shawn09@sample.com\"," + + "\"Fax\": \"6834567890\"," + + "\"Phone\": \"7634567890\"" + + "}," + + "\"BFormData\": {" + + "\"B1aDescrOfProp\": \"RFC\"," + + "\"B1bDateAcquired\": \"07/01/2022\"," + + "\"B1cDateSoldOrDisposed\": \"09/04/2021\"," + + "\"B1dProceeds\": 40.55," + + "\"B1eCostOrOtherBasis\": 30.89," + + "\"B1fAccruedMktDisc\": 20.11," + + "\"B1gWashsaleLossDisallowed\": 4.25," + + "\"B2TypeOfGainLoss\": \"ordinary short term\"," + + "\"B3IsProceedsFromCollectibles\": true," + + "\"B3IsProceedsFromQOF\": false," + + "\"B4FedTaxWH\": 0," + + "\"B5IsNonCoveredSecurityNotReported\": false," + + "\"B5IsNonCoveredSecurityReported\": false," + + "\"B6IsGrossProceeds\": true," + + "\"B6IsNetProceeds\": false," + + "\"B7IsLossNotAllowedbasedOn1d\": false," + + "\"B8PLRealizedOnClosedContract\": 0," + + "\"B9PLUnrealizedOnOpenContractPrevTy\": 0," + + "\"B10UnrealizedPLOnOpenContractCurTy\": 0," + + "\"B11AggPLOnContract\": 0," + + "\"B12IsBasisReportedToIRS\": false," + + "\"B13Bartering\": 43," + + "\"AccountNum\": \"789121\"," + + "\"CUSIPNum\": \"8988932143534\"," + + "\"IsFATCA\": true," + + "\"Form8949Code\": \"X\"," + + "\"Is2ndTINnot\": true," + + "\"States\": [" + + "{" + + "\"StateCd\": \"WV\"," + + "\"StateIdNum\": \"99999999\"," + + "\"StateWH\": 257.94" + + "}," + + "{" + + "\"StateCd\": \"ID\"," + + "\"StateIdNum\": \"999999999\"," + + "\"StateWH\": 15" + + "}" + + "]" + + "}" + + "}" + + "]" + + "}"; + + // Writing the POST data to the request + try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { + wr.writeBytes(postData); + wr.flush(); + } + + // Reading the response + int responseCode = con.getResponseCode(); + BufferedReader in; + if (responseCode >= 200 && responseCode <= 300) { + in = new BufferedReader(new InputStreamReader(con.getInputStream())); + } else { + in = new BufferedReader(new InputStreamReader(con.getErrorStream())); + } + String inputLine; + StringBuilder response = new StringBuilder(); + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + + // Printing the response + System.out.println(response.toString()); + } +} \ No newline at end of file diff --git a/seeker/snippet/BValidateForm.py b/seeker/snippet/BValidateForm.py new file mode 100644 index 00000000..ebc84785 --- /dev/null +++ b/seeker/snippet/BValidateForm.py @@ -0,0 +1,133 @@ +#date: 2024-11-21T17:05:19Z +#url: https://api.github.com/gists/12c2a93e5abbb015225dcdeed70078c2 +#owner: https://api.github.com/users/sts-developer + +import http.client +import json + +conn = http.client.HTTPSConnection("testapi.taxbandits.com") +payload = json.dumps({ + "SubmissionManifest": { + "TaxYear": "2024", + "IRSFilingType": "IRIS", + "IsFederalFiling": True, + "IsPostal": True, + "IsOnlineAccess": True, + "IsScheduleFiling": False, + "ScheduleFiling": None + }, + "ReturnHeader": { + "Business": { + "BusinessId": None, + "BusinessNm": "Snowdaze LLC", + "FirstNm": None, + "MiddleNm": None, + "LastNm": None, + "Suffix": None, + "PayerRef": "Snow123", + "TradeNm": "Iceberg Icecreams", + "IsEIN": True, + "EINorSSN": "71-3787159", + "Email": "james@sample.com", + "ContactNm": None, + "Phone": "6634567890", + "PhoneExtn": "12345", + "Fax": "6634567890", + "BusinessType": "ESTE", + "SigningAuthority": None, + "KindOfEmployer": "FederalGovt", + "KindOfPayer": "REGULAR941", + "IsBusinessTerminated": True, + "IsForeign": False, + "USAddress": { + "Address1": "3576 AIRPORT WAY", + "Address2": "UNIT 9", + "City": "FAIRBANKS", + "State": "AK", + "ZipCd": "99709" + }, + "ForeignAddress": None + } + }, + "ReturnData": [ + { + "SequenceId": "1", + "IsPostal": True, + "IsOnlineAccess": True, + "IsForced": True, + "Recipient": { + "RecipientId": None, + "TINType": "EIN", + "TIN": "36-3814577", + "FirstPayeeNm": "Dairy Delights LLC", + "SecondPayeeNm": "Coco Milk", + "FirstNm": None, + "MiddleNm": None, + "LastNm": None, + "Suffix": None, + "IsForeign": True, + "USAddress": None, + "ForeignAddress": { + "Address1": "120 Bremner Blvd", + "Address2": "Suite 800", + "City": "Toronto", + "ProvinceOrStateNm": "Ontario", + "Country": "CA", + "PostalCd": "4168682600" + }, + "Email": "shawnjr@sample.com", + "Fax": "6834567890", + "Phone": "7634567890" + }, + "BFormData": { + "B1aDescrOfProp": "RFC", + "B1bDateAcquired": "07/01/2022", + "B1cDateSoldOrDisposed": "09/04/2021", + "B1dProceeds": 40.55, + "B1eCostOrOtherBasis": 30.89, + "B1fAccruedMktDisc": 20.11, + "B1gWashsaleLossDisallowed": 4.25, + "B2TypeOfGainLoss": "ordinary short term", + "B3IsProceedsFromCollectibles": True, + "B3IsProceedsFromQOF": False, + "B4FedTaxWH": 0, + "B5IsNonCoveredSecurityNotReported": False, + "B5IsNonCoveredSecurityReported": False, + "B6IsGrossProceeds": True, + "B6IsNetProceeds": False, + "B7IsLossNotAllowedbasedOn1d": False, + "B8PLRealizedOnClosedContract": 0, + "B9PLUnrealizedOnOpenContractPrevTy": 0, + "B10UnrealizedPLOnOpenContractCurTy": 0, + "B11AggPLOnContract": 0, + "B12IsBasisReportedToIRS": False, + "B13Bartering": 43, + "AccountNum": "789121", + "CUSIPNum": "8988932143534", + "IsFATCA": True, + "Form8949Code": "X", + "Is2ndTINnot": True, + "States": [ + { + "StateCd": "WV", + "StateIdNum": "99999999", + "StateWH": 257.94 + }, + { + "StateCd": "ID", + "StateIdNum": "999999999", + "StateWH": 15 + } + ] + } + } + ] +}) +headers = { + 'Authorization': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJlNDdhN2I3MGMwNTY0NjI2OTU0M2RhNzQwZmNiNTZmNCIsImV4cCI6MTczMjAxNjY0OCwiaWF0IjoxNzMyMDEzMDQ4LCJpc3MiOiJodHRwczovL3Ricy1vYXV0aC5zdHNzcHJpbnQuY29tL3YyLyIsInN1YiI6ImJlZWQ0ZTAxYzM2NmQ4MjIiLCJ1c2VydW5pcXVlaWQiOiIifQ.S6hAjN56eo7fQuFL810aody1M-22xvhWj8ewVAHRxDU', + 'Content-Type': 'application/json' +} +conn.request("POST", "/V1.7.3/form1099B/ValidateForm", payload, headers) +res = conn.getresponse() +data = res.read() +print(data.decode("utf-8")) \ No newline at end of file diff --git a/seeker/snippet/Setup Android build environment on Fedora b/seeker/snippet/Setup Android build environment on Fedora deleted file mode 100644 index 95e09db0..00000000 --- a/seeker/snippet/Setup Android build environment on Fedora +++ /dev/null @@ -1,44 +0,0 @@ -#date: 2024-11-19T16:50:51Z -#url: https://api.github.com/gists/b2c457aae35dfec38c32eba2a00cbf12 -#owner: https://api.github.com/users/hyeondg - -#!/bin/bash -if [ $UID != "0" ]; then - echo "ERROR: You must run this script as root!" - exit 1 -fi - -dnf install \ - @development-tools \ - android-tools \ - automake \ - bison \ - bzip2 \ - bzip2-libs \ - ccache \ - curl \ - dpkg-dev \ - gcc \ - gcc-c++ \ - gperf \ - libstdc++.i686 \ - libxml2-devel \ - lz4-libs \ - lzop \ - make \ - maven \ - ncurses-compat-libs \ - openssl-devel \ - pngcrush \ - python \ - python3 \ - python3-mako \ - python-mako \ - python-networkx \ - schedtool \ - squashfs-tools \ - syslinux-devel \ - zip \ - zlib-devel \ - zlib-devel.i686 -curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo && chmod +x /usr/bin/repo \ No newline at end of file diff --git a/seeker/snippet/WorkSeven.py b/seeker/snippet/WorkSeven.py new file mode 100644 index 00000000..375b8325 --- /dev/null +++ b/seeker/snippet/WorkSeven.py @@ -0,0 +1,34 @@ +#date: 2024-11-21T17:11:45Z +#url: https://api.github.com/gists/910753385983c7fc24562855f2af3145 +#owner: https://api.github.com/users/EXODEZ + +# 6 задание +number = input("Введите десятизначное число: ") + +if len(number) != 10 or not number.isdigit(): + print("Ошибка: Введите корректное десятизначное число.") +else: + digits = [int(digit) for digit in number] + + max_digit = max(digits) + min_digit = min(digits) + + print(f"Самая большая цифра: {max_digit}") + print(f"Самая маленькая цифра: {min_digit}") + +# 7 задание +ticket_number = input("Введите шестизначное число: ") + +if len(ticket_number) != 6 or not ticket_number.isdigit(): + print("Ошибка: Введите корректное шестизначное число.") +else: + first_half = ticket_number[:3] + second_half = ticket_number[3:] + sum_first_half = sum(int(digit) for digit in first_half) + sum_second_half = sum(int(digit) for digit in second_half) + + if sum_first_half == sum_second_half: + print("Счастливый билет") + else: + print("Несчастливый билет") + diff --git a/seeker/snippet/arc_unpacker.py b/seeker/snippet/arc_unpacker.py deleted file mode 100644 index 4b48297f..00000000 --- a/seeker/snippet/arc_unpacker.py +++ /dev/null @@ -1,110 +0,0 @@ -#date: 2024-11-19T16:43:25Z -#url: https://api.github.com/gists/21c95c1a875e219ebb1c956569c2dd8f -#owner: https://api.github.com/users/Ailyth99 - -################################################################### -# ARC file unpacker for PS2 Kagero 2 / Trapt game's arc files -################################################################### -import os -import struct -from pathlib import Path - -def is_arc_file(file_path): - """Check if file is ARC format""" - try: - with open(file_path, 'rb') as f: - magic = f.read(4) - return magic == b'RPS\x00' - except: - return False - -def unpack_arc(input_file, output_dir): - """Unpack single ARC file""" - try: - # Create subfolder named after file - file_name = Path(input_file).stem - sub_output_dir = os.path.join(output_dir, file_name) - os.makedirs(sub_output_dir, exist_ok=True) - - with open(input_file, 'rb') as f: - # Check file header - magic = f.read(4) - if magic != b'ARC\x00': - raise ValueError(f"Not a valid ARC file: {input_file}") - - # Read header info - files_count = struct.unpack(' 10: + raise ValueError("Start must be between 0 and 10") + + end = max(start - 1, 0) + begin = start_dict.get(start) + end_word = start_dict.get(end).lower() + + song_lines = [ + "{} green bottle{} hanging on the wall,".format(begin, '' if start == 1 else 's'), + "{} green bottle{} hanging on the wall,".format(begin, '' if start == 1 else 's'), + "And if one green bottle should accidentally fall,", + "There'll be {} green bottle{} hanging on the wall.".format(end_word, '' if end == 1 else 's') + ] + + return song_lines \ No newline at end of file diff --git a/seeker/snippet/code.py b/seeker/snippet/code.py deleted file mode 100644 index 0d20151e..00000000 --- a/seeker/snippet/code.py +++ /dev/null @@ -1,47 +0,0 @@ -#date: 2024-11-19T16:47:38Z -#url: https://api.github.com/gists/215ad8e88e3ef46854af066c1ff0da54 -#owner: https://api.github.com/users/MrNtex - -import requests -from bs4 import BeautifulSoup -from fpdf import FPDF - -def scrap_pokemon_list(): - url='https://pokelife.pl/pokedex/index.php?title=Lista_Pokemon%C3%B3w_Kanto' - response = requests.get(url) - - soup = BeautifulSoup(response.content, 'html.parser') - pokemons_list = [] - - table= soup.find('table', class_='Tabela1') - rows = table.find_all('tr') - - for row in rows[1:]: - columns = row.find_all('td') - pokemon = (columns[2].text[:-1], f"No.{columns[0].text[:-1]}") - pokemons_list.append(pokemon) - - return pokemons_list - -def get_pokemon_info(pokemon_name): - pokemon_name = pokemon_name.replace('\'','') - pokemon_name = pokemon_name.replace('. ','-') - pokemon_name = pokemon_name.replace('♀','-f') - pokemon_name = pokemon_name.replace('♂','-m') - url = f'https://pokeapi.co/api/v2/pokemon/{pokemon_name.lower()}' - response = requests.get(url) - return response.json() - - -pokemon_list = scrap_pokemon_list() - -for pokemon in pokemon_list: - try: - pokemon_info = get_pokemon_info(pokemon[0]) - except: - print("Blad: " + pokemon[0]) - else: - print(pokemon_info['name']) - -print(pokemon_list) - diff --git a/seeker/snippet/convert_archive.py b/seeker/snippet/convert_archive.py deleted file mode 100644 index 685a7281..00000000 --- a/seeker/snippet/convert_archive.py +++ /dev/null @@ -1,456 +0,0 @@ -#date: 2024-11-19T16:51:28Z -#url: https://api.github.com/gists/e19d5f1b178c45c4034480a849ab3a09 -#owner: https://api.github.com/users/fastdaima - -import argparse -import json -import logging -import os -import re -import shutil -from concurrent.futures import ProcessPoolExecutor, as_completed -from dataclasses import dataclass -from datetime import datetime -from typing import Any, Callable, Dict, List, Literal, Optional, Tuple - -# Logging setup -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) - -@dataclass -class MediaFile: - id: str - content_type: str - path: str - metadata: Dict[str, Any] - -@dataclass -class Content: - id: str - text: str - metadata: Dict[str, Any] - timestamp: str - parent_id: Optional[str] - media_files: List[Dict[str, Any]] - content_source: str - -@dataclass -class Thread: - id: str - contents: List[Content] - -@dataclass -class Message: - role: Literal["assistant", "user"] - content: str - -# Data extraction functions -def clean_json_string(json_string: str) -> str: - return re.sub(r'^window\.[^=]+=\s*', '', json_string.strip()).rstrip(';') - -def process_file(file_path: str) -> List[Dict[str, Any]]: - try: - with open(file_path, 'r', encoding='utf-8') as f: - data = clean_json_string(f.read()) - results = json.loads(data) - return results - except Exception as e: - logger.warning(f"Error processing file {file_path}: {e}") - return [] - -def extract_manifest(file_path: str) -> Dict[str, Any]: - try: - with open(file_path, 'r', encoding='utf-8') as file: - content = clean_json_string(file.read()) - return json.loads(content) - except json.JSONDecodeError: - match = re.search(r'window\.__THAR_CONFIG\s*=\s*({.*})', content, re.DOTALL) - if match: - return json.loads(match.group(1)) - logger.error(f"Could not parse __THAR_CONFIG in manifest file: {file_path}") - raise - except Exception as e: - logger.error(f"Error extracting manifest from {file_path}: {e}") - raise - -def get_media_files(tweet_id: str, media_folder: str) -> List[str]: - try: - all_files = os.listdir(media_folder) - media_files = [ - f for f in all_files - if f.startswith(f"{tweet_id}-") and os.path.getsize(os.path.join(media_folder, f)) > 0 - ] - return media_files - except Exception as e: - logger.error(f"Error getting media files for tweet_id {tweet_id}: {e}") - return [] - -def get_media_type(filename: str) -> str: - ext = os.path.splitext(filename)[1].lower() - if ext in ('.mp4', '.mov'): - return 'video' - elif ext in ('.jpg', '.jpeg', '.png', '.gif'): - return 'photo' - return 'unknown' - -def extract_content(item: Dict[str, Any], content_source: str, media_folder: str) -> List[Content]: - content_id = item.get('id') or item.get('tweetId') - text = item.get('text') or item.get('fullText') or item.get('full_text') - - media_files = get_media_files(content_id, media_folder) - media_file_objects = [{ - 'id': f"{content_id}_{os.path.splitext(media_file)[0]}", - 'content_type': get_media_type(media_file), - 'path': os.path.join(media_folder, media_file), - 'metadata': { - 'parent_tweet': item, - 'media_info': item.get('extended_entities', {}).get('media', []) - } - } for media_file in media_files] - - return [Content( - id=content_id, - text=text, - metadata=item, - timestamp=item.get('created_at', ''), - parent_id=item.get('in_reply_to_status_id', None), - media_files=media_file_objects, - content_source=content_source - )] - -def process_file_wrapper(args: Tuple[str, Dict[str, Any], str, str]) -> List[Content]: - archive_path, file_info, extractor_name, media_folder = args - file_path = os.path.join(archive_path, file_info['fileName']) - file_data = process_file(file_path) - extractor = globals()[extractor_name] # Get the extractor function by name - return extractor(file_data, media_folder) - -def extract_content_data(archive_path: str, file_info: Dict[str, Any], extractor: Callable, media_folder: str) -> List[Content]: - try: - return extractor(file_info['data'], media_folder) - except Exception as e: - logger.error(f"Error extracting data with {extractor.__name__}: {e}") - return [] - -def extract_data(archive_path: str, type_info: Dict[str, Any], extractor: Callable) -> List[Content]: - media_folder = os.path.join(archive_path, 'data', 'tweets_media') - contents = [] - extractor_name = extractor.__name__ - - with ProcessPoolExecutor() as executor: - args_list = [ - (archive_path, file_info, extractor_name, media_folder) - for file_info in type_info.get('files', []) - ] - futures = [executor.submit(process_file_wrapper, args) for args in args_list] - - total_futures = len(futures) - logger.info(f"Processing {total_futures} files with {extractor_name}") - completed_count = 0 - - for future in as_completed(futures): - result = future.result() - if result: - contents.extend(result) - completed_count += 1 - if completed_count % 10 == 0 or completed_count == total_futures: - logger.info(f"Processed {completed_count}/{total_futures} files") - - logger.info(f"Total {extractor_name} extracted: {len(contents)} from {len(type_info.get('files', []))} files") - return contents - -def extract_tweets(file_data: List[Dict[str, Any]], media_folder: str) -> List[Content]: - logger.info(f"Extracting tweets from {len(file_data)} items") - contents = [ - content - for tweet in file_data if 'tweet' in tweet - for content in extract_content(tweet['tweet'], 'tweet', media_folder) - ] - logger.info(f"Extracted {len(contents)} tweet contents") - return contents - -def extract_likes(file_data: List[Dict[str, Any]], media_folder: str) -> List[Content]: - logger.info(f"Extracting likes from {len(file_data)} items") - contents = [ - content - for like in file_data if 'like' in like - for content in extract_content(like['like'], 'like', media_folder) - ] - logger.info(f"Extracted {len(contents)} like contents") - return contents - -def extract_archive_data(archive_path: str) -> Dict[str, List[Content]]: - try: - manifest_path = os.path.join(archive_path, 'data', 'manifest.js') - manifest = extract_manifest(manifest_path) - data_types = manifest.get('dataTypes', {}) - - extractors = { - 'tweets': extract_tweets, - 'like': extract_likes, - # Add more extractors as needed - } - - response = {} - for data_type, extractor in extractors.items(): - if data_type in data_types: - response[data_type] = extract_data(archive_path, data_types[data_type], extractor) - - return response - - except Exception as e: - logger.error(f"Error occurred during data extraction: {e}") - return {} - -# Data transformation functions -def clean_text(text: str, entities: Optional[Dict] = None) -> str: - if entities: - for url in entities.get('urls', []): - short_url = url.get('url', '') - expanded_url = url.get('expanded_url', '') - if short_url and expanded_url: - text = text.replace(short_url, expanded_url) - - text = re.sub(r'https://t.co/\w+', '', text) - text = re.sub(r'@\w+', '', text) - text = re.sub(r'#\w+', '', text) - text = re.sub(r'\s+', ' ', text) - return text.strip() - -def get_all_tweets(data: Dict[str, List[Content]]) -> Dict[str, Content]: - logger.info("Combining tweets and likes into all_tweets") - all_tweets = {tweet.id: tweet for tweet in data.get('tweets', []) if tweet.id} - logger.info(f"Added {len(data.get('tweets', []))} tweets to all_tweets") - - likes = data.get('like', []) - for like in likes: - if like.id: - all_tweets[like.id] = like - else: - logger.warning("Like without id encountered and skipped.") - logger.info(f"Added {len(likes)} likes to all_tweets") - logger.info(f"Total {len(all_tweets)} tweets/likes in all_tweets") - - return all_tweets - -def get_conversation_texts(conversation: List[Content]) -> List[Tuple[str, str]]: - return [ - (tweet.text, "assistant" if 'full_text' in tweet.metadata else "user") - for tweet in conversation - if tweet.text - ] - -def trim_conversation_to_last_assistant(conversation_data: List[Message]) -> List[Message]: - for i in range(len(conversation_data) - 1, -1, -1): - if conversation_data[i].role == "assistant": - return conversation_data[:i+1] - return [] - -def get_conversation_data(conversation: List[Content]) -> List[Message]: - conversation_data = [] - current_role = None - current_content = [] - - for text, role in get_conversation_texts(conversation): - cleaned_text = clean_text(text) - if cleaned_text: - if role != current_role and current_role is not None: - conversation_data.append(format_message(current_content, current_role)) - current_content = [] - current_role = role - current_content.append(cleaned_text) - - if current_content: - conversation_data.append(format_message(current_content, current_role)) - - return trim_conversation_to_last_assistant(conversation_data) - -def extract_threads_and_conversations(all_tweets: Dict[str, Content]) -> Tuple[List[Thread], List[List[Content]]]: - """Extract threads and conversations from all tweets.""" - threads = [] - conversations = [] - - # Keep track of processed tweet IDs to avoid duplicates - processed_ids = set() - - for tweet in all_tweets.values(): - if tweet.id in processed_ids: - continue - - if tweet.content_source == 'tweet' and tweet.parent_id and tweet.parent_id in all_tweets and not tweet.text.startswith('RT'): - # Initialize the chain - chain = [tweet] - current_tweet = tweet - - # Walk up the chain of replies - while current_tweet.parent_id and current_tweet.parent_id in all_tweets: - parent_tweet = all_tweets[current_tweet.parent_id] - chain.append(parent_tweet) - current_tweet = parent_tweet - - if current_tweet.id in processed_ids: - break # Avoid cycles - - # Mark tweets as processed - for t in chain: - processed_ids.add(t.id) - - # Determine if it's a thread or conversation - if all(t.content_source == 'tweet' for t in chain): - # This is a thread (user replying to themselves) - threads.append(Thread(id=tweet.id, contents=list(reversed(chain)))) - else: - # This is a conversation (user replying to others) - conversations.append(list(reversed(chain))) - - return threads, conversations - -# Data export functions -def process_media_files(media_files: List[Dict[str, Any]], images_folder: str) -> List[str]: - media_links = [] - for media_file in media_files: - media_path = media_file.get('path') - if media_path and os.path.isfile(media_path): - orig_filename = os.path.basename(media_path) - new_filename = f"_{orig_filename}" - dest_path = os.path.join(images_folder, new_filename) - shutil.copy(media_path, dest_path) - media_links.append(f"![{new_filename}](images/{new_filename})") - else: - logger.warning(f"Invalid or missing media path: {media_path}") - return media_links -def save_thread_markdown(thread: Thread, output_dir: str, media_folder: str, images_folder: str): - if not thread.contents: - logger.warning("Attempted to save an empty thread.") - return - - try: - date_str = thread.contents[0].timestamp - date = datetime.strptime(date_str, '%a %b %d %H:%M:%S %z %Y').date() - except ValueError: - logger.warning(f"Invalid date format: {date_str}") - date = datetime.today().date() - - frontmatter = f"---\nDate: {date.isoformat()}\n---\n" - - thread_text = [] - for tweet in thread.contents: - media_links = process_media_files(tweet.media_files, images_folder) - cleaned_text = clean_text(tweet.text, tweet.metadata.get('entities')) - combined_text = f"{cleaned_text}\n\n" + '\n\n'.join(media_links) - thread_text.append(combined_text) - - first_words = ' '.join(thread_text[0].split()[:5]) - sanitized_filename = re.sub(r'[^\w\-_ ]', '', first_words).strip().replace(' ', '_')[:50] - filename = f"{sanitized_filename}.md" - file_path = os.path.join(output_dir, filename) - - top_tweet_id = thread.contents[0].id - top_tweet_link = f"https://twitter.com/i/web/status/{top_tweet_id}" - - with open(file_path, 'w', encoding='utf-8') as f: - f.write(f"{frontmatter}\n\n" + '\n\n'.join(thread_text) + f"\n\n[View on Twitter]({top_tweet_link})") - -def save_tweets_by_date(all_tweets: Dict[str, Content], threads: List[Thread], output_dir: str, images_folder: str): - thread_ids = {tweet.id for thread in threads for tweet in thread.contents} - non_thread_tweets = [ - tweet for tweet_id, tweet in all_tweets.items() - if tweet_id not in thread_ids - and not tweet.parent_id - and tweet.content_source == 'tweet' - and not tweet.text.startswith('RT') - ] - - tweets_by_date: Dict[datetime.date, List[Content]] = {} - for tweet in non_thread_tweets: - date_str = tweet.timestamp - if not date_str: - logger.warning(f"Tweet missing date information: {tweet}") - continue - try: - date = datetime.strptime(date_str, '%a %b %d %H:%M:%S %z %Y').date() - tweets_by_date.setdefault(date, []).append(tweet) - except ValueError: - logger.warning(f"Invalid date format: {date_str}") - - for date, tweets_on_date in tweets_by_date.items(): - filename = f"{date.isoformat()}.md" - file_path = os.path.join(output_dir, filename) - tweets_on_date.sort(key=lambda x: x.timestamp) - content = '\n\n---\n\n'.join( - f"*{datetime.strptime(tweet.timestamp, '%a %b %d %H:%M:%S %z %Y').strftime('%I:%M %p')}* \n{clean_text(tweet.text, tweet.metadata.get('entities'))}" + - ''.join(process_media_files(tweet.media_files, images_folder)) - for tweet in tweets_on_date - ) - with open(file_path, 'w', encoding='utf-8') as f: - f.write(content) - -def format_message(content: List[str], role: Literal['assistant', 'user']) -> Message: - return Message(role=role, content="\n\n".join(content)) - -def format_conversation(conversation_data: List[Message], system_message: str) -> Dict[str, Any]: - messages = [{"role": "system", "content": system_message}] - messages.extend([message.__dict__ for message in conversation_data]) - return {"messages": messages} - -def save_conversations_to_jsonl(threads: List[Thread], conversations: List[List[Content]], output_path: str, system_message: str = "You have been uploaded to the internet"): - logger.info(f"Saving {len(conversations) + len(threads)} conversations to {output_path} in oai format") - os.makedirs(os.path.dirname(output_path), exist_ok=True) - - with open(output_path, 'w', encoding='utf-8') as f: - for thread in threads: - formatted_thread = get_conversation_data(thread.contents) - if not formatted_thread: - continue - formatted_thread = format_conversation(formatted_thread, system_message) - f.write(json.dumps(formatted_thread) + '\n') - - for conversation in conversations: - formatted_conv = get_conversation_data(conversation) - if not formatted_conv: - continue - formatted_conv = format_conversation(formatted_conv, system_message) - f.write(json.dumps(formatted_conv) + '\n') - -def main(archive_path: str, output_dir: str, output_formats: List[str], system_message: str): - data = extract_archive_data(archive_path) - all_tweets = get_all_tweets(data) - threads, conversations = extract_threads_and_conversations(all_tweets) - - if 'markdown' in output_formats: - threads_output_dir = os.path.join(output_dir, 'threads') - images_folder = os.path.join(output_dir, 'images') - non_thread_output_dir = os.path.join(output_dir, 'tweets_by_date') - - os.makedirs(threads_output_dir, exist_ok=True) - os.makedirs(images_folder, exist_ok=True) - os.makedirs(non_thread_output_dir, exist_ok=True) - - logger.info(f"Saving {len(threads)} threads") - for i, thread in enumerate(threads, start=1): - save_thread_markdown( - thread, - threads_output_dir, - os.path.join(archive_path, 'data', 'tweets_media'), - images_folder - ) - if i % 10 == 0 or i == len(threads): - logger.info(f"Saved {i}/{len(threads)} threads") - - save_tweets_by_date(all_tweets, threads, non_thread_output_dir, images_folder) - - if 'oai' in output_formats: - output_path = os.path.join(output_dir, 'conversations_oai.jsonl') - save_conversations_to_jsonl(threads, conversations, output_path, system_message) - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Process Twitter archive") - parser.add_argument("--archive-path", default="test", help="Path to the Twitter archive directory") - parser.add_argument("--output-dir", default="output", help="Directory where outputs will be saved") - parser.add_argument("--output-formats", nargs='+', default=['markdown', 'oai'], - help="Output formats to generate (markdown, oai)") - parser.add_argument("--system-message", default="You have been uploaded to the internet", - help="System message for the conversation") - args = parser.parse_args() - - main(args.archive_path, args.output_dir, args.output_formats, args.system_message) diff --git a/seeker/snippet/exercises.py b/seeker/snippet/exercises.py deleted file mode 100644 index 5b47e5df..00000000 --- a/seeker/snippet/exercises.py +++ /dev/null @@ -1,149 +0,0 @@ -#date: 2024-11-19T17:07:01Z -#url: https://api.github.com/gists/9b99e4a21c927e54acaa5f2cdf1f3ee4 -#owner: https://api.github.com/users/IceryDev - -import math -import random -from time import sleep -import string - -def is_int_or_float(number, text: str, mode: bool): - if mode: - while True: - try: - float(number) - except ValueError: - number = input(text) - continue - break - return float(number) #Float - else: - while True: - try: - float(number) - except ValueError: - number = input(text) - continue - break - return int(number) #Int - -def p1(): - x = is_int_or_float(input("Enter an integer: "), "Invalid, enter a proper integer: ", False) - if x > 0: print("Positive") - elif x < 0: print("Negative") - else: print("Zero") - -def p2(): - x = is_int_or_float(input("Enter an integer: "), "Invalid, enter a proper integer: ", False) - if x % 2 == 0: print("Even") - else: print("Odd") - -def p3(): - x = is_int_or_float(input("Enter your age: "), "Invalid, enter a proper age: ", False) - if x >= 18: print("You are eligible to vote") - else: print("You are not eligible to vote") - -def p4(): - no_list: list[int] = [] - for a in range(3): - no_list.append(is_int_or_float(input(f"Enter integer {a + 1}: "), "Invalid, enter a proper integer: ", False)) - print(max(no_list[0], no_list[1], no_list[2])) - -def p5(): - x = is_int_or_float(input("Enter an integer: "), "Invalid, enter a proper integer: ", False) - if x % 3 == 0 and x % 5 == 0: print(f"{x} is divisible by both 3 and 5.") - elif x % 3 != 0 and x % 5 == 0: print(f"{x} is divisible by 5.") - elif x % 3 == 0 and x % 5 != 0: print(f"{x} is divisible by 3.") - else: print(f"{x} is not divisible by 5 and 3.") - -def p6(): - x = is_int_or_float(input("Enter your marks: "), "Invalid, enter a proper mark: ", True) - if x > 100: print("How did you get that mark????!!!!!") - elif x >= 90: print("A") - elif x >= 80: print("B") - elif x >= 70: print("C") - elif x >= 60: print("D") - elif x < 60: print("F") - -def p7(): - letter = input("Type a letter: ") - if letter.lower() in ["a", "e", "u", "i", "o"]: print("That is a vowel.") - elif letter.lower() in list(set(string.ascii_lowercase) - {"a", "e", "u", "i", "o"}): print("That is a consonant.") - else: print("That is not an English letter!!") - -def p8(): - x = is_int_or_float(input("Enter a year: "), "Invalid, enter a proper year: ", False) - if (x % 4 == 0 and x % 100 != 0) or x % 400 == 0: - print("Yay, that is a leap year!!") - else: - print("That is not a leap year.") - -def p9(): - x = is_int_or_float(input("Enter a temperature in Celsius: "), "Invalid, enter a proper temperature: ", True) - if x < -273: print("I see what you are doing... But I have thought of it. :)") - else: - a = (9 * x / 5) - 32 - print(f"The Fahrenheit value is {a} and it is ", end="") - if a < 32: print("freezing.") - elif a > 85: print("hot.") - else: print("moderate.") - -def p10(): - x = is_int_or_float(input("Enter an integer: "), "Invalid, enter a proper integer: ", False) - print(f"The number is {int(math.log10(x)) + 1} digits.") - -def p11(): - a = 1 - while a < 11: - print(a) - a += 1 - -def p12(): - a = 0 - s = 0 - while a < 100: - a += 1 - s = s + a - print(s) - -def p13(): - s = 0 - while True: - x = is_int_or_float(input("Enter an integer (0 to end process): "), "Invalid, enter a proper integer: ", False) - s += x - if x == 0: break - print(s) - -def p14(): - x = is_int_or_float(input("Enter an integer: "), "Invalid, enter a proper integer: ", False) - b = 0 - for a in range(1, 11): - b += 1 - if b % 3 == 0: - print(f"{x} x {a} = {x * a}") - else: - print(f"{x} x {a} = {x * a}", end=" // ") - -def p15(): - counter = 10 - while counter > 0: - print(counter) - sleep(1) - counter -= 1 - print("Blast off!") - -def p16(): - x = random.randint(1, 9) - y = is_int_or_float(input("Enter an integer: "), "Invalid, enter a proper integer: ", False) - while x != y: - print("Wrong!") - y = is_int_or_float(input("Enter an integer: "), "Invalid, enter a proper integer: ", False) - print("Correct! Well done!") - -while True: - user_input = is_int_or_float(input("Which program do you want to run (1-16, 0 to exit)? "), "Enter an integer. ->", False) - while not -1 < user_input < 17: - user_input = is_int_or_float(input("Which program do you want to run (1-16)? "), "Enter an integer. ->", False) - if user_input == 0: break - else: - globals()["p" + str(user_input)]() \ No newline at end of file diff --git a/seeker/snippet/extract_table_example.py b/seeker/snippet/extract_table_example.py deleted file mode 100644 index 06ba4ab3..00000000 --- a/seeker/snippet/extract_table_example.py +++ /dev/null @@ -1,26 +0,0 @@ -#date: 2024-11-19T17:00:33Z -#url: https://api.github.com/gists/9203619987005e067afcdb5ca695a99f -#owner: https://api.github.com/users/sdg-1 - -import pdfplumber -import PyPDF2 - -# Open the PDF file with PyPDF2 - -pdf_file = 'example.pdf' -pdf_reader = PyPDF2.PdfReader(pdf_file) - -# Extract text with PyPDF2 -full_text = "" - -for page in pdf_reader.pages: - full_text += page.extract_text()  # Extract text from each page - -print("Extracted Text:", full_text) - -# Extract tables with pdfplumber -with pdfplumber.open(pdf_file) as pdf: - for page in pdf.pages: - tables = page.extract_tables()  # Extract tables - for table in tables: - print("Extracted Table:", table)  # Print each table \ No newline at end of file diff --git a/seeker/snippet/gistfile1.txt b/seeker/snippet/gistfile1.txt index a9cfd4a3..4ca8a01b 100644 --- a/seeker/snippet/gistfile1.txt +++ b/seeker/snippet/gistfile1.txt @@ -1,155 +1,18 @@ -#date: 2024-11-20T17:11:55Z -#url: https://api.github.com/gists/971d90d09ed10abbe0af9ada8c345344 -#owner: https://api.github.com/users/yjm7026 +#date: 2024-11-21T16:54:14Z +#url: https://api.github.com/gists/baefea843da366a4949e94e67fce8c6a +#owner: https://api.github.com/users/AleksPopov4 -#!/bin/bash -# This file will be sourced in init.sh -# Namespace functions with provisioning_ +#! /bin/bash -### Edit the following arrays to suit your workflow - values must be quoted and separated by newlines or spaces. -DISK_GB_REQUIRED=30 +#sum all numbers from 0 to 1000 where a number can be divided by 3 or 5 but not both +sum=0 -APT_PACKAGES=( - # Add any APT packages if needed -) +for ((i=1; i<=1000; i++)); +do + if (( i % 3 == 0 && i % 5 != 0 )) || ((i % 5 == 0 && i % 3 != 0 )); + then + sum=$((sum + i)) + fi +done -PIP_PACKAGES=( - # Add any PIP packages if needed -) - -EXTENSIONS=( - "https://github.com/muerrilla/sd-webui-detail-daemon" - "https://github.com/bbc-mc/sd-webui-model-merger" # 모델 병합 확장 기능 - "https://github.com/deforum-art/sd-webui-deforum" - "https://github.com/adieyal/sd-dynamic-prompts" - "https://github.com/ototadana/sd-face-editor" - "https://github.com/AlUlkesh/stable-diffusion-webui-images-browser" - "https://github.com/hako-mikan/sd-webui-regional-prompter" - "https://github.com/Coyote-A/ultimate-upscale-for-automatic1111" - "https://github.com/Gourieff/sd-webui-reactor" -) - -CHECKPOINT_MODELS=( - "https: "**********" - "https: "**********" - "https: "**********" -) - -LORA_MODELS=( - # Add LoRA model URLs if needed later -) - -VAE_MODELS=( - "https: "**********" -) - -ESRGAN_MODELS=( - "https://huggingface.co/ai-forever/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth" - "https://huggingface.co/FacehugmanIII/4x_foolhardy_Remacri/resolve/main/4x_foolhardy_Remacri.pth" - "https://huggingface.co/Akumetsu971/SD_Anime_Futuristic_Armor/resolve/main/4x_NMKD-Siax_200k.pth" -) - -CONTROLNET_MODELS=( - # Add ControlNet model URLs if needed -) - -### DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ### -function provisioning_start() { - if [[ ! -d /opt/environments/python ]]; then - export MAMBA_BASE=true - fi - source /opt/ai-dock/etc/environment.sh - source /opt/ai-dock/bin/venv-set.sh webui - - DISK_GB_AVAILABLE=$(($(df --output=avail -m "${WORKSPACE}" | tail -n1) / 1000)) - DISK_GB_USED=$(($(df --output=used -m "${WORKSPACE}" | tail -n1) / 1000)) - DISK_GB_ALLOCATED=$(($DISK_GB_AVAILABLE + $DISK_GB_USED)) - provisioning_print_header - provisioning_get_apt_packages - provisioning_get_pip_packages - provisioning_get_extensions - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/ckpt" \ - "${CHECKPOINT_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/lora" \ - "${LORA_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/vae" \ - "${VAE_MODELS[@]}" - provisioning_get_models \ - "${WORKSPACE}/storage/stable_diffusion/models/esrgan" \ - "${ESRGAN_MODELS[@]}" - - PLATFORM_ARGS="" - if [[ $XPU_TARGET = "CPU" ]]; then - PLATFORM_ARGS="--use-cpu all --skip-torch-cuda-test --no-half" - fi - PROVISIONING_ARGS="--skip-python-version-check --no-download-sd-model --do-not-download-clip --port 11404 --exit" - ARGS_COMBINED="${PLATFORM_ARGS} $(cat /etc/a1111_webui_flags.conf) ${PROVISIONING_ARGS}" - - cd /opt/stable-diffusion-webui - if [[ -z $MAMBA_BASE ]]; then - source "$WEBUI_VENV/bin/activate" - LD_PRELOAD=libtcmalloc.so python launch.py \ - ${ARGS_COMBINED} - deactivate - else - micromamba run -n webui -e LD_PRELOAD=libtcmalloc.so python launch.py \ - ${ARGS_COMBINED} - fi - provisioning_print_end -} - -function provisioning_get_extensions() { - for repo in "${EXTENSIONS[@]}"; do - dir="${repo##*/}" - path="/opt/stable-diffusion-webui/extensions/${dir}" - if [[ -d $path ]]; then - if [[ ${AUTO_UPDATE,,} == "true" ]]; then - printf "Updating extension: %s...\n" "${repo}" - ( cd "$path" && git pull ) - fi - else - printf "Downloading extension: %s...\n" "${repo}" - git clone "${repo}" "${path}" --recursive - fi - done -} - -function provisioning_get_models() { - if [[ -z $2 ]]; then return 1; fi - dir="$1" - mkdir -p "$dir" - shift - arr=("$@") - printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir" - for url in "${arr[@]}"; do - printf "Downloading: %s\n" "${url}" - provisioning_download "${url}" "${dir}" - done -} - -function provisioning_download() { - wget -qnc --content-disposition --show-progress -P "$2" "$1" -} - -provisioning_start -ioning_get_models() { - if [[ -z $2 ]]; then return 1; fi - dir="$1" - mkdir -p "$dir" - shift - arr=("$@") - printf "Downloading %s model(s) to %s...\n" "${#arr[@]}" "$dir" - for url in "${arr[@]}"; do - printf "Downloading: %s\n" "${url}" - provisioning_download "${url}" "${dir}" - done -} - -function provisioning_download() { - wget -qnc --content-disposition --show-progress -P "$2" "$1" -} - -provisioning_start +echo "$sum" \ No newline at end of file diff --git a/seeker/snippet/interactive_gradio_using_blocks.py b/seeker/snippet/interactive_gradio_using_blocks.py deleted file mode 100644 index 1f0c86e7..00000000 --- a/seeker/snippet/interactive_gradio_using_blocks.py +++ /dev/null @@ -1,36 +0,0 @@ -#date: 2024-11-19T17:04:12Z -#url: https://api.github.com/gists/ef4902a3d9b55a833354a3c84cab9828 -#owner: https://api.github.com/users/agatheminaro - -import gradio as gr - - -def greet( - name: str, - temperature: int, - is_morning: bool, -) -> tuple[str, float]: - """Greet the user with a message and the temperature in Celsius.""" - salutation = "Good morning" if is_morning else "Good evening" - greeting = f"{salutation} {name}. It is {temperature} Fahrenheit today." - celsius = round((temperature - 32) * 5 / 9, 2) - return greeting, celsius - - -with gr.Blocks() as demo: - with gr.Row(): - with gr.Column(): - input_name = gr.Textbox(label="Enter your name") - input_temperature = gr.Slider(0, 100, label="What is the temperature?") - input_is_morning = gr.Checkbox(label="Is it morning?") - with gr.Column(): - greeting_output = gr.Textbox(label="Greeting") - celsius_output = gr.Number(label="Temperature in Celsius") - button = gr.Button(value="Greet") - button.click( - greet, - inputs=[input_name, input_temperature, input_is_morning], - outputs=[greeting_output, celsius_output], - ) - -demo.launch() \ No newline at end of file diff --git a/seeker/snippet/main.py b/seeker/snippet/main.py index f1dc10fe..289853b8 100644 --- a/seeker/snippet/main.py +++ b/seeker/snippet/main.py @@ -1,12 +1,24 @@ -#date: 2024-11-19T17:10:34Z -#url: https://api.github.com/gists/40b980eadde4a630c8fd8dae655bce4e +#date: 2024-11-21T16:58:41Z +#url: https://api.github.com/gists/2ac3079d8938fa160857862bd1178f4b #owner: https://api.github.com/users/mypy-play -# mypy: enable-error-code="possibly-undefined" -def func(flag: bool) -> str: - if flag: - name = "Name" - return name - - -func(False) \ No newline at end of file +from typing import Any +from collections.abc import Callable +import inspect + + +class CallableClass: + def __init__(self) -> None: + pass + + def __call__(self, *args: Any, **kwargs: Any) -> None: + return None + + + +assert callable(CallableClass) # Success + + +callable_instance = CallableClass() +assert isinstance(callable_instance, Callable[..., None]) # Errors +assert isinstance(callable_instance, Callable) # Also erros \ No newline at end of file diff --git a/seeker/snippet/openwrt-lede-on-pogoplug-mobile.sh b/seeker/snippet/openwrt-lede-on-pogoplug-mobile.sh deleted file mode 100644 index 81880534..00000000 --- a/seeker/snippet/openwrt-lede-on-pogoplug-mobile.sh +++ /dev/null @@ -1,140 +0,0 @@ -#date: 2024-11-19T17:12:06Z -#url: https://api.github.com/gists/88b0048d567fc5ef60be8f668ac67080 -#owner: https://api.github.com/users/zichuan-li - -# --------------------------------------------------------------------------------- -# Device - PogoPlug Mobile - Install OpenWrt on internal flash (128mb) and keep allowing boot to SD or USB -# --------------------------------------------------------------------------------- -http://blog.qnology.com/2015/02/openwrt-on-pogoplug-mobile.html - -# Corrected URLs, because download.qnology.com is down: -http://ssl.pepas.com/pogo/mirrored/download.qnology.com/pogoplug/v4/ - -cd /tmp -#wget http://ssl.pepas.com/pogo/mirrored/download.qnology.com/pogoplug/v4/fw_printenv -#wget http://ssl.pepas.com/pogo/mirrored/download.qnology.com/pogoplug/v4/fw_setenv -#chmod +x fw_setenv - -apt-get update -apt-get install u-boot-tools - -# setup fw_env.config -echo "/dev/mtd0 0xc0000 0x20000 0x20000">/etc/fw_env.config - -# 1MB for the uBoot, the rest for rootfs (~122MB) -/tmp/fw_setenv mtdparts 'mtdparts=orion_nand:1M(u-boot),-(rootfs)' - -# This reboot is important -reboot - -cat /proc/mtd -#dev: size erasesize name -#mtd0: 00100000 00020000 "u-boot" -#mtd1: 07f00000 00020000 "rootfs" - -apt-get update -apt-get install mtd-utils -# with mtd-utils we will have ubiattach, ubimkvol, ubiformat: -#wget http://ssl.pepas.com/pogo/mirrored/download.qnology.com/pogoplug/v4/ubiattach -#wget http://ssl.pepas.com/pogo/mirrored/download.qnology.com/pogoplug/v4/ubimkvol -#wget http://ssl.pepas.com/pogo/mirrored/download.qnology.com/pogoplug/v4/ubiformat - - -ubiformat /dev/mtd1 -#ubiformat: mtd1 (nand), size 133169152 bytes (127.0 MiB), 1016 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes -#libscan: scanning eraseblock 1015 -- 100 % complete -#ubiformat: 896 eraseblocks have valid erase counter, mean value is 0 -#ubiformat: 86 eraseblocks are supposedly empty -#ubiformat: 2 bad eraseblocks found, numbers: 25, 26 -#ubiformat: warning!: 32 of 1014 eraseblocks contain non-UBI data -#ubiformat: continue? (y/N) -y -#ubiformat: warning!: only 896 of 1014 eraseblocks have valid erase counter -#ubiformat: mean erase counter 0 will be used for the rest of eraseblock -#ubiformat: continue? (y/N) -y -#ubiformat: use erase counter 0 for all eraseblocks -#ubiformat: warning!: VID header and data offsets on flash are 2048 and 4096, which is different to requested offsets 512 and 2048 -#ubiformat: use new offsets 512 and 2048? ubiformat: continue? (y/N) -y -#ubiformat: use offsets 512 and 2048 -#ubiformat: formatting eraseblock 1015 -- 100 % complete -ubiattach -p /dev/mtd1 -#UBI device number 0, total 1014 LEBs (130830336 bytes, 124.8 MiB), available 992 LEBs (127991808 bytes, 122.1 MiB), LEB size 129024 bytes (126.0 KiB) -ubimkvol /dev/ubi0 -m -N rootfs -#Set volume size to 127991808 -# Volume ID 0, size 992 LEBs (127991808 bytes, 122.1 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs", alignment 1 -mkdir /tmp/ubi -mount -t ubifs ubi0:rootfs /tmp/ubi - -# Corrected URLs, because 15.05.1 is newer than 15.05 (we could use LEDE too if it is available) -cd /tmp -wget http://downloads.openwrt.org/chaos_calmer/15.05.1/kirkwood/generic/openwrt-15.05.1-kirkwood-generic-rootfs.tar.gz -wget http://downloads.openwrt.org/chaos_calmer/15.05.1/kirkwood/generic/openwrt-15.05.1-kirkwood-zImage -wget http://downloads.openwrt.org/chaos_calmer/15.05.1/kirkwood/generic/md5sums - -# check that zImage and rootfs.tar.gz are OK -md5sum -c md5sums 2>/dev/null | grep OK - -# extract rootfs.tar.gz to ubi rootfs at /tmp/ubi -cd /tmp/ubi -tar xvzf /tmp/openwrt*rootfs.tar.gz - -mkdir boot -mv /tmp/openwrt*kirkwood-zImage ./boot/zImage - -#FDT from http://forum.doozan.com/read.php?2,12096 - -# This, instead of download it we already have it so we copy it : -# link down: http://download.qnology.com/pogoplug/v4/kirkwood-pogoplug_v4.dtb -#cd boot; wget http://download.qnology.com/pogoplug/v4/kirkwood-pogoplug_v4.dtb -cd boot -cp /boot/dts/kirkwood-pogoplug_v4.dtb ./kirkwood-pogoplug_v4.dtb - -sync -cd / -umount /tmp/ubi - -# Setup uBoot Environment -# Cut and Paste this whole section -fw_setenv fdt_file '/boot/kirkwood-pogoplug_v4.dtb' -fw_setenv loadaddr '0x800000' -fw_setenv zimage '/boot/zImage' -fw_setenv fdt_addr '0x1c00000' -fw_setenv loadubi 'echo Trying to boot from NAND ...;if run mountubi; then run loadubizimage;run loadubifdt;ubifsumount;run bootzubi;fi' -fw_setenv mountubi 'ubi part rootfs; ubifsmount ubi0:rootfs' -fw_setenv loadubizimage 'ubifsload ${loadaddr} ${zimage}' -fw_setenv loadubifdt 'ubifsload ${fdt_addr} ${fdt_file}' -fw_setenv bootzubi 'echo Booting from nand ...; run setargsubi; bootz ${loadaddr} - ${fdt_addr};' -fw_setenv setargsubi 'setenv bootargs console=${console},${baudrate} ${optargs} ubi.mtd=1 root=ubi0:rootfs rw rootfstype=ubifs rootwait ${mtdparts}' - -# Setup boot order. -# USB->SD->SATA->UBI/NAND -fw_setenv bootcmd 'run bootcmd_usb; run bootcmd_mmc; run bootcmd_sata; run loadubi; reset' - -#poweroff Pogoplug and remove SD Card and USB flash drive. -poweroff - -# So far it works perfectly, without SD / USB it boots to OpenWrt and with Debian SD it boots to Debian -# Important: It will not work if you use an SD that was previusly used on another Pogo Device. -# the ethernet it wont work. - -# Now OpenWRT will have as usual IP 192.168.1.1 with DHCP server enabled -# we will have to disable DHCP server, and configure to get automatic IP from DHCP, and assign a password -telnet 192.168.1.1 - -#####Initial Boot via Telnet###### -#set passwd and enable ssh -passwd - -# Reconfigure Network to DHCP Client -# disable dhcp server on lan -uci set dhcp.lan.ignore='1' -uci set network.lan.proto='dhcp' -uci del network.lan.ipaddr -uci del network.lan.netmask -uci commit dhcp -uci commit network -sync -/etc/init.d/dnsmasq restart -reboot diff --git a/seeker/snippet/phton.py b/seeker/snippet/phton.py new file mode 100644 index 00000000..72d0c22c --- /dev/null +++ b/seeker/snippet/phton.py @@ -0,0 +1,5 @@ +#date: 2024-11-21T17:12:44Z +#url: https://api.github.com/gists/0fdde16782b752b5fd8b1c9a9b752625 +#owner: https://api.github.com/users/Evan-brnt + +from math import * diff --git a/seeker/snippet/ping_starter.py b/seeker/snippet/ping_starter.py deleted file mode 100644 index 33ab01a6..00000000 --- a/seeker/snippet/ping_starter.py +++ /dev/null @@ -1,100 +0,0 @@ -#date: 2024-11-19T16:46:18Z -#url: https://api.github.com/gists/fa02f816478b9ce36250c8f2d623db02 -#owner: https://api.github.com/users/dulimarta - -from socket import gethostbyname, getprotobyname, socket, SOCK_RAW, AF_INET, htons, inet_ntoa -from os import getpid -import sys -from struct import pack, unpack_from -from time import time, sleep -from select import select - -ICMP_ECHO_REQUEST = 8 - -def checksum(sdata): - csum = 0 - - # Pad with zero if we have odd number of bytes - if len(sdata) % 2: - data += b'\x00' - - for i in range(0, len(sdata), 2): - # Take each 16-bit as an unsigned integer - word = (sdata[i] << 8) + sdata[i+1] - csum += word - # Add back the carry value to the current sum - csum = (csum >> 16) + (csum & 0xFFFF) - # Just in case the above sum has carry bits - csum = csum + (csum >> 16) - - # Return the lowest 16 bits of the 1s complement - return ~csum & 0xFFFF - -def receiveOnePing(mySocket, ID, timeout, destAddr): - timeLeft = timeout - while True: - startedSelect = time() - whatReady = select([mySocket], [], [], timeout) - howLongInSelect = time() - startedSelect - if whatReady[0] == []: - timeLeft = timeLeft - howLongInSelect - if timeLeft <= 0: - print ("Timeout") - return None # timeout - else: - break - timeReceived = time() - recPacket,addr = mySocket.recvfrom(1024) - ## BEGIN: your code - ## Fetch the IP header fields - ## Fetch the ICMP header fields - print ("Your work here") - ## END: your code - return 0 - -def sendOnePing(mySocket, destAddr, ID): - - # ICMP header fields: - # type (1 byte) - # code (1 byte) - # checksum (2 bytes) - # id (2 bytes) - # sequence (2 bytes) - - # Make a dummy header with 0 checksum - myChecksum = 0 - header = pack("bbHHH", ICMP_ECHO_REQUEST, 0, myChecksum, ID, 1) - data = pack("d", time()) - # calculate the checksum on the header and dummy data - myChecksum = checksum(header+data) - header = pack("bbHHH", ICMP_ECHO_REQUEST, 0, htons(myChecksum), ID, 1) - packet = header+data - mySocket.sendto(packet, (destAddr, 1)) - -def doOnePing(destAddr, timeout): - icmp = getprotobyname("icmp") - mySocket = socket(AF_INET, SOCK_RAW, icmp) - # Use the lowest 16-bit of the PID - myID = getpid() & 0xFFFF - sendOnePing(mySocket, destAddr, myID) - rtt = receiveOnePing(mySocket, myID, timeout, destAddr) - mySocket.close() - return rtt - -def ping(host, timeout=1): - try: - dest = gethostbyname(host) - print (f"Pinging {host}") - while True: - doOnePing(dest, timeout) - sleep(1) - except Exception as e: - print(f"Exception: {e}") - except KeyboardInterrupt: - print("\nShow summary here") - -if __name__ == "__main__": - if len(sys.argv) < 2: - print(f"Use {sys.argv[0]} hostname") - else: - ping(sys.argv[1]) diff --git a/seeker/snippet/process_better.py b/seeker/snippet/process_better.py deleted file mode 100644 index c53684dd..00000000 --- a/seeker/snippet/process_better.py +++ /dev/null @@ -1,119 +0,0 @@ -#date: 2024-11-19T17:00:50Z -#url: https://api.github.com/gists/085cd216d9276551678bfb148e2e9dc4 -#owner: https://api.github.com/users/NostraDavid - -# /// script -# requires-python = ">=3.13" -# dependencies = [ -# "polars", -# ] -# /// -from pathlib import Path -from typing import OrderedDict -import polars as pl - -PROJECT = Path().cwd() - -basepath = PROJECT / "jobs" - -# Read the CSV file into a Polars DataFrame -df = pl.scan_csv( - f"{basepath}/demographic_divident.csv", - schema=OrderedDict( - [ - ("SortOrder", pl.Int64), - ("LocID", pl.Int64), - ("Notes", pl.String), - ("ISO3_code", pl.String), - ("ISO2_code", pl.String), - ("SDMX_code", pl.Int64), - ("LocTypeID", pl.Int64), - ("LocTypeName", pl.String), - ("ParentID", pl.Int64), - ("Location", pl.String), - ("VarID", pl.Int64), - ("Variant", pl.String), - ("Time", pl.Int64), - ("TPopulation1Jan", pl.Float64), - ("TPopulation1July", pl.Float64), - ("TPopulationMale1July", pl.Float64), - ("TPopulationFemale1July", pl.Float64), - ("PopDensity", pl.Float64), - ("PopSexRatio", pl.Float64), - ("MedianAgePop", pl.Float64), - ("NatChange", pl.Float64), - ("NatChangeRT", pl.Float64), - ("PopChange", pl.Float64), - ("PopGrowthRate", pl.Float64), - ("DoublingTime", pl.Float64), - ("Births", pl.Float64), - ("Births1519", pl.Float64), - ("CBR", pl.Float64), - ("TFR", pl.Float64), - ("NRR", pl.Float64), - ("MAC", pl.Float64), - ("SRB", pl.Float64), - ("Deaths", pl.Float64), - ("DeathsMale", pl.Float64), - ("DeathsFemale", pl.Float64), - ("CDR", pl.Float64), - ("LEx", pl.Float64), - ("LExMale", pl.Float64), - ("LExFemale", pl.Float64), - ("LE15", pl.Float64), - ("LE15Male", pl.Float64), - ("LE15Female", pl.Float64), - ("LE65", pl.Float64), - ("LE65Male", pl.Float64), - ("LE65Female", pl.Float64), - ("LE80", pl.Float64), - ("LE80Male", pl.Float64), - ("LE80Female", pl.Float64), - ("InfantDeaths", pl.Float64), - ("IMR", pl.Float64), - ("LBsurvivingAge1", pl.Float64), - ("Under5Deaths", pl.Float64), - ("Q5", pl.Float64), - ("Q0040", pl.Float64), - ("Q0040Male", pl.Float64), - ("Q0040Female", pl.Float64), - ("Q0060", pl.Float64), - ("Q0060Male", pl.Float64), - ("Q0060Female", pl.Float64), - ("Q1550", pl.Float64), - ("Q1550Male", pl.Float64), - ("Q1550Female", pl.Float64), - ("Q1560", pl.Float64), - ("Q1560Male", pl.Float64), - ("Q1560Female", pl.Float64), - ("NetMigrations", pl.Float64), - ("CNMR", pl.Int64), - ] - ), -) - - -# Average Life Expectancy by Location -avg_life_expectancy = ( - df.group_by("Location") - .agg(pl.col("LEx").mean().alias("AvgLifeExpectancy")) - .sort("Location") -) - -# Save average life expectancy to CSV -avg_life_expectancy.sink_csv(f"{basepath}/out/avg_life_expectancy.csv") - -# Total Births and Deaths by Location -total_births_deaths = ( - df.group_by("Location") - .agg( - [ - pl.col("Births").sum().alias("TotalBirths"), - pl.col("Deaths").sum().alias("TotalDeaths"), - ] - ) - .sort("Location") -) - -# Save total births and deaths to CSV -total_births_deaths.sink_csv(f"{basepath}/out/total_births_deaths.csv") diff --git a/seeker/snippet/simple_gradio_interface.py b/seeker/snippet/simple_gradio_interface.py deleted file mode 100644 index 754d4f3b..00000000 --- a/seeker/snippet/simple_gradio_interface.py +++ /dev/null @@ -1,17 +0,0 @@ -#date: 2024-11-19T16:46:22Z -#url: https://api.github.com/gists/c3140dec7302ec6cae3e0a1da1f176dc -#owner: https://api.github.com/users/agatheminaro - -from __future__ import annotations - -import gradio as gr -import numpy as np - - -def image_classifier(input_image: np.ndarray) -> dict[str, float]: - """Output a dummy probabilitie for the image to be a dog or a cat.""" - return {"cat": 0.3, "dog": 0.7} - - -demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label") -demo.launch() \ No newline at end of file diff --git a/seeker/snippet/simple_interactive_gradio_interface.py b/seeker/snippet/simple_interactive_gradio_interface.py deleted file mode 100644 index 8fe8fe75..00000000 --- a/seeker/snippet/simple_interactive_gradio_interface.py +++ /dev/null @@ -1,30 +0,0 @@ -#date: 2024-11-19T16:57:06Z -#url: https://api.github.com/gists/e0d4c68957adbdb0d8a80117279ef6c9 -#owner: https://api.github.com/users/agatheminaro - -import gradio as gr - - -def greet( - name: str, - temperature: int, - is_morning: bool, -) -> tuple[str, float]: - """Greet the user with a message and the temperature in Celsius.""" - salutation = "Good morning" if is_morning else "Good evening" - greeting = f"{salutation} {name}. It is {temperature} Fahrenheit today." - celsius = round((temperature - 32) * 5 / 9, 2) - return greeting, celsius - - -demo = gr.Interface( - fn=greet, - inputs=[ - gr.Text(label="What is your name?"), - gr.Slider(0, 100, label="What is the temperature?"), - gr.Checkbox(label="Is it morning?"), - ], - outputs=[gr.Text(label="Greeting"), gr.Number(label="Temperature in Celsius")], -) -if __name__ == "__main__": - demo.launch() \ No newline at end of file diff --git a/seeker/snippet/torch_device.py b/seeker/snippet/torch_device.py deleted file mode 100644 index 8af2c4ed..00000000 --- a/seeker/snippet/torch_device.py +++ /dev/null @@ -1,13 +0,0 @@ -#date: 2024-11-19T16:50:48Z -#url: https://api.github.com/gists/5b558e0a552627efb1c2d54b90a7cec6 -#owner: https://api.github.com/users/vadim0x60 - -def torch_device(): - import torch - t = torch.Tensor([0]) - for device in ['xla', 'cuda', 'mps', 'xpu', 'cpu']: - try: - t.to(device) - return torch.device(device) - except RuntimeError: - pass \ No newline at end of file diff --git a/seeker/snippet/validate.go b/seeker/snippet/validate.go deleted file mode 100644 index 93a02f60..00000000 --- a/seeker/snippet/validate.go +++ /dev/null @@ -1,29 +0,0 @@ -//date: 2024-11-19T17:11:11Z -//url: https://api.github.com/gists/9fdd16fb5d2d8e610e0a6f3fd1eb28a0 -//owner: https://api.github.com/users/jclem - -func (c Collection) Validate() error { - v := vld.New() - strlen := vld.StrLen(1, 64) - - v.Validate( - []string{"name"}, - strlen(c.Name), - ) - - v.Validate( - []string{"tags", "key"}, - vld.MapKeys[string, string](strlen)(c.Tags), - ) - - v.Validate( - []string{"tags", "value"}, - vld.MapValues[string](strlen)(c.Tags), - ) - - if err := v.GetError(); err != nil { - return fmt.Errorf("validate collection: %w", err) - } - - return nil -} \ No newline at end of file