Code faster with the help of AI

Generate code just by typing a text description. AI will create the code for you. Test it now

Questions about programming?Chat with your personal AI assistant

How others used it recently

Generated by the communtiy

generate functionThu, 23 Mar 2023

I want a python program with a dialgo window that captures an image from the webcam. I also want that in that dialgo window there is a colour selector that uses the selected colour to apply a mask for the selected colour. I want all this with opencv

import cv2 import numpy as np def nothing(x): pass # Create a black image, a window img = np.zeros((300,512,3), np.uint8) cv2.namedWindow('image') # create trackbars for color change cv2.createTrackbar('R','image',0,255,nothing) cv2.createTrackbar('G','image',0,255,nothing) cv2.createTrackbar('B','image',0,255,nothing) cap = cv2.VideoCapture(0) while(True): # get current positions of four trackbars r = cv2.getTrackbarPos('R','image') g = cv2.getTrackbarPos('G','image') b = cv2.getTrackbarPos('B','image') # Read the frame ret, frame = cap.read() if ret: # Flip the image frame = cv2.flip(frame,1) # Convert BGR

Python
Guest
generate functionSat, 18 Mar 2023

generame una programacion sobre activar un motor, cuando el sensor infrarrojo e18-d80nk detecta un objeto el motor tendra que detenerse despues dar una orden a un servo motor que se active durante 5 s...

#include <Servo.h> Servo myservo; int sensor = A0; int led1 = 13; int led2 = 12; int led3 = 11; int led4 = 10; int led5 = 9; int motorPWMA = 2; int motorAIN1 = 3; int motorAIN2 = 4; int motorPWMB = 6; int motorBIN1 = 7; int motorBIN2 = 8; int btn = 7; void setup() { myservo.attach(5); Serial.begin(9600); pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(btn, INPUT); pinMode(motorPWMA, OUTPUT); pinMode(motorAIN1, OUTPUT); pinMode(motorAIN2

C++
Guest
generate functionMon, 05 Dec 2022

Program to stream m3u8 url to youtube in python

from pytube import YouTube import os def stream_video(url): yt = YouTube(url) stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first() print(stream.download()) if __name__ == '__main__': url = 'https://www.youtube.com/watch?v=d7Vw-iO3pb8' stream_video(url)

Python
View User
generate functionThu, 23 Mar 2023

I want a python program with a dialgo window that captures an image from the webcam. I also want that in that dialgo window there is a colour selector that uses the selected colour to apply a mask for the selected colour. I want all this with opencv

import cv2 import numpy as np def nothing(x): pass # Create a black image, a window img = np.zeros((300,512,3), np.uint8) cv2.namedWindow('image') # create trackbars for color change cv2.createTrackbar('R','image',0,255,nothing) cv2.createTrackbar('G','image',0,255,nothing) cv2.createTrackbar('B','image',0,255,nothing) cap = cv2.VideoCapture(0) while(True): # get current positions of four trackbars r = cv2.getTrackbarPos('R','image') g = cv2.getTrackbarPos('G','image') b = cv2.getTrackbarPos('B','image') # Read the frame ret, frame = cap.read() if ret: # Flip the image frame = cv2.flip(frame,1) # Convert BGR

Python
Guest
generate functionWed, 21 Dec 2022

dice gambling script

from random import randint def diceRoll(userGuess, numRoll): if userGuess == numRoll: return True else: return False def main(): numRoll = randint(1, 6) userGuess = int(input("Guess a number from 1 to 6: ")) if diceRoll(userGuess, numRoll): print("You win!") else: print("You lose. Better luck next time!") main()

Python
Guest
generate functionMon, 14 Nov 2022

Tell me a secret

def tell_me_a_secret(): print("I will keep your secret\n") secret = input("what's your secret : ") print("you said " + secret)

Python
Guest
generate functionSun, 13 Nov 2022

create an account using firebase google sign in

final FirebaseAuth _auth = FirebaseAuth.instance; final GoogleSignIn googleSignIn = GoogleSignIn(); String name; String email; String imageUrl; Future<String> signInWithGoogle() async { final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn(); final GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication; final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleSignInAuthentication.accessToken, idToken: googleSignInAuthentication.idToken, ); final AuthResult authResult = await _auth.signInWithCredential(credential); final FirebaseUser user = authResult.user; assert(!user.isAnonymous); assert(await user.getIdToken() != null); final FirebaseUser currentUser = await _auth.currentUser(); assert(user.uid == currentUser.uid); assert(user.email != null);

