instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I built a GUI tool that takes excel files and outputs a finished report to help automate a report at work. It was a fantastic learning experienced and I feel much more comfortable with pandas and python, but I am very aware of some bad programming practices I have included.
I am self taught, and a little stuck on what ... | stackexchange/codereview |
Here is my code, I use it to verify whether an input path is correct or not. I assume that the input path is encoded in UTF8. Is there any way to make it better?
#define MAX_PATH_LEN MAX_PATH
#define IN
#define OUT
typedef int Bool_T;
static
int GetCharsNumInPath( IN const char * path )
{
int cnt;
int i;
... | stackexchange/codereview |
As you will see, I am not very familiar with Python and NumPy but want to learn it.
The following code is a very basic Sudoku solver which works fine for simple examples. Although it runs, I still have the feeling it is not very Pythonic.
from numpy import *
import sys
def set(col,row,wert):
# Set the value in fi... | stackexchange/codereview |
I'm currently working on a system using WCF to communicate between a Windows Service and one or multiple clients. Service is required to answer clients calls, as well as notify them of certain events, which is why I implemented a callback feature using simplified subscriber model. Callback interface has methods with va... | stackexchange/codereview |
It only does expressions with 2 operands yet, but I'm wondering if there are any ways I can improve this:
# infix.rb: parse infix-operated math expressions
class String
def is_number?
true if Float(self) rescue false
end
end
class InfixParser
@operations = [ '/', '*', '+', '-' ]
testString = '(24 + 6) / ... | stackexchange/codereview |
The array size is <= 16. The difference is defined as:
diff[i] = array[i+1] - array[i];
I need to find the number of permutations of the original array, which have a difference that is a permutation of the difference of the original array.
This is my code:
public class Main {
Scanner scan = new Scanner(System.in);... | stackexchange/codereview |
In the following code we use the function Incrementer (capitalized for clarity, despite that it's to be used without new), to instantiate a number.
Incrementer provides a method increment to augment a counter in a span. We have two such counters, and so we define Incrementer to avoid code duplication (although it would... | stackexchange/codereview |
I'd like to refactor my extractSimplePromptName test so it does the same but it's "prettier", hence less code. As far as looking at it, it seems like it could be refactored so it does the same thing, but it's just less code. I'm just fairly new to programming so having a hard time seeing where I should make the changes... | stackexchange/codereview |
I created this small function just to practice C code. It's a simple random string generator.
#include <string.h>
#include <time.h>
char *randstring(int length) {
static int mySeed = 25011984;
char *string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.-#'?!";
size_t stringLen = st... | stackexchange/codereview |
Suppose there are a set of given points (represented by x and y two dimensional coordinates), and for any given point A, I want to find the nearest distance point among the given set of point.
My current solution is straightforward: just find min among all distances. The issue of my implementation is, if we want to c... | stackexchange/codereview |
I have written a code to sort a main table containing tables in each of its rows. Here I am trying to sort the table by first sorting the rows in each of the main rows and then sorting the table from the sorted main rows. Whenever I click on headers the table is sorted in ascending and descending order alternately. How... | stackexchange/codereview |
I am brand new to C++ and am working with the Arduino micro controller. The project I've been working on for my university requires me to write code to do the following:
If the ultrasonic sensor detects a distance within a certain range, output HIGH to activate an electric motor
If the sensor detects distance outside... | stackexchange/codereview |
The Fortran program 'MAIN' below calls 3 subroutines.
It opens a file if it is not present, (overwrites if it is already present).
writes something on the file using the file identifier integer and
closes the file.
program MAIN
2001 FORMAT (A,I10)
INTEGER FILEIDS(10)
CHARACTER*64 fname
FILEIDS(... | stackexchange/codereview |
I've been tasked to solve this exercise lately, and this is what I wrote:
object Main {
def isSubstringPalindrome(inp: String)(start: Int, end: Int): Boolean =
(start.compareTo(end), inp(start)==inp(end)) match {
case (0, _) => true
case (1, _) => true
case (-1, true) => isSubstringP... | stackexchange/codereview |
I'd like some feedback on code I wrote to obfuscate text on-disk. The basic idea is the same as ROT13 (which is implemented in the Python standard library), except instead of rotating the English alphabet by 13, the underlying byte representation is rotated by 128. The use case is to hide data from a string-search.
Bec... | stackexchange/codereview |
So basically jqueryphp is a jQuery plugin that allows you to call any PHP function within client-side JavaScript: jqueryphp@github
I wrote it as a response to projects such as PHP.JS and other JavaScript emulated PHP function libraries. I realize that my solution will only be useful in contexts where latency is not muc... | stackexchange/codereview |
Given an input N as the size of a centrifuge, I need to find out the number of balanced configurations. The full description is here.
Centrifuge is a piece of equipment that puts multiple test tubes in rotation at very high speeds. It consists of a cylindrical rotor with holes situated evenly along the circumference o... | stackexchange/codereview |
I'm new to jQuery, but I have a fair bit of experience with JavaScript, mainly using Angular.
What I'm wanting to do is have implement a horizontal list of tabs, where clicking each button will display a corresponding div, and hide the others.
Here's how I'm doing it:
$(document).ready(function(){
$(".tab-group").... | stackexchange/codereview |
I am looking for clean way to accumulate amounts within a input dataset. In this example, there are 18 rows of data, and the output is a 3 rows of data, accumulated by Key, by ExpenseType.
My biggest concern is whether hashMap is the correct utility for this, or if there is an easier/cleaner way.
FamilyExpenseProcesso... | stackexchange/codereview |
The PHPSESSID is stored in the clients cookie so I don't consider it as secure. Someone might bruteforce it and perform some action (like a Facebook status post) whenever a session was successfully hijacked.
I was wondering how I can protect against attacks like that. Maybe by locking out suspect users? My solution I c... | stackexchange/codereview |
I am taking a class in mobile application development this fall. I have finished my first assignment of creating a class to divide an arbitrary dollar amount into the minimum number of bills and coins. I have completed the assignment and everything works as intended (outside of an occasional error I'm having with compu... | stackexchange/codereview |
I'm writing some small programs to practice Rust, and this one's a string compressor for the golfing language Jelly (unofficial spec). It involves some non-ASCII stuff and bigints (from the num-bigint crate).
use std::io;
use std::io::Write;
use num_bigint::{BigUint, ToBigUint};
use num_traits::cast::ToPrimitive;
use s... | stackexchange/codereview |
My code is working, however, in the foreach section, when it runs the invoke-command if I don't use "-ErrorAction SilentlyContinue" the red error text that states a computer cannot be connected to shows up. The code still works fine, I just wanted to know if there is a way to add "nicer" text, so that when the invoke-c... | stackexchange/codereview |
This is a c# class I use to implement web database applications with Microsoft IIS and Microsoft SQL server. It passes the http context to a selected SQL stored procedure, and writes a response based on the result sets generated by the stored procedure. Thus the entire application is coded as SQL stored procedures, apa... | stackexchange/codereview |
This is a follow up to:
Validating individual properties and whole items
I have a custom class I've written which allows me to validate
individual properties of items, without firing validation errors on
other properties. This allows me to individually validate what my
users are editing without flinging up a lot... | stackexchange/codereview |
I have been studying the architecture of the Siamese neural network introduced by Yann LeCun and his colleagues in 1994 for the recognition of signatures ("Signature verification using a Siamese time delay neural network".pdf, NIPS 1994).
I had some problems in understanding the general architecture of this Siamese ne... | stackexchange/codereview |
Is there anything I can improve in my UserManager class which saves and loads info about users connected to my server?
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException... | stackexchange/codereview |
class CSList
{
public:
CSList()
{
::InitializeSListHead(&m_head);
}
USHORT Depth()
{
return ::QueryDepthSList(&m_head);
}
PSLIST_ENTRY Flush()
{
return ::InterlockedFlushSList(&m_head);
}
PSLIST_ENTRY First()
{
return ::RtlFirstEntrySList(&m... | stackexchange/codereview |
I'm attempting a practice problem in Codeforces that requires you to find the number of multiples of 3 less than or equal to a given number. I have written the following code but it gives a TLE once the test case reaches the order of 108.
int x = Reader.nextInt();
int count = 0;
for(int i = 3; i<=x; i++){
if(i%3 =... | stackexchange/codereview |
I wrote a small multiple select interface in jQuery, and I'm looking for any feedback on code quality/usability.
It has to do the following:
When check all is checked, all boxes must become checked
When check all is unchecked, all boxes must become unchecked
When all boxes become checked the check all box must become ... | stackexchange/codereview |
My question has to do with :
(a) Can this be made more secure?
(b) Are there best practices in relation to setting timezone?
(c) What best approach should be taken defining use of utf8?
$my_success = 0;
$my_message = '';
$my_id = 0;
try {
# declare & set variabl... | stackexchange/codereview |
This is my rewrite of the program posted here, based on janos's comments. I also added the ability to read from stdin.
I've also included a test script. I wanted something lightweight I could easily re-run, but didn't want a dependency or full test framework like bats. Comments on the test script are also welcome.
N... | stackexchange/codereview |
As usual, please be brutally honest with your opinion of my code, and how you would judge it if I were to code this at a top-tier tech company for an interview(think Google, MSFT, Facebook, etc). My algorithm is has a worst time complexity of O(n).
Question:
Given an unsorted integer array, find the first missing posit... | stackexchange/codereview |
I wrote a functionality to read files and load them into the map m_fileParams.
Then I am searching the specific keys in the map container using find. Here using find I am searching different keys.
My code is working fine. But I wanted to know how best I can optimize the code?
In several places I have used find to searc... | stackexchange/codereview |
I decided that for some parts of my project, communication through events would be very handy, for that purpose I started writing the most basic part of the event system, an interface consisting of only 1 EventHandler with rather generic name:
public interface ICustomObservable<TArgs>
where TArgs : EventArgs
{
... | stackexchange/codereview |
I'm new to Python 3, and I tried to test if my palindrome code works and passes most of the edge cases, so I created the following 2 Python files. When I ran the python3 test_palindromes.py on the terminal, it shows that 2 tests passed. And I was wondering if that is sufficient for my palindrome function. I think I hav... | stackexchange/codereview |
I have some buttons in my class that show or hide two views (by setting their alpha property to either 0 or 1) when the user taps on them. I have written a function that uses the tag property of the sender of the button (which is passed to the function by default) to identify which view to show or hide:
@IBAction func ... | stackexchange/codereview |
I'm writing a function that validates array-like container to have correct type, length or to be hashable. Some of conditions may not be used for validation.
def check_container(container, type_=None, length=None, hashable=None):
"""
Validates container to have correct type and length, or hashable parameter.
... | stackexchange/codereview |
This works just fine, however, the assignment was to write a recursive "function". I'm curious to see if this should count.
Any comments / suggestions/ stuff I should watch out for are appreciated.
#include <iostream>
#include <functional>
#include <cctype>
#include <cstdlib>
int main() {
char go_again = 'Y';
... | stackexchange/codereview |
I've posted the code for the following question. What could be improved?
Q: Write a program that allows the user to type in a phrase and then
outputs the acronym for that phrase.
Note: The acronym should be all uppercase, even if the words in the
phrase are not capitalized.
def main():
## input the phrase
... | stackexchange/codereview |
Description:
Given the Knapsack capacity and the weight and value of some items,
find a way to maximize the value in the given Knapsack.
Code:
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static float KnapSack(float capacity, PriorityQueue<Pair> queue) {
floa... | stackexchange/codereview |
I was wondering if anyone could make any suggestions to how I could write the following more concisely and reduce the number of IF statements? If possible, I would also like to simultaneously assign values to variables and calculate the score.
I will eventually have multiple rule sets and formula scores for other quest... | stackexchange/codereview |
I'm following this presentation. At the very end there's an exercise about solving Fibonacci and says that instead of addition, make the operation setteable by a function.
Is the following is a good solution? How close might it be to what Rob Pike would have written?
package main
import "fmt"
func add(a, b int) int {... | stackexchange/codereview |
Context
PlayerHouse is a place where the Player (the game character) can refill its health, store its inventory, etc. like in a RPG-game. The user can upgrade it for example to refill player's health faster and store more inventory items.
Entity in question: PlayerHouse
class PlayerHouse {
private int moneyReq... | stackexchange/codereview |
I wrote a productivity app for Android. It lets you switch system settings, like Bluetooth, wife, screen brightness, volumes, ringtones, mobile data, airplane mode, etc. Unfortunately I have discovered that device manufacturers modify the OS in every possible way, disabling functionality, requesting additional permissi... | stackexchange/codereview |
Spurred by this question: Project Euler #8 I decided to try to solve it with as clean code as possible.
Here is the problem formulation:
The four adjacent digits in the 1000-digit number that have the
greatest product are 9 × 9 × 8 × 9 = 5832.
73167176531330624919225119674426574742355349194934
96983520312774506326... | stackexchange/codereview |
I'm a little unhappy with the look of this "flexible" way of dealing with errors from an API in Ruby:
class ApiError < StandardError
def initialize(response)
message = response.is_a?(String) ? response
: !(response.respond_to? 'body') ? 'Error'
: response.body.is_a?(Hash) ? response.body['... | stackexchange/codereview |
This piece of code calculates the sum of all prime numbers below 1 million.
It stood out to me that the Ruby script is around 20% faster. I know that Go should be faster just for being a compiled language. So how can I make the Go code run faster than it already does?
I'm interested in solutions involving goroutines, p... | stackexchange/codereview |
My external drive that I use for Backup had some broken files. I feared that I'd lose some (or all) the data in there. So I wanted to copy each and every file to my hard disk.
I first tried using regular Windows methods (Copy, Xcopy). But, these methods took a lot of time and the commands would stop execution after hit... | stackexchange/codereview |
I always use nested list and dictionary comprehension for unstructured data and this is a common way I use it.
In [14]: data = """
41:n
43:n
44:n
46:n
47:n
49:n
50:n
51:n
52:n
53:n
54:n
55:cm
56:n
57:n
58:n"""
In [15]: {int(line.split(":")[0]):line.split(":")[1] for line in data.split("\n") if len(line.split(":"))==2}
... | stackexchange/codereview |
I'm writing a code for my application: you can create a task, and you can choose the moment when you want to send this task (to some kind of user):
Send now
Send later
Repeat
You can select from above options. If you choose send later, you'll be prompted for a date:
And there are variety of options if you choose Re... | stackexchange/codereview |
First of all, please note that the input (.vcf) file is very large (>60 GB).
So I am reading the .vcf files line by line, but since I have to check for duplicate of two columns present in the input vcf file, I extract those two columns from the input file to a text file ("dup_posID.txt") and then check for duplicates, ... | stackexchange/codereview |
Here is my take at a lightweight interface implementation, where I focus on discoverability of suitable classes from strings (for simplicity, class name is used as an id). Each interface has it's own "registry" of implementations.
My choice of abc module is due to presence of registration method there, better support f... | stackexchange/codereview |
I am developing a service where the user need to sign the seller agreement with Mobile BankID (Swedish e-sign service). To make this work I need to make SOAP request to get the progress status of the signing request in Mobile BankID.
Is this code understandable? How can I make it more clean?
def collect_request(transac... | stackexchange/codereview |
I have a program that starts a bunch of goroutines, feeds them data and when there is no more data, waits for the goroutines to finish. I use sync.WaitGroup. I am unsure if I am using correctly, in an idiomatic way or if there is a better solution.
Background
My real code reads a log file of disk-space and numbers of f... | stackexchange/codereview |
Is it possible to rewrite this piece of code any better when it comes to efficiency and/or readability?
public function dispatch()
{
$key = array_search($this->reqUri, $this->routes);
if ($key !== false) {
if (isset($this->methods[$key])) {
if ($this->methods[$key] === $this->reqMethod) {
... | stackexchange/codereview |
I’m learning python and have built a very simple program that just renames files. It makes all letters lowercase and replaces spaces and %20-instances with underscores and then copies them into a ‘Finished’ folder. I’m looking for better methods and approaches of writing and structuring my code.
Can anybody find any ob... | stackexchange/codereview |
I'm reviewing my code and trying to figure out how I can do some simplifying to flatten my code. Whether it be making simpler function out of the segment of code or by removing parts of it and wanted some opinions.
if ($regenerated_post_password !== $user_data->password)
{
/* Password from login from does n... | stackexchange/codereview |
I recently discovered the exponential search algorithm which can be used to find whether a value exists in an ordered range. An exponential search checks whether a value is smaller than the \$2^n\$th element of the range, then if the searched value is indeed smaller, it performs a binary search in the range \$[2^n, 2^{... | stackexchange/codereview |
GitHub
Here is a Castle.Core based service interface decorator providing automatic logging through the ambient logging context.
Logging context should be constructed higher in the call stack:
using var log = new Log(log.Debug, log.Info, log.Warning, log.Error);
and used through the static API after:
Log.Info("Hello Wo... | stackexchange/codereview |
I'm using Raphael.js to generate objects which are unique but do basically the same thing. I'm also using Fancybox to display a unique image after a click on a generated object.
Is there a way to write this more concise?
//OBJECT 101
var p1_101 = p1.path("M361,146.773 366.25,192.94 365.917,196.606 366.583,199.69 38... | stackexchange/codereview |
I am new to RxJava and have the following code which I use to search YouTube videos via the API and ultimately display them in a list.
private fun showYouTubeSearchView() {
val youtubeSearchView = viewFactory.getYouTubeSearchView(null)
val contentView = youtubeSearchView.rootView
youtubeSearchView.subscri... | stackexchange/codereview |
I have a rating system where users can vote between 1-6. I'd like to normalize the votes a bit to better accommodate for extreme voting, where individuals tend to vote as high or as low as possible. To do this, I have the following algorithm which seems to work well. However, it's extremely inefficient and not very wel... | stackexchange/codereview |
I have a vector with 10000 particles that I use in a Particle Filter. The problem is that it's taking too long to compute the weighted selection of the particles.
I want to use a vector of weights (probabilities) to select elements from a vector (particles) to generate a new vector (new_particles) with the same size as... | stackexchange/codereview |
With the new additions in c++11 and c++17 I wanted to create a simple implementation of thread pool.
I would like your opinion on:
Thread safety
API
performace
and general code quality
I also would like to know if it good idea to have wait_until_empty method.
Without id I probably could have avoided using a mutex.... | stackexchange/codereview |
Just a fun batch file I have made. I wanted an easy way to loop any arbitrary command several times: loopme.bat
@echo off
SETLOCAL
echo LoopMe v1.0
IF "%~1"=="/?" (GOTO HELP)
IF "%~1"=="" (GOTO HELP)
IF "%2"=="" (SET TIMEOUT=1) ELSE (SET TIMEOUT=%2)
SET COMMAND=%~1
SET COUNTER=0
:RUN
SET /A COUNTER=%COUNTER% + 1
CMD ... | stackexchange/codereview |
This code gets the cell's colour regardless of whether it's set from conditional formatting or not. It currently works on 2010 and unsure about older versions of excel.
My question is is there a way to make this code more efficient?
Such as being able to highlight an area for the code to search rather than setting For... | stackexchange/codereview |
I've written a Python program to analyse a huge C++ code base in excess of millions of lines of code. The job of the program is simply to search for all C and C++ style comments and extract all the comments which contain specific keywords and phrases and to write those comments to an associated file. So far the program... | stackexchange/codereview |
I am trying to improve working code seeing if there was any potential issues or performance problems. This code will connect to an ftp server and upload a file.
public SendFiles(string demoFileLocation, string liveFileLocation, string fileName, string username, string password)
{
ResultStatus resul... | stackexchange/codereview |
Recently, I have been trying to improve my functional programming skills and understanding. While at work today, my coworkers and I were playing Hangman in a group chat. I thought of a program that would guess the likeliest letter in the word to guess. So I implemented it when I got home. Here is the repository if you ... | stackexchange/codereview |
I have unstructured input-output data, f=f(x). I want to estimate the range of f as a function of x, given limited sampled. So, I tried to discretize the data use small bins in x to estimate the variance of f associated with that bin. After a lot of work, I cobbled together a working code. But, I'm sure there must be a... | stackexchange/codereview |
This code was tested on IBM's 5-Qubit processor as an implementation of Grover's search algorithm, but for an unknown number of solutions. This code is based on Arthur Pittenger's book, "An Introduction to Quantum Computing Algorithms" and the mathematical structure was posted as a proof-verification question here.
h ... | stackexchange/codereview |
Suppose I have an InputStream that contains text data, and I want to detect all words and their numLine. I reach for every word in file and their num line and put the result in a map. This is my code:
public class IndexerClassicRead {
private static Map<String, Map<String, Set<Integer>>> mapAllWordsPositionInFilesI... | stackexchange/codereview |
This question is related to another one that I have asked here.
I need to find ways to improve the runtime performance of the following piece of C-code.
I want to increase RANGE to around 1G, and still complete the execution within a reasonable time.
Auxiliary data structures:
#define RANGE 16000000
uint08 sieve[RANG... | stackexchange/codereview |
This is my first game that I made. How could this be improved?
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>
#include <conio.h>
using namespace std;
int snakelenght=2;
char direction='d';
char field[20][30];
class Past
{
int m_nx;
int m_ny;
public:
void Init(int x,int y)
... | stackexchange/codereview |
I recently discovered the exponential search algorithm which can be used to find whether a value exists in an ordered range. An exponential search checks whether a value is smaller than the \$2^n\$th element of the range, then if the searched value is indeed smaller, it performs a binary search in the range \$[2^n, 2^{... | stackexchange/codereview |
I am attempting to complete the coin flip streaks problem from automate the boring stuff with python.
My code works fine but my only concern is the phrasing of the task.
Does the question want us to find the number of samples (100 flips) that contain at least one streak and divide that by the total number of samples (1... | stackexchange/codereview |
I wrote the following simple 1 producer - 1 consumer problem, in attempt to learn some C++11 threading / generics.
#include <iostream>
#include <mutex>
#include <condition_variable>
#include <deque>
#include <thread>
struct data {
int x, y;
std::string s;
data() : s("test") {
x = std::rand() % 10... | stackexchange/codereview |
I learn BASH scripting occasionally from time to time, now I am working on a simple bash script that serves to maintain Dovecot user database. The general purpose of the script is able to list, add or delete user entries in the specified file. Please add some comments about the code - common mistake and etc. I want to ... | stackexchange/codereview |
As I know it is not good idea to have so many pointers in c++ code.
But I have written this simple implementation of linked list in c++ and there are many pointers in it, how can I improve that?
Also as I tried I can not use functions in algorithm module on this linked list, how can I make this class compatible with th... | stackexchange/codereview |
I made a new version of this which was actually not behaving correctly, because it showed duplicated values, it just didn't add them again, this is the link to that program, someone point at correctly I think that the problem didn't state that student should use an ArrayList, but an Array, so I made this program again ... | stackexchange/codereview |
I have a form in Laravel that goes over several templates (Blade files). For each template I am implementing simple conditional logic to show and hide groups of questions.
For the templates, I'm using HTML5 for efficient client-side validation. I wrote the Javascript below to show and hide fields using HTML attributes.... | stackexchange/codereview |
This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++. I am following the suggestions proposed by G. Sliepen in the answer. The techniques including passing a range to std::ranges::transform() and using std::invoke() a... | stackexchange/codereview |
On my webform, there are two kinds of address-fields a user can give. But since it's a complex webform (Drupal) it's kind of hard to achieve. Every time a user adds an extra address, the form is regenerated and there will be a new item added to the $address_afl and $address_bev-array. Is it possible to compress this co... | stackexchange/codereview |
Final iteration of an iterative review.
The previous iteration is here: 3D 1st Person Snake Game #2
Note: For the snippet, click run, "Full page", purposely lose, and then type r.
Here is the snippet:
<html>
<head>
<style>
canvas{
position:fixed;
left:0;
top:0;
width:99%;
... | stackexchange/codereview |
I have two database tables UsersDownload, Non-UsersDownload. There is also two model object and two service that take in the object and insert the data into the correct table. Is this the best architecture for this? or is there a better way to handle this? Would it be better to use an interface?
public class UserLog
{
... | stackexchange/codereview |
The purpose of the below code is to build a shape based on the user input, specifically:
Prompt the user to enter a shape - either a triangle or a square
Determine which "texture" to use for the shape - currently set at #'s for squares, *'s for triangles
Build the shape based on the selected texture
Sample output for... | stackexchange/codereview |
I've written my own implementation of strcat in C.
char* my_strcat(char *str1, char *str2)
{
int len_str1 = 0, len_str2 = 0, len_str3;
for (int i = 0; str1[i] !='\0'; i++)
{
len_str1++;
}
for (int i = 0; str2[i] != '\0'; i++)
{
len_str2++;
}
len_str3 = len_str1 + len_str2;
cha... | stackexchange/codereview |
Similar to the previous post Brainfuck Interpreter: Slower than a Snail?, it runs BF in java. The only difference is that the converter will convert the BF code into a compilable and fairly readable Java code, and run it.
Example:
BF code:
++++++++++[>++++++++++<-]> Initialize 100 (number of times to perform FizzBuzz)... | stackexchange/codereview |
I have recently finished a "django for beginners" book that ended with creating a small articles site. The last chapter adds a Comment model which is linked to Article model. However the comments are just created in the admin page. As a continuation of the book I wanted to test what I have learned and add the ability t... | stackexchange/codereview |
This is a first version of an implementation of std::optional it is supposed to compile under C++14. The public interface of the class is complete, but there are still quite a few things missing. Only a few of the constructor availability traits are checked, none of the noexcept clauses are implemented, no non-member f... | stackexchange/codereview |
I'm trying sqlx for the first time these days, sorry if this is a dumb question.
I'm writing a function that I want to take both PgPool and Transaction<Postgres>.
I'm using the below (SIMPLIFIED) code:
#[derive(Debug, Default, sqlx::FromRow)]
pub struct PgPlayer {
pub id: String,
pub created_at: time::OffsetDat... | stackexchange/codereview |
import java.util.*;
import java.io.*;
public class Player
{
Scanner read;
PrintWriter write;
private String playerid;
private int playerscore;
int x = 0;
ArrayList<String> n = new ArrayList<String>();
ArrayList<Integer> s = new ArrayList<Integer>();
Lis... | stackexchange/codereview |
I'm working on figuring out what the current 'business' day of the month it is. For instance, if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month.
Is there a better way of doing this?
var first = DateTime.Today.FirstDayOfMonth();
var businessDayOfMonth = 0;
for (var i = first; i <... | stackexchange/codereview |
I have a web application where I connect with a MySQL database using PDO and in some scripts there are a lot of queries one after the other which don't necessarily concern the same tables. i.e I will execute a SELECT statement in one, and then depending on some values I will UPDATE another and finally go and DELETE fro... | stackexchange/codereview |
In Objective-C, many of the NSString or NSMutableString methods for comparing or manipulating strings require a range argument--that is, an argument of data type NSRange (a struct containing a starting position and a length). This applies outside of NSString (NSArray for example), but NSString is where I see it most f... | stackexchange/codereview |
This is the original problem :
Input Format
The first line contains a single string, a. The second line contains a
single string, b.
Constraints
1<= |a|,|b| <= 10^4
It is guaranteed that and consist of lowercase English alphabetic
letters (i.e., through ). Output Format
Print a single integer denoting the numb... | stackexchange/codereview |
The task:
Given a string and a set of characters, return the shortest substring
containing all the characters in the set.
For example, given the string "figehaeci" and the set of characters
{a, e, i}, you should return "aeci".
If there is no substring containing all the characters in the set,
return null.
My so... | stackexchange/codereview |
This is a single page HTML/CSS layout. This is my first ever code and I know it's not perfect, but I would love for someone with a lot more experience to let me know of my mishaps.
<!DOCTYPE HTML>
<html>
<head>
<link type="text/css" rel="stylesheet" href="dereke.css"/>
<title>
</title>
</head>
<body>
... | stackexchange/codereview |
I'm working with Python 2.7.5 and I'm trying to make it match the PEP8 coding style. I have a few one line for loops but the issue is that they are each above 80 characters in length. Is it bad practice for me to make them multiple lines for the sake of PEP8?
So should something like this:
patient = ([d['patient'] for... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.