tectudssr
App updated 10.10.2020
(added word wrap function)
I’ve created an Android App, shortly after A.VCE+ dead.
tectudssr cannot show pictures and can’t doing a lot of other things, but it serves me faithfully for text quizes.
Download the latest APK – v. 2.36
How to use the Application?
1. Install SumatraPDF
2. Open the pdf-test from gratisExam (didn’t tested other pdf-s) using SumatraPDF, “Save as” -> “Save as .txt”
3. Удаляю из этого текстового файла вопросы в которых нет вариантов ответа или правильного ответа (редко).
4. Rename this file to tect.txt and move it to the Download folder of tablets sd-card
Back – swipe left or Vol+
Forward – swipe right or Vol-
I’m choosing right answers (checkboxes or radiobuttons depends on answers)
now, tectudssr will show correct answers – click the bottom middle button (or swipe up):
In cases of segmentation faults, incorrect quiz parsing (and so on) leave a comment or write a mail (attach the pdf).
Android v6+ required.
Previous version: tectudssr-2.11.apk.
Parse XLS using openpyxl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
#1. Entferne non SAP/AEB Services #2. Lösche Übersicht Seite #3. Speichern als xls #4. Konvertieren xls to xlsx #5. Speichern als \\SAP\SD import openpyxl, win32com.client, calendar, pandas as pd, datetime as dt from datetime import datetime from datetime import date xlapp = win32com.client.DispatchEx("Excel.Application") print('Aktualisierung xlsx...') wbr = xlapp.Workbooks.Open('C:\Documents\Statistik Loader.xlsx') wbr.RefreshAll() xlapp.CalculateUntilAsyncQueriesDone() wbr.Save() print('Aktualisierung ist fertig.') xlapp.Quit() print('Lesen die xlsx Datei...') df = pd.read_excel('Statistik Loader.xlsx', 'Quelldaten', index_col=None, na_values=['NA']) df = df.drop(df[(df['State'] == 'closed')].index) df = df.drop(df[(df['Queue'] != '[1] Second Level::SAP') & (df['Queue'] != '[2] Third Level::SAP')].index) print('Reinigung xlsx...') writer = pd.ExcelWriter('Statistik.xlsx') df.to_excel(writer, 'Quelldaten', index=False) writer.save() print('Reinigung ist fertig.') Woerterbuch = { 'SD-EU': 0, 'JIS': 0, 'IAU240': 0, 'JAVA-Entwicklung': 0, 'Preisfindung': 0, 'LO-Logistik': 0, 'EDIFACT-Mapping': 0, 'IDocs': 0, 'EDI': 0, 'ABAP': 0, 'SAP-Basis': 0, 'Vertrieb': 0 } Dienste = { '[T000] SAP::JIT': 0 } for Wort in Woerterbuch: Wort = '[T000] SAP::' + Wort Dienste[Wort] = 0 class switch(object): value = None def __new__(class_, value): class_.value = value return True def case(*args): return any((arg == switch.value for arg in args)) wb = openpyxl.load_workbook('Statistik.xlsx') ws = wb['Quelldaten'] print('Kalkulation...') for cell in ws['I']: if str(cell.value) in Dienste: Dienste [str(cell.value)] += 1 ws = wb.create_sheet('T000') i = 0 for dienstName in Dienste: i += 1 ws.cell(row=i, column=1).value = dienstName ws.cell(row=i, column=2).value = Dienste[dienstName] currentdate = datetime.today().strftime('%d.%m.%Y') wb.save('\\\\java.sap.sd\DFS-Abteilungen$\SAP\SD\\' + currentdate + '.xlsx') print('File \\\\java.sap.sd\DFS-Abteilungen$\SAP\SD\\' + currentdate + '.xlsx ist gespeichert.') d,m,y = currentdate.split('.') woche = dt.date(int(y),int(m),int(d)).strftime("%V") monat = calendar.month_name[int(m)] outlook = win32com.client.Dispatch('outlook.application') mail = outlook.CreateItem(0) mail.To = 'uchla@feedback' mail.Subject = 'Die Liste Woche #' + woche + ', ' + monat mail.HtmlBody = 'Hallo, die Datei S:\SAP\SD\\' + currentdate + '.xlsx ist fertig. \r\n Viele Grüße \r\n' mail.Display(True) |
Change date on Vanilla Forum
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.*; import java.sql.Statement; public class vanied { Connection Verbindung; Statement stmt; vanied() { try { Class.forName("com.mysql.cj.jdbc.Driver"); Verbindung = DriverManager.getConnection("jdbc:mysql://java.www:3306/db-name?serverTimezone=UTC","db-benutzer","db-kennwort"); stmt = Verbindung.createStatement(); } catch(SQLException | ClassNotFoundException e){ System.out.println(e); } } void updateTopic(String ID, String Author, String dt) throws SQLException { String query = "UPDATE GDN_Discussion set DateInserted=" + dt + " where DiscussionID=" + ID + ";"; if ("" != Author) // das ist ein Kommentar query = "UPDATE GDN_Comment set InsertUserID=" + Author + ", DateInserted=" + dt + " where CommentID=" + ID + ";"; stmt.executeUpdate(query); } String benutzerExist(String benutzerName){ String benutzerID = ""; try { ResultSet rs = stmt.executeQuery("SELECT UserID FROM GDN_User WHERE Name=\"" + benutzerName + "\";"); while (rs.next()) { benutzerID = rs.getString("UserID"); } } catch (SQLException e) { System.out.println(e); } return benutzerID; } int maxBenutzerID(){ try { ResultSet rs = stmt.executeQuery("SELECT MAX(UserID) FROM GDN_User;"); while (rs.next()) { return rs.getInt("UserID"); } } catch (SQLException e) { System.out.println("Houston, wir haben ein Problem: " + e); } return 0; } String regBenutzerName(String benutzerName) { String benutzer = benutzerExist(benutzerName); if (benutzer != "") return benutzer; String kennwort = "neues-kennwort"; String query = "INSERT INTO GDN_User (UserID, Name, Password, HashMethod, Email, ShowEmail, Gender, CountVisits, " + "CountInvitations, Permissions, Attributes, HourOffset, Admin, Banned, Deleted) " + "VALUES(" + maxBenutzerID()+1 + ",\"" + benutzerName + "\", \"" + kennwort + "\", Vanilla, 'generiert@e-mail.www', 0, m, 0, 0, '', '', 2, 0, 0, 0);"; try { stmt.executeUpdate(query); return String.valueOf(maxBenutzerID()+1); } catch (SQLException e) { System.out.println("Houston, wir haben ein Problem: " + e); } return ""; } } |
To launch files from Chrome’s context menu, I’ve registered a simple new URI handler: https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85) i.e. vanied:
Add to Windows registry:
1 2 3 4 5 6 7 8 9 10 |
HKEY_CLASSES_ROOT vanied (Default) = "URL:Vanied Protocol" URL Protocol = "" DefaultIcon (Default) = "java.exe,1" shell open command (Default) = "C:\openjdk-15.0.1\bin\java.exe" --module-path C:\Users\User\IdeaProjects\javafx-sdk-11.0.2\lib --add-modules javafx.controls,javafx.fxml -jar "C:\Users\User\IdeaProjects\vanied\out\artifacts\vanied_jar\vanied.jar" "%1" |
Context Menu Editor plugin for Chrome: cme3.4.0.cab
After installing right click on Options:
Add new item
Edit and apply. Except info.linkUrl there are number of different data: https://developer.chrome.com/extensions/contextMenus#property-onclick-info
Процентиль, JSON
Процентиль – показатель того, какой процент значений находится ниже определённого уровня. Например, значение 50-й процентили указывает, что 50% значений располагается ниже этого уровня.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package com.tickets; import java.io.IOException; import java.text.ParseException; public class Main { public static void main(String[] args) throws IOException, ParseException { /* Напишите программу, которая прочитает файл tickets.json и рассчитает: - среднее время полета между городами Хабаровск и Хайфа - 90-й процентиль времени полета между городами Хабаровск и Хайфа Программа должна вызываться из командной строки Linux, результаты должны быть представлены в текстовом виде */ percentileAverage centile = new percentileAverage("/home/ruslan/tickets.json", "bookno", "Хабаровск", "Хайфа"); System.out.println("Среднее время полета: " + centile.getAverage() + " минут"); // для 100 чисел - сортируем и берем 90-е число (90-й процентиль) System.out.println("90-й процентиль времени полета: " + centile.getPercentile() + " минут"); System.in.read(); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
package com.tickets; import org.json.JSONObject; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class percentileAverage { private int Average; private int Percentil; private String jsonStr; private JSONObject jsonObj; private Iterator<String> keys; private List<Long> timeList = new ArrayList<>(); percentileAverage(String fn, String key, String city1, String city2) { try { jsonStr = Files.readString(Path.of(fn)); JSONObject mainObj = new JSONObject(jsonStr); jsonObj = mainObj.getJSONObject(key); filter(city1, city2); } catch (IOException e) { e.printStackTrace(); } } private void filter(String city1, String city2) { String depcity, arrcity, key; keys = jsonObj.keys(); while (keys.hasNext()) { key = keys.next(); if (jsonObj.get(key) instanceof JSONObject) { depcity = getVal(key, "depcity"); arrcity = getVal(key, "arrcity"); if ( (depcity.equals(city1) && arrcity.equals(city2)) || (depcity.equals(city2) && arrcity.equals(city1)) ) { timeList.add( flightInMinutes(getVal(key, "deptime"), getVal(key, "arrtime"))); } else keys.remove(); } } } protected long flightInMinutes(String deptime, String arrtime){ SimpleDateFormat df = new SimpleDateFormat("HH:mm"); Date arrTime = null, depTime = null; try { depTime = df.parse(deptime); arrTime = df.parse(arrtime); } catch (ParseException e) { e.printStackTrace(); } long diffTime = arrTime.getTime() - depTime.getTime(); return diffTime/60000; } private String getVal(String key, String name){ return ((JSONObject) jsonObj.get(key)).getString(name); } public int getAverage() { int sum = 0; for(int i=0; i<timeList.size(); i++){ sum = (int) (sum + timeList.get(i)); } Average = sum/timeList.size(); return Average; } public int getPercentile() { Collections.sort(timeList); int index = (int) Math.ceil(90 / 100.0 * timeList.size()); Percentil = Math.toIntExact(timeList.get(index - 1)); return Percentil; } } |
pom.xml:
1 2 3 4 5 6 7 8 9 |
<dependencies> ... <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20210307</version> </dependency> ... </dependencies> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
"bookno":{ "b1": { "deptime": "00:10", "depcity": "Хабаровск", "arrcity": "Хайфа", "arrtime": "13:12" }, "b2": { "deptime": "00:20", "depcity": "Находка", "arrcity": "Назарет", "arrtime": "13:33", }, "b3": { "deptime": "00:25", "depcity": "Уссурийск", "arrcity": "Иерусалим", "arrtime": "13:34" } ... } |