Dart
Guest
generate functionTue, 21 Mar 2023

metodo asincrono patch en api rest

[HttpPatch("{id}")] public async Task<IActionResult> UpdateAsync([FromBody] UpdateViewModel viewModel) { var result = await _productService.UpdateAsync(viewModel); if (result.Success) return Ok(result); return BadRequest(result); }

C#
Guest
generate functionMon, 05 Dec 2022

Program to stream m3u8 url to youtube in python

from pytube import YouTube import os def stream_video(url): yt = YouTube(url) stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first() print(stream.download()) if __name__ == '__main__': url = 'https://www.youtube.com/watch?v=d7Vw-iO3pb8' stream_video(url)

Python
View User
generate functionFri, 10 Feb 2023

CGPA Calculator Examination Result No_____Course_Code____________Description______________________Credit____Grade____Grade_Point 1 SFES1101 LOGIC AND CRITICAL THINKING ...

#include <iostream> using namespace std; int main(){ string courseCode, courseDescription; int credit, grade; cout << "Enter course code: "; getline(cin, courseCode); cout << "Enter course description: "; getline(cin, courseDescription); cout << "Enter credit: "; cin >> credit; cout << "Enter Grade: "; cin >> grade; cout << "Course Code: " << courseCode << endl; cout << "Course Description: " << courseDescription << endl; cout << "Credit: " << credit << endl; cout << "Grade: " << grade << endl; return 0; }

C++
Guest
generate functionSun, 04 Dec 2022

Calculate the derivative of a function

public static double FirstDerivative(this double[] x, double[] y, double x_0, double dx) { int idx; Helpers.FindIndex(x, x_0, out idx); double x_m = x[idx - 1]; double x_p = x[idx + 1]; double f_m = y[idx - 1]; double f_0 = y[idx]; double f_p = y[idx + 1]; double h = x_p - x_m; return (f_p - f_m) / h; }

C#
Guest
text to sql syntaxTue, 17 Jan 2023

Выгрузить все столбцы таблиц с описанием ВСЕХ типов полей по группам типов(например текст, JSONB, число, вещественное число) через case на русском языке. postgresql Выгрузить без пробелов и переносов. выгрузить одной строкой

SELECT string_agg(case data_type when 'character varying' then 'text' when 'integer' then 'integer' when 'double precision' then 'real' when 'jsonb' then 'jsonb' end,',') FROM information_schema.columns where table_schema='public' and table_name='customers';

generate functionTue, 21 Mar 2023

metodo asincrono patch en api rest

[HttpPatch("{id}")] public async Task<IActionResult> UpdateAsync([FromBody] UpdateViewModel viewModel) { var result = await _productService.UpdateAsync(viewModel); if (result.Success) return Ok(result); return BadRequest(result); }

C#
Guest

show error message in html

<div class="container" id="main"> <div class="alert alert-warning alert-dismissible fade show" role="alert"> <strong>Holy guacamole!</strong> You should check in on some of those fields below. <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> </div> </div>

Guest
generate functionSun, 05 Feb 2023

AngularJS Program to find the Simple Interest

function simpleInterest(p, t, r) { i = (p * t * r) / 100 return i } var p = prompt("Enter principal amount: "); var t = prompt("Enter time period: "); var r = prompt("Enter rate of interest: "); document.write("Simple interest: " + simpleInterest(p, t, r));

Javascript
Guest

Apex Legends "classic" HTML.

<p class="bg-blue"><a href="https://playapex.com/" target="_blank" rel="noopener noreferrer">PLAY APEX</a></p> <p class="bg-white"><a href="https://www.ea.com/games/apex-legends" target="_blank" rel="noopener noreferrer">ELECTRONIC ARTS</a></p> <p class="bg-blue"><a href="https://help.ea.com/en-us/help/faq/apex-legends-faq/" target="_blank" rel="noopener noreferrer">HELP</a></p> <p class="bg-white"><a href="https://legal.ea.com/terms-of-service" target="_blank" rel="noopener noreferrer">TERMS</a></p> <p class="bg-blue"><a href="https://www.ea.com/privacy-policy" target="_blank" rel="noopener noreferrer">PR

generate functionSun, 13 Nov 2022

