instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I have a stream of sensor data which I want to visualize in a plot with many subplots. Plotting the data is a real bottleneck in my code. Right now I get with small resolution only 16 FPS which is far too slow.
Here is what it looks like:
import time
from matplotlib import pyplot as plt
import numpy as np
def live_pl... | stackexchange/codereview |
I wrote a code that retrieves categories from DB and act as dynamic category search. I kindly ask you to review my code and tell me if the code can be optimized/improved. Thank you for your help.
This is the html code.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
... | stackexchange/codereview |
I'm trying to update my website's code to HTML5's semantic and structural elements, but I'm not very sure with the sections and article element.
Here's the structure of my page:
<body>
<header id="heaven" style="background-image: url(" ./images/header/2.png ");"></header>
<nav id="outer-nav" style="position: ab... | stackexchange/codereview |
I was in the mood for some C++ and decided to write a command line calculator, which understands addition, subtraction, multiplication and parentheses. See what I have:
main.cpp
#include <algorithm>
#include <cctype>
#include <iostream>
#include <iterator>
#include <sstream>
#include <stack>
#include <stdexcept>
#inclu... | stackexchange/codereview |
I have implemented below code for binary search tree implementation using shared pointer. At present, I have considered only integers. It supports insertion and deletion of values. Also, a print method is implemented for inorder traversal.
Please review and provide your suggestions.
class Bst {
struct node {
... | stackexchange/codereview |
I am writing a program that will deal with formatting the text in a text area.
The user will use Ctrl + A, Ctrl + C to copy the entirety of a web page, then paste that text into a text area. The program will take the text area, remove the junk, and output the important information to then be copied and pasted into a d... | stackexchange/codereview |
I've started to fill my GitHub profile with small applications to educate and showcase my skills. However, I feel like I'm missing something essential, while creating these projects.
Could you take a look at this component, and advice me on how to refactor it? Its purpose is to get Coin Data from an API, and display t... | stackexchange/codereview |
I'm trying to make a code review for an external developer on my project. His code could be improved and I need your advices in order to know if my overwritten parts are better or not.
Part 1
# INITIAL
if 'error_message' in result_import:
result_import['error_message'] = "The file could not be uploaded. \n" + resu... | stackexchange/codereview |
I have write a normal programm "Transpose the matrix" in go. Suppose input are always correct. I also read the article An Efficient Matrix Transpose in CUDA C/C++. So I keen to know how I can use Go-routines or another efficient way to problem in go way
package main
import (
"fmt"
)
func main() {
a := [][... | stackexchange/codereview |
I was recently tasked with architecting a user/profile object in Objective-C and wanted the ability to access a static instance from the class level, similar in style to the way Parse manages their current user (a static variable on a class, not a singleton). With Parse, I can call a class method to return the current... | stackexchange/codereview |
I made a function to get a list with numbers around another number. Example: I want to get in a range of 2 numbers around 4. This will return: [2, 6]. You can set a min number and a max_number. That means when I set a min_num, the lower number should not be lower than the min number.
import sys
def get_numbers_around... | stackexchange/codereview |
public class FirstActivity extends Activity {
private String userName;
private Uri userPhoto;
private void onOkButtonPressed() {
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra(SecondActivity.Key.USER_NAME, userName);
intent.putExtra(SecondActivity.Key.USER_... | stackexchange/codereview |
I'm a beginner in Android and I've been experiencing "Skipped xx frames" everytime I load up my activity which is a list of languages. I tried optimizing the listview following tutorials (applied recycling and viewHolder pattern) but still can't get rid of the issue.
ListLanguagesActivity.java
package com.experiment.wo... | stackexchange/codereview |
This code will copy data from a workbook and copy it to an existing (and open) workbook. At the beginning of the month this copy/paste works very quickly, but as the month goes on and the data also grows, this process slows down to a couple of minutes. Once we start hitting 200 rows of data, we see the performance slow... | stackexchange/codereview |
I recently completed the Pascal's Triangle challenge on leetcode. I would like to have my code reviewed.
You don't need a leetcode account to see the description of the challenge linked above, but for completeness I'm pasting the description here.
Given an integer numRows, return the first numRows of Pascal's triangle... | stackexchange/codereview |
In my real life example I am at a layout stage and before I actually move any further I would like to review my current approach. I am still learning about UI, XAML on WPF technology and I guess I haven't gotten my head around all the possible approaches yet.
I have built this very simple SSCCE to better demonstrate wh... | stackexchange/codereview |
Here's what I ended up with for Learning Python the Hard Way Ex 51 with image upload (save and display).
The form:
<div style="margin:300px;border:1px solid #000">
<form method="POST" enctype="multipart/form-data" action="upload">
A Greeting: <input type="text" name="greet">
<br/>
Your Name: <input type="text" name="na... | stackexchange/codereview |
There isn't a very reliable way (in my opinion) to get the mime type of a specific extension, regardless of the file actually being of that type or not.
This type of thing usually is used when sending a different Content-type when you intend to send, for example, an image.
class MIMETypes {
/**
* @var string ... | stackexchange/codereview |
I have function that takes all of the attributes passed to a custom tag, and returns a select subset. I am try to convert the current function, which does not use closures
string function passThrough(required struct attr) output="false" {
local.result = "";
for(local.myKey in arguments.attr) {
if (var... | stackexchange/codereview |
What follows is a piece of code that essentially toggles an array of filters (if the filter doesnt exist it adds it, if it does, it removes it).
What would you suggest is the best way to write the following imperative approach declaratively?
var selectedFilters = [ {name:"SomeName"} , ... ]
var inputFilter = {name:"Oth... | stackexchange/codereview |
I completed a short coding challenge and just want to know if I should use shorter methods of which I am unaware, or make it more readable.
/*
*
* Complete the vowelsAndConsonants function.
* Print your output using 'console.log()'.
*/
function vowelsAndConsonants(s) {
var strConsonants = "";
var strVowels = "";
v... | stackexchange/codereview |
As I am new to bash scripting, and want to use apt-get in my university. I know that many people have issues when trying to do so. My focus is simplicity and ease of use, but still need to be somewhat robust.
#!/bin/bash
string="install"
errormsg="\n\tInvalid input\n You should run this script with the following st... | stackexchange/codereview |
I'm currently working on an uncrafting tool for minecraft and got a neat output working that shows all the materials needed in a tree. I wonder if the code used to print that tree could be improved somehow. I only have the recursion depth as a measurement and the ArrayList gets filled in the same order as seen in the i... | stackexchange/codereview |
I'm building a text search system for a web application in PHP. I wrote this function that gets the sentences of the text which contains the keywords used by the user and also highlight them (well, surround them with any tags anyway).
I'm measuring an average of 23ms if only the first matches is retrieved, and about 27... | stackexchange/codereview |
I am working through UPenn CIS 194: Introduction to Haskell (Spring 2013). Since I am not able to take the course for real I am asking for CR (feedback) as it could be from teacher in that course.
HW1 - Validating Credit Card Numbers - Full description
A shortened problem statement:
Validate a credit card number by th... | stackexchange/codereview |
Some of my functions use a "fail_silently" flag. It is used in the following way:
def test(a, b, c=1, fail_silently = False)
try:
return int(a) + c
except:
if fail_silently:
return None
raise
Therefore, if there is an error, we catch it and fail gracefully. The key here is tha... | stackexchange/codereview |
I'm looking to highlight some words on a webpage, I've grouped them now, but changed the css and html slightly and this seems to have broken it.
For context, looking to add a list of words in JS which would then apply formatting to those words. I changed the p to a span because I wanted them to be an inline-block, whic... | stackexchange/codereview |
I am requesting a review for my solution to this problem from exercism.io. I'm posting it here since there is not always input on solution submitted through exercism.
The problem is as stated:
Calculate the Hamming difference between two DNA strands.
A mutation is simply a mistake that occurs during the creation or
... | stackexchange/codereview |
I recently came across this SO question asking for methods to determine if a std::string represents an integer. There is also this SO question for floats. I decided to code up a few methods consolidating these questions.
#include <string>
#include <algorithm>
#include <iterator>
#include <cctype>
namespace detail
{
... | stackexchange/codereview |
I created a quick program to test the precision of randomness generated by the .rand method. The primary question is whether I can use the .times method in place of the while code blocks to increase efficiency and:
Whether such a practice would reduce the amount of processing required/if this would be at all signific... | stackexchange/codereview |
I wrote a generic implementation of A* with the focus of not having to clone nodes or actions. Thanks to some very good advice I received on Stack Overflow, I have arrived at the following final result:
lib.rs
extern crate typed_arena;
use std::cmp::Ordering;
use std::collections::{BinaryHeap, HashMap};
use std::hash:... | stackexchange/codereview |
Floating point inaccuracies are really annoying. I understood that in its true sense while developing the next version of Point (this time I'm actually foolproofing my code). Before I upload it for review, I want a class that I wrote, called Numbers to be reviewed.
Numbers.java
package library.util;
/**
* This class ... | stackexchange/codereview |
I am a freshman Computer Engineering student.
Variable names are pretty straightforward; I believe it would be easy to understand.
Program explanation:
First you have to create an account and deposit money into it. Create method that runs and writes your id and password in separate text files and calls deposit_first w... | stackexchange/codereview |
I've recently taken an interest in Android applications and I have been working on an app regarding the travelling salesman problem.
My app is a kind of a trip optimizer which is meant for travelers, so that they can optionally choose a starting point and a destination/multiple destinations. Right now the app works fin... | stackexchange/codereview |
I decided to implement some data structures- this time an AVL tree. I think the logic is correct. Is there a way to make it clearer and do you have any ideas about more tests to add?
# An AVL tree, python
import random
class TreeNode:
def __init__(self, key, val, left=None, right=None, parent=None, bal=0):
... | stackexchange/codereview |
This program is supposed to calculate the mathemathical maximum of helpful flags you can have on the nth day, starting with 0 helpful flags, using the StackExchange system of gaining more possible flags, meaning every 10 helpful flags you gain one possible one, immediately.
#include <stdio.h>
// <summary>
// Small C p... | stackexchange/codereview |
I need to cut the time it takes to print a large string by ~50%.
I went from using s1 + s2 to using StringBuilder, and instead of making several calls to System.out.print for each line, I create one large string by appending newlines to the StringBuilder, and then print that large string just once with System.out.
Bu... | stackexchange/codereview |
Somebody please verify this code. Is this efficient? please tell me modular way to accomplish this task.
Updated
I want to add show class to data-targetand remove
show class from data-group Just like happening in an accordion. I wanted to know that this code is perfect for that scenario. I'm new here please let know... | stackexchange/codereview |
I made this function to act sort of like jQuery's $.ajax. I intend to use it in small projects where I do not use jQuery (I don't want to load a whole framework just to facilitate http requests).
Edit: New script incorporating Bob Lauer's suggestions
"use strict";
function OM(obj){
return new ObjectManipulator(obj... | stackexchange/codereview |
I am trying to encrypt/decrypt file using source code directly. The issue is how to properly do it after reading the file.
int crypto_aead_encrypt(
unsigned char *c, unsigned long long *clen,
const unsigned char *m, unsigned long long mlen,
const unsigned char *ad, unsigned long long adlen,
const unsig... | stackexchange/codereview |
This time I made a quiz game, in which the player is asked questions and receives points for each question answered correctly. Some people told me I should learn about classes, so this is what I came up with.
import random
from Quiz_Questions import game_questions
questions = [*game_questions]
def game():
print('-... | stackexchange/codereview |
Algorithm: Determine if an array of arrays of characters can be
concatenated in order, into a substring of haystack.
Example:
[['a','A','@'], ['b','B','8'], ['c','(','[']]
This list can be combined by selecting from each of the subarrays in
order, such as:
abc, ab(, ab[, Abc, Ab( etc.
Are any of these combination... | stackexchange/codereview |
I had always had the necessity to display long text outputs on the console screen. The size of the text displayed usually exceeds the amount of text that can be accessed by scrolling up through he console output. Also, there had been times when I wanted to look at the output history, to spot out abnormalities or bugs. ... | stackexchange/codereview |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 4