Jump to content

AnotherMax

Member
  • Posts

    25
  • Joined

  • Last visited

Everything posted by AnotherMax

  1. If you want to store it in a database you can use: Neo4J which is a graph database letting you store "nodes" and "links". Alternativly and probably simpler, you can use graphviz which I use the python library (pypi) to parse graphs / construct and parse etc. These can be saved to ".dot" files and uses the "DOT Language".
  2. I assume you noticed that the `public float breakForce = 100f;` isn't actually being used on line 54. Not super familier with Unity but you could try setting a negative motorTorque or value far exceeding "3500f". Or could be something to do with the "Slip based friction model" -> https://docs.unity3d.com/2020.1/Documentation/ScriptReference/WheelCollider.html
  3. So v1 has this "flat" keyword but v2 doesn't. You can see this in the v1.5.x docs:https://v15.vuetifyjs.com/en/components/buttons#flat I'm guessing the reason there are subtlties between v1 and v2 is simply the implementation between to the two. You could inspect the code e.g. the css output and compare them to find the differences. There is also this https://vuetifyjs.com/en/getting-started/upgrade-guide/#upgrading-from-v1-5-x-to-v2-0-x which you might find useful if you have more components to move across.
  4. It should be implemented out of the box. https://openlayers.org/en/latest/apidoc/module-ol_interaction.html https://openlayers.org/en/latest/apidoc/module-ol_interaction_PinchZoom-PinchZoom.html I assume you're using a somewhat recent version. You could try and hook into the 'on' call and do a console log. Last thing to check is whether it's supported on your device? If you're using an old device with old browers, could cause issues: https://caniuse.com/touch
  5. If you use the keywords 'text tile' on the v-btn e.g. <v-btn text tile v-for="item in nav" :key="item.icon" to="#" :title="item.title">{{ item.text }}</v-btn> That should be very similar. The docs are very good as they are interactive and let you see all the options for components: https://vuetifyjs.com/en/components/buttons/#usage Here explains what the two "text + tile" actually do: https://vuetifyjs.com/en/components/buttons/#text
  6. Yeah that's sounds tricky, sorry I couldn't help out more! Maybe a naive appoarch, but couldn't you brute force it? e.g. the DataView will have a limited amout of bytes and I suppose you could observe the changing value.
  7. Can't say I'm brushed up on this but looked quite interesting, did a little digging and saw this example: https://developer.mozilla.org/en-US/docs/Web/API/BluetoothCharacteristicProperties If I understand correctly you're just trying to read the data from the cscMeasurement? The above implies that the `event?.target` has a 'value' (Not a DataView?). I came across this as well: https://googlechrome.github.io/samples/web-bluetooth/discover-services-and-characteristics.html?optionalServices=link_loss Might help you debug ~ though that just seems to show the properties of a given characteristic - probably easy to modify.
  8. Take a look at the top of the code that's commented out. Personally, I'd take an approach where you create an array of struct such as that and store all the data within those: e.g. #include "Keyboard.h" int keys[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; // A nicer way would be to include an array of something like so struct KeyThing { int pin; char keyToPress; boolean isActive; }; KeyThing allKeys[12]; void setup() { Keyboard.begin(); // '1' starts at the decimal number 49 int x = 49; // https://www.ibm.com/docs/en/aix/7.2?topic=adapters-ascii-decimal-hexadecimal-octal-binary-conversion-table for (int i = 0; i < 11; ++i) { // initilize pins pinMode(i, INPUT); // Add all the keys into the 'allKeys' with the correct values allKeys[i].pin = keys[i]; allKeys[i].keyToPress = x; allKeys[i].isActive = false; x++; } } void loop() { for (int i = 0; i < 11; ++i) { handleSwitchPin(allKeys[i]); } // Short delay delay(10); } boolean handleSwitchPin(KeyThing keyData) { if (digitalRead(keyData.pin) == HIGH && keyData.isActive == false) { // Store the pin thats pressed then set isActive to true so this can't be called again // by another pin keyData.isActive = true; Keyboard.press(keyData.keyToPress); } else if (digitalRead(keyData.pin) == LOW && keyData.isActive == true) { // This will only get called when the pin thats pressed is the 'pin' and it's LOW and it's active keyData.isActive = false; Keyboard.release(keyData.keyToPress); // Release specific key } } My C is a bit rusty so this might not work first time. I'd also come up with a better struct name other then 'KeyThing'
  9. Oh good point, I was thinking of debouce incorrectly in my little brain. You will probably want to re-add you're debounce back in given what minibois has stated.
  10. https://developer.valvesoftware.com/wiki/Source_SDK_2013 ? https://github.com/ValveSoftware/source-sdk-2013 Once that is done, you'd need to "Mod" the game to how you want it. Valve have some quite extensive documentation on using the SDK. e.g. Has a bunch of different changes to UI / new guns that sorta thing.
  11. You can do that sort of behaviour with sets: fruits = {"apple", "banana", "cherry"} print(fruits - {"apple"}) # or to actually remove it. fruits -= {"apple"} print(fruits)
  12. #include "Keyboard.h" int keys[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; // A nicer way would be to include an array of something like so // //struct KeyThing { // int key; // char keyToPress; // boolean isActive; //}; // //KeyThing keyData[12]; int pinPressed = 0; boolean isActive = false; void setup() { Keyboard.begin(); for (int i = 2; i < 13; ++i) { // initilize pins pinMode(i, INPUT); } } void loop() { for (int i = 2; i < 13; ++i) { handleButtonPin(i); } // Short delay delay(10); } boolean handleButtonPin(int pin) { if (digitalRead(pin) == HIGH && isActive == false) { // Store the pin thats pressed then set isActive to true so this can't be called again // by another pin pinPressed = pin; isActive = true; doAction(pin); } else if (pinPressed == pin && digitalRead(pin) == LOW && isActive == true) { // This will only get called when the pin thats pressed is the 'pin' and it's LOW and it's active isActive = false; Keyboard.releaseAll(); } } void doAction(int pin) { switch (pin) { case 2: Keyboard.press('1'); break; case 3: Keyboard.press('2'); break; case 4: Keyboard.press('3'); break; case 5: Keyboard.press('4'); break; case 6: Keyboard.press('5'); break; case 7: Keyboard.press('6'); break; case 8: Keyboard.press('7'); break; case 9: Keyboard.press('8'); break; case 10: Keyboard.press('9'); break; } } Modifed your code a little (not tested). So this can currently only handle 1 switch at a time due to having two variables for storing the state. This could be fixed but would be slightly more complex. I personally prefer code examples to understand things. If you want more of an explanation as to why this works (assuming it does) either ask for further details or inspect the code and add print statements to see what variables are what and when (this can help you understand it)
  13. I think a bit more info is needed to help: What do you want the actually functionality to be (what behaviour do you want)? e.g. A toggle (you press and it holds)? A you press and it holds for a short while? If it just spams a bunch that implies the switches you are using might already be toggle switches as oppose to buttons? I don't think what minibois said would help as delaying going into the `doAction(i)` function won't change the actual delay between when the button is pressed and released.
  14. I could be miss understanding but your asking why is there more then one row in the database or that when you refresh the page it inserts two records at once? Everytime you run the browser / load this up it will insert a new row into the database. Maybe you want a constraint in the database to not have a row with the same name and age?
  15. I don't really know any JQuery any more but if you want to programmtically add/remove something based on a boolean value it should be quite straight forward like so: This uses formated strings, so you can kinda add variables into strings using `${variable_name}` or a ternary operater which are really nice to use: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator function get_image_name(filename, is_checked) { // Returns the file name with 'F' attached if is_checked is true, // otherwise just the filename with '.png' appeneded. return `${filename}${(is_checked) ? 'F' : ''}.png` // Backticks allow for formatted strings } x = get_image_name("picture_1", true) // Returns --> picture_1F.png y = get_image_name("picture_1", false) // Returns --> picture_1.png You can ofcouse modify the 'F' to be what you want etc or even add it as an extra parameter. Though thinking about it, this may or may not work depending on how you get the 'current' filename. As if you get it from the 'src' you'd need ot strip out the 'F.png', To do that you'd want to first remove the '.png' as thats consitent could use: str.replace(".png", "") -> returns new string without '.png', then add a check to see if the magical 'F' is the last index in the string, if it is then you can replace that then you'll have the original file name without the prefix.
  16. Yeah, it seems to be whats happening, you can still get just backend dev jobs but they are just harder to find. You can however in python use templating to generate static html pages like: Jinja or check out this: https://wiki.python.org/moin/Templating I was hired doing just backend but started doing frontend, not that I super wanted to but it has grown on me. (we use VueJS which is picking up traction)
  17. At work we use Python 3 with connexion and swagger to create endpoints for our frontend tools. I'd say to mess around with that, make a few things etc put on GitHub or something. Full-stack is much more desirable to employers.
  18. Assuming all '.py' files are in the same directory, and 'file_to_import.py' is simply made up of a bunch of function I'd do: from file_to_import import function_name_1, function_name_2 from file_to_import import * # Imports all functions from 'file_to_import' I wouldn't do the import with the ` * ` as it's a bit ambiguous. If you have a directory structure like: - main.py - utils \ - thingy.py If you want to import 'thingy.py' functions into the 'main.py' you can do: from utils.thingy import function_name_1, function_name_2
  19. It looks like you're using this: https://www.npmjs.com/package/firebase/v/3.1.0 Perhaps try and incude just the things you need (This would make the website download less which is good: <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-app.js"></script> <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-auth.js"></script> <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script> <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-storage.js"></script> Alternativly try using doing it this way, take a look at Step 3 and From the CDN. https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
  20. Second "if" statement, the `cpu[0].vetorDeIO` looks to be an array. // cpu[0].vetorDeIO => cpu[0].vetorDeIO[0] // this if (cpu[0].tempodeExecucao == cpu[0].vetorDeIO) {... // to if (cpu[0].tempodeExecucao == cpu[0].vetorDeIO[0]) {...
  21. Hey, I spent a couple hours this morning creating the extension. I've never made one before and it was pretty fun! I've published it on the marketplace too! (Its called 'WhatFile') https://marketplace.visualstudio.com/items?itemName=MaxHorwood.whatfile The README has what you need to set in your settings. It was surprisingly easy to write this, it was more of a challenge to upload it If you wanna write an extension I'd recommend looking at: https://code.visualstudio.com/api/get-started/your-first-extension Max
  22. String query = "INSERT INTO table1(Emp_no,Date,salary) VALUES (?, ?, ?)"; PreparedStatement pStatement; try { // getConnection() is DriverManager.getConnection(); I have things set up in seperate classes pStatement = getConnection().prepareStatement(query); pStatement.setInt(1, empid); // you should be able to do setDate() if thats how your DB is set up pStatement.setString(2, localDate); pStatement.setInt(3, w_amount); pStatement.executeUpdate(); } catch (SQLException ex) { Logger.getLogger(DBInterface.class.getName()).log(Level.SEVERE, null, ex); } I've done this before. This is what I did.
  23. Click on the Text Field. Go to code tab on the right. (By default) And variable Modifiers. Set this to public. in the code you will want to create a new object of that frame (contains the text field) ie: NewJFrame mainFrame = new NewJFrame(). then you can get the text through mainFrame.fieldName.getText(); This is might not be the best way but it works.
  24. 83 Lines. Python 2.7.13. I needed a program that could copy 1 file into a bunch of directories which are all in the same directory. Couldn't find anything online so I made my own and wanted to share Additionally, I wanted to make a program with a GUI. So here you go!! For users who CBA to actually try it but want to see the sexy GUI: from Tkinter import * from tkFileDialog import askopenfilename from tkFileDialog import askdirectory import os import shutil def fileName1(): filename = askopenfilename() labelText1.set(filename) return def copyFile(src, dest): # Copies file to dest try: shutil.copy(src, dest) # eg. src and dest are the same file except shutil.Error as e: print('Error 1: %s' % e) # eg. source or destination doesn't exist except IOError as e: print('Error 2: %s' % e.strerror) def main(): fileToCopy = labelText1.get() if os.path.dirname(fileToCopy): isFolderFound = True if e.get() != "": if os.path.exists(e.get()): isFolderFound = True else: isFolderFound = False else: isFolderFound = False if isFolderFound: directory = os.listdir(dirToCopyTo.get()) # Stores all files and folders for files in directory: # Files just returns folder name so add on to the DIR in the entry box files = dirToCopyTo.get()+"/"+files if os.path.isdir(files): # If dir (folder) then copyFile copyFile(fileToCopy, files) labelText2.set("Done") else: labelText2.set("Folder not found") else: labelText2.set("Pick a file") app = Tk() app.title("Copy file into all DIR") app.geometry('370x100+550+340') b1 = Button(app, text="Pick a File", command=fileName1, width=25) b1.grid(row=0, column=0, pady=5, padx=5) labelText1 = StringVar() labelText1.set("<----") e1 = Entry(app, textvariable=labelText1,width=25) e1.grid(row=0, column=1, pady=5, padx=5) def test(): folderDir = askdirectory() dirToCopyTo.set(folderDir) Button(app, text="Folder Directory", command=test, width=25).grid(row=1, column=0) dirToCopyTo = StringVar() dirToCopyTo.set("") e = Entry(app, text=dirToCopyTo, width=25) e.grid(row=1, column=1, pady=5, padx=5) labelText2 = StringVar() labelText2.set("-----") label2 = Label(app, textvariable=labelText2) label2.grid(row=2, column=1, pady=5, padx=5) b3 = Button(app, text="Copy File", command=main, width=25) b3.grid(row=2, column=0, pady=5, padx=5) app.resizable(0,0) app.mainloop() There should be no bugs (No promises)
×