forward all connections to goatse.cx

def forward_to_goatse(ip, port): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('goatse.cx', 80)) s.listen(0) while 1: (incoming_socket, address) = s.accept() incoming_socket.send(b'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<html><body><img src="http://goatse.cx/"></body></html>') incoming_socket.close()

Python
Guest
code to explanationWed, 16 Nov 2022

j=10 _ = [print(''.join([' ' for o in range(j-it-1)]) + '_'.join(['#' for _ in range(1+it)]) + ''.join([' ' for o in range(j-it-1)])) for it in range(j)]

_ is the list comprehension (or generator) in this case. The value of _ is not important as long as it is not used. print(''.join([' ' for o in range(j-it-1)]) + '_'.join(['#' for _ in range(1+it)]) + ''.join([' ' for o in range(j-it-1)])) is the print statement. The first and third parts are creating spaces and the second part is creating the #. The other parts are controlling the number of spaces and #. for it in range(j) is the for loop.

Guest
code to explanationWed, 16 Nov 2022

j=10 _ = [print(''.join([' ' for o in range(j-it-1)]) + '_'.join(['#' for _ in range(1+it)]) + ''.join([' ' for o in range(j-it-1)])) for it in range(j)]

_ is the list comprehension (or generator) in this case. The value of _ is not important as long as it is not used. print(''.join([' ' for o in range(j-it-1)]) + '_'.join(['#' for _ in range(1+it)]) + ''.join([' ' for o in range(j-it-1)])) is the print statement. The first and third parts are creating spaces and the second part is creating the #. The other parts are controlling the number of spaces and #. for it in range(j) is the for loop.

Guest
generate functionSat, 18 Mar 2023

generame una programacion sobre activar un motor, cuando el sensor infrarrojo e18-d80nk detecta un objeto el motor tendra que detenerse despues dar una orden a un servo motor que se active durante 5 s...

#include <Servo.h> Servo myservo; int sensor = A0; int led1 = 13; int led2 = 12; int led3 = 11; int led4 = 10; int led5 = 9; int motorPWMA = 2; int motorAIN1 = 3; int motorAIN2 = 4; int motorPWMB = 6; int motorBIN1 = 7; int motorBIN2 = 8; int btn = 7; void setup() { myservo.attach(5); Serial.begin(9600); pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); pinMode(led5, OUTPUT); pinMode(btn, INPUT); pinMode(motorPWMA, OUTPUT); pinMode(motorAIN1, OUTPUT); pinMode(motorAIN2

C++
Guest
generate functionFri, 17 Mar 2023

encender un compresor para neumatica

Script function encenderCompresor(tiempoEncender, tiempoApagar) { digitalWrite(compresor, 1) delay(tiempoEncender) digitalWrite(compresor, 0) delay(tiempoApagar) } encenderCompresor(1500, 1000)

Java
Guest
generate functionMon, 20 Mar 2023

Jugar piedra, papel y tijera

def jugarPiedraPapelTijera(a, b): if a == b: return "Empate" elif (a == "piedra" and b == "tijera") or (a == "papel" and b == "piedra") or (a == "tijera" and b == "papel"): return "Gana a" else: return "Gana b" jugarPiedraPapelTijera("piedra", "tijera")

Python
Guest
generate functionTue, 21 Mar 2023

metodo asincrono patch en api rest

[HttpPatch("{id}")] public async Task<IActionResult> UpdateAsync([FromBody] UpdateViewModel viewModel) { var result = await _productService.UpdateAsync(viewModel); if (result.Success) return Ok(result); return BadRequest(result); }

C#
Guest
generate functionWed, 22 Mar 2023

How to read a csv file and select a column and record this in java project

import java.io.File; import java.util.ArrayList; import java.util.Scanner; import java.io.FileNotFoundException; public class CSVReader { void readFile(String fileName){ ArrayList<Integer> list = new ArrayList<>(); try { Scanner inputStream = new Scanner(new File(fileName)); while(inputStream.hasNext()){ String data = inputStream.next(); String[] values = data.split(","); list.add(Integer.parseInt(values[2])); } inputStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println(list); } public static void main(String[] args) { CSVReader obj = new CSVReader(); obj.readFile("C:\\Users\\veera\\Downloads\\befkbhalderstatkode.csv"); } }

Java
Guest
ContactPrivacy Policy