Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

Programming Languages

Programming Languages
11 posts | Last Activity on 04-05-2024 02:52 by caa
C
caa 04-05-2024 02:52, 13 days ago
Re: simple python game - source code
[code]import random def guess_number(): # Generate a random number between 1 and 100 secret_number = random.randint(1, 100) # Initialize the number of attempts attempts = 0 print("Welcome to the Guessing Game!") print("I have selected a number between 1 and 100. Can you guess it?") while True: # Get user input guess = int(input("Enter your guess: ")) # Increment the number of attempts attempts += 1 # Check if the guess is correct if guess == secret_number: print(f"Congratulations! You guessed the number in {attempts} attempts!") break elif guess < secret_number: print("Too low! Try again.") else: print("Too high! Try again.") if __name__ == "__main__": guess_number()[/code]
C
caa 03-05-2024 14:18, 13 days ago
Re: line drawing program python and pygame
click on "download source" button to download complete code
C
caa 03-05-2024 14:16, 13 days ago
Re: line drawing program python and pygame
[code]import pygame import sys # Initialize pygame pygame.init() # Set the window size WINDOW_WIDTH = 800 WINDOW_HEIGHT = 600 WINDOW_SIZE = (WINDOW_WIDTH, WINDOW_HEIGHT) # Set up the window window = pygame.display.set_mode(WINDOW_SIZE) pygame.display.set_caption('Line Drawing Program') # Set up colors WHITE = (255, 255, 255) BLACK = (0, 0, 0) # Set up variables for line drawing drawing = False start_pos = None end_pos = None # Main loop while True: # Handle events for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: # Left mouse button drawing = True start_pos = event.pos elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: # Left mouse button drawing = False end_pos = event.pos pygame.draw.line(window, BLACK, start_pos, end_pos, 2) pygame.display.flip() elif event.type == pygame.MOUSEMOTION: if drawing: end_pos = event.pos window.fill(WHITE) # Clear the window pygame.draw.line(window, BLACK, start_pos, end_pos, 2) pygame.display.flip() # Update the display pygame.display.update()[/code]
C
caa 27-04-2024 14:48, 19 days ago
Re: modify an existing order using alice blue python api
Here's a basic example of how you might implement this in Python using the Alice Blue API: ```python [code]from alice_blue import * # Replace 'YOUR_API_KEY' and 'YOUR_API_SECRET' with your actual API key and secret API_KEY = 'YOUR_API_KEY' API_SECRET = 'YOUR_API_SECRET' # Authenticate with Alice Blue API alice = AliceBlue(username=API_KEY, password=API_SECRET, access_token_path='access_token.json') # Fetch order details (replace 'order_id' with the ID of the order you want to modify) order_id = 'YOUR_ORDER_ID' order = alice.get_order(order_id) # Modify order if order: modified_order = alice.modify_order(order_id, quantity=10) # Specify the new quantity if modified_order: print('Order modified successfully:') print(modified_order) else: print('Failed to modify order') else: print('Order not found')[/code] ``` Please note that this is a basic example and may need to be adjusted based on the specific requirements of the Alice Blue API and your trading strategy. Additionally, ensure that you have appropriate permissions and account balance before modifying orders through the API.
C
caa 27-04-2024 14:48, 19 days ago
Re: modify an existing order using alice blue python api
To modify an existing order using the Alice Blue Python API, you typically need to follow these steps: 1. **Authenticate**: Authenticate yourself with the Alice Blue API by providing your API key or other authentication credentials. 2. **Fetch Order Details**: Retrieve the details of the order you want to modify, such as its order ID and other necessary parameters. 3. **Modify Order**: Use the appropriate endpoint to modify the order. You'll need to specify parameters such as the order ID, new quantity, price (if applicable), and other relevant details. 4. **Handle Response**: Handle the response from the API to determine if the order modification was successful. The response may include information such as the modified order ID, execution status, and any error messages.
C
caa 21-03-2024 13:45, 2 months ago
Re: program for collision detection with ultrasonic sensor
In this example: - We include the `Ultrasonic` library, which provides functions for interfacing with the ultrasonic sensor. - We define the trigger and echo pins for the ultrasonic sensor, as well as the threshold distance for collision detection. - In the `setup` function, we initialize the Serial communication. - In the `loop` function, we measure the distance to the obstacle using the `distanceRead` function from the `Ultrasonic` library. - We check if the measured distance is below the collision threshold. If it is, we print a message indicating a collision detected. - You can add additional actions inside the `if` statement to respond to a collision, such as stopping a motor or activating a buzzer. Make sure to connect the ultrasonic sensor to the correct pins > the Arduino board, and adjust the pins and threshold distance according to your setup. Additionally, consider adding additional safety measures and error handling to improve the reliability of the collision detection system.
C
caa 21-03-2024 13:44, 2 months ago
Re: program for collision detection with ultrasonic sensor
To create a program for collision detection using an ultrasonic sensor with Arduino, you'll need to measure the distance to an obstacle using the sensor and trigger an alert if the distance is below a certain threshold, indicating a potential collision. Here's a basic example using an Arduino board and an ultrasonic sensor: [code]```cpp // Include the Ultrasonic library #include <Ultrasonic.h> // Define the pins for the ultrasonic sensor #define TRIGGER_PIN 12 #define ECHO_PIN 11 // Define the threshold distance for collision detection (in centimeters) #define COLLISION_THRESHOLD 10 // Initialize the ultrasonic sensor Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN); void setup() { Serial.begin(9600); } void loop() { // Measure the distance to the obstacle float distance = ultrasonic.distanceRead(CM); // Print the distance to the Serial monitor Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm"); // Check if the distance is below the collision threshold if (distance < COLLISION_THRESHOLD) { // Collision detected, trigger an alert Serial.println("Collision detected!"); // You can add additional actions here, such as stopping a motor or activating a buzzer } // Wait for a short delay before taking the next measurement delay(1000); } ```[/code]
C
caa 25-11-2023 06:55, 6 months ago
Re: libraries or tools for creating stock charts, popular choices
Highcharts: A JavaScript charting library that supports a variety of chart types, including stock charts. Official Website: Highcharts Chart.js: A simple yet flexible JavaScript charting library that can be used for various chart types, including line charts that could represent stock data. Official Website: Chart.js Plotly: A Python graphing library that supports interactive charts, including stock charts. Official Website: Plotly Matplotlib (Python): A widely used Python plotting library that can be used to create various types of charts, including stock charts. Official Website: Matplotlib
A
admin2 28-10-2023 16:34, 6 months ago
Re: ruby automation
Here's a simple example of automating a file operation in Ruby to copy files from one directory to another: ```ruby require 'fileutils' source_directory = 'source_folder' destination_directory = 'destination_folder' # Check if the source directory exists if File.directory?(source_directory) # Ensure the destination directory exists; create it if it doesn't FileUtils.mkdir_p(destination_directory) unless File.directory?(destination_directory) # Copy files from source to destination FileUtils.cp_r(Dir.glob("#{source_directory}/*"), destination_directory) puts 'Files copied successfully.' else puts 'Source directory does not exist.' end ``` This script checks if a source directory exists, creates the destination directory if it doesn't, and then copies files from the source to the destination. You can extend and customize your Ruby automation scripts to meet your specific needs, whether it's automating a simple task or a complex workflow. Remember to handle errors and exceptions to ensure robust automation.
Responded in ruby automation
A
admin2 28-10-2023 16:34, 6 months ago
Re: ruby automation
4. **Database Automation**: - Connect to databases using Ruby libraries like ActiveRecord or Sequel. - Automate database queries and updates. 5. **GUI Automation**: - Use libraries like AutoIt or Sikuli to automate interactions with GUI applications. - Automate repetitive tasks in desktop applications. 6. **Email Automation**: - Interact with email services using libraries like Net/IMAP or Action Mailer. - Automate tasks like sending emails or processing incoming messages. 7. **File Parsing and Generation**: - Automate parsing and processing of text files, CSV files, XML, JSON, and more. - Generate reports, documents, or configuration files.
Responded in ruby automation
A
admin2 28-10-2023 16:34, 6 months ago
Re: ruby automation
Ruby is a versatile programming language that can be used for automation tasks. Whether you want to automate repetitive tasks on your computer or perform web automation, Ruby has libraries and tools that can help. Here are a few areas where you can use Ruby for automation: 1. **System Automation**: - Automate file operations, like copying, moving, or renaming files and directories. - Schedule tasks using `cron` jobs or Task Scheduler. - Monitor system resources and processes. - Interact with the command line and run shell commands. 2. **Web Automation**: - Use libraries like Watir or Selenium for web scraping and testing. - Automate repetitive web tasks, such as form submissions and data extraction. - Create web scraping bots to collect data from websites. 3. **API Automation**: - Make HTTP requests and interact with RESTful APIs. - Automate data retrieval or synchronization with web services.
Responded in ruby automation
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?