instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I really liked the close tray program that CD-ROM drivers programs used to include in MS-DOS days.
Since I live in a place where even getting an internship is impossible, I've decided to learn by myself.
I implemented this "Hello World" C# script to do that with a twist.
It will check the optical drive status and if op... | stackexchange/codereview |
Okay...so I have been self teaching for about seven months, this past week someone in accounting at work said that it'd be nice if she could get reports split up....so I made that my first program because I couldn't ever come up with something useful to try to make...all that said, I got it finished last night, and it ... | stackexchange/codereview |
class BinaryTreeNode {
private BinaryTreeNode left;
private BinaryTreeNode right;
private int data;
BinaryTreeNode(int d) {
data = d;
}
public void insertLeft(BinaryTreeNode n) {
this.left = n;
}
public void insertRight(BinaryTreeNode n) {
this.right = n;
}
public int height() {
... | stackexchange/codereview |
Are there any optimization suggestions?
<?php
# Pascal's Triangle using Recursion.
$rows_to_generate = 15; // Define number of rows you want to generate.
$storage = array();
function get_elem($row,$pos) // generate element having number of row and number of position.
{
global $storage;
if(isset($storage[$ro... | stackexchange/codereview |
I made a Tic-Tac-Toe game in WPF and was just hoping for some input as I am pretty new to WPF and I am still a student so I'm sure that my C# code in general may be lacking
XAML:
<Window x:Class="TicTacToc.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.micr... | stackexchange/codereview |
A previous question regarding Linny exists here.
After a wonderful response on my previous question regarding my developing programming language, I worked on it for a couple days, and am returning for more scrutiny. What I added:
If Statements ( no else )
Functions ( with calls )
For Loops
Math operations
User input (... | stackexchange/codereview |
How can I imrpove the performance of this T-SQL statement?
SELECT Code, Description
INTO [DBApps_Pulse_WarehouseAreas].[dbo].[Tbl_Partmaster]
FROM SYSDataBridge.dbo.View_Pulse_Partmaster_Synchronized
ALTER TABLE [DBApps_Pulse_WarehouseAreas].[dbo].[Tbl_Partmaster] ADD PRIMARY KEY (Code)
| stackexchange/codereview |
This algorithm is meant to read a string of numbers on an input, a naive substitution cipher code (A = 1, B = 2, ..., Z = 26) and output the number of ways the code could be interpreted (e.g. 25114 could mean 'BEAN', ‘BEAAD’, ‘YAAD’, ‘YAN’, ‘YKD’ and ‘BEKD’, hence output is 6).
It is working properly, but not fast eno... | stackexchange/codereview |
The task
is taken from leetcode
There are two sorted arrays nums1 and nums2 of size m and n
respectively.
Find the median of the two sorted arrays. The overall run time
complexity should be O(log (m+n)).
You may assume nums1 and nums2 cannot be both empty.
Example 1:
nums1 = [1, 3]
nums2 = [2]
The median is 2.0
E... | stackexchange/codereview |
I have to benchmark my code often, and decided that it is about time to implement an easy API for that:
current_time.h:
#ifndef CURRENT_TIME_H
#define CURRENT_TIME_H
#include <chrono>
#include <cstdint>
class CurrentTime {
std::chrono::high_resolution_clock m_clock;
public:
uint64_t milliseconds();
uint6... | stackexchange/codereview |
I have a very large dictionary that contains key-value pairs where the key is a string and the value a list. All lists have the same lengths. I want to split up the dataset (dictionary) in two based on the values in one of the lists. One of the lists will contain binary values (i.e. 0 or 1). I want to split up the dict... | stackexchange/codereview |
I am trying to search a json string(events) from a given list (eventSubscriptions).Here is what I have tried.
import com.fasterxml.jackson.databind.ObjectMapper;
private boolean isEventsOverlapping(String events, List<EventSubscription> eventSubscriptions) throws IOException {
List<String> eventsList = ne... | stackexchange/codereview |
This is a simple hello world sample project used for instruction. I'm just looking for general comments on the approach and design.
AdvancedHelloWorldTest.java
/**
* AdvancedHelloWorldTest.java
* 2014 GetGnosis.com
*/
package com.getgnosis.tutorials.tutorial01001;
import static org.junit.Assert.*;
import java.io... | stackexchange/codereview |
I've made a Bash script to monitor some server log files for certain data and my method probably isn't the most efficient.
One section specifically bugs me is that I have to write a newline to the monitored log so that the same line wont be read over continually.
Feedback would be greatly appreciated!
#!/bin/bash
serv... | stackexchange/codereview |
I am writing a C# program wherein I need to populate an array based on a lookup table and set of string arrays with metadata. My lookup table looks like this (Table with key: transmitter, value: Array of receiver):
{
LED1: ["px1","px2","px3"],
LED2: ["px4","px5","px6"]
}
and my meta arrays looks like this (it ... | stackexchange/codereview |
I'm assigning a HEX-Value to a byte in a byte array and then send this byte array to a serial port. If the value is bigger than 255 the corresponding HEX-Value is supposed to be split into two.
Example: 750 = 0x2EE so A[0] = 0x2 and A[1] = 0xEE
Is this an efficient way to do the task that I want it to do? From what I r... | stackexchange/codereview |
I've recently started programming and been self-studying on various online courses + official documentation of oracle / java. Code is quite messy and if you don't have time to understand it, I wouldn't even bother in your place. This is also not Object Oriented since I didn't see a reason to do it that way although I w... | stackexchange/codereview |
I am working on a code that will minimize the number of ingredients necessary to make some dishes.
Each dish can be prepared in an arbitrary large number of ways, with combinations of two ingredients. The result is a tuple of recipes.
I have a code that works, but if there are a large number of items, it is very slow a... | stackexchange/codereview |
Need to write a function that takes an open file as the only parameter and returns a dictionary that maps a string to a list of strings and integers.
each line in the text will have a username, first name, last name, age, gender and an e-mail address. The function will insert each person's information into a dictiona... | stackexchange/codereview |
Is the following query is vulnerable in terms of $itemstatus? I want to be sure about it. $yesorno is a user input which is sanitized and it's fine, however, $itemstatus is a not user input but is included in the query. Can $itemstatus be manipulated or overall if it's vulnerable?
$username = $this->site->SanitizeI... | stackexchange/codereview |
I have implemented a simple iterator. Just want to check if I have missed anything.
interface iterator<E>
{
boolean hasNext();
E next();
}
class Iterator<E> implements iterator
{
E[] arr;
int curPos = 0;
@Override
public boolean hasNext()
{
... | stackexchange/codereview |
The code that was just added to Rubberduck will allow us to set up hotkeys for our features, so that next release, Ctrl+Shift+R brings up the refactor/rename dialog, for example.
The requirements were roughly:
Let client code know when a keypress is captured in a code pane
Enable registration and handling of hotkeys
... | stackexchange/codereview |
I'm trying to learn C++ having come from a C/Assembly background. I thought one of the first tools I'd make as a project is a "directory tally" program:
It will count all the files in the current directory
If the user specifies, it will count all the folders in the current directory too
If the user specifies, it wil... | stackexchange/codereview |
While trying to learn more about arrays in C, I tried to write some code that did the following:
Read a stream of numbers from the stdin and store them in an array
Print the array in the order the numbers have been stored (i.e. print the original array)
Print the array in reversed order
Sort and print the array
Given ... | stackexchange/codereview |
I work in the training department of a captioning agency, where I spend a lot of time grading trainee's dictation transcripts.
We receive the transcripts of trainee's dictation of test audios and then compare them with Microsoft Word to the original transcript, highlighting incorrect words yellow, omitted words blue, a... | stackexchange/codereview |
From time to time I use Python's poplib module to inspect/manipulate POP3 mailboxes, often interactively. I find the interface very cumbersome however, so I decided to try to make a wrapper that's easier to work with. I haven't tried to make it complete, rather it mostly just does what I need it to do.
I'm mostly happy... | stackexchange/codereview |
This reverses the case of a character in a string (a string being an array of characters). How does it look? Anything I can improve on? Besides documentation, in particular, any thoughts on the type casting found in str_case_rev?
#include <stdio.h> // fprintf
#include <stdlib.h> // malloc
#include <string.h> // strlen... | stackexchange/codereview |
How can I combine multiple DNS lookups without nesting a whole bunch of if else statements? How would this impact performance? I would ultimately like the function to lookup all DNS addresses simultaneously.
function checkInternet(isConnected) {
require('dns').lookup('a.root-servers.net', function (err) {
i... | stackexchange/codereview |
I tried to write a program in Prolog and describe a family tree:
parents(uranus, gaia, rhea).
parents(uranus, gaia, cronus).
parents(cronus, rhea, zeus).
parents(cronus, rhea, hera).
parents(cronus, rhea, demeter).
parents(zeus, leto, artemis).
parents(zeus, leto, apollo).
parents(zeus, demeter, persephone).
man(uranu... | stackexchange/codereview |
I am trying to accept JavaScript array literals in an HTML text input.
The problem is that HTML text inputs are captured as strings, such that an input of ['name', 'who', 1] becomes "['name', 'who', 1]".
My intention is for the following samples to yield the corresponding outputs.
"['river',"spring"]" // ["r... | stackexchange/codereview |
I am trying to convert "Random = 1" into dictionary {"Random":1}
I tried
Key = (line.split('=')[0]).split()[0] #to get key and remove spaces
value = (line.split('=')[1]).split()[0]
CQ_Options[Key] = value
How could I do it in more mature way?
| stackexchange/codereview |
The code works just fine, but recently performace has taken a hit and it has SQL Timeouts far too often. I have it set up so I can run 50 different version of the application two for each different m.qlevel.
This allows it to run fairly fast, but the SQL timeouts are requiring to much babysitting.
document_attachments... | stackexchange/codereview |
Here is a vanilla JS module that I wrote for sorting and searching an array.
I would appreciate feedback on the design of the module as I'm new to writing javascript in modules and don't know if I'm missing the point.
"use strict";
/**
* Find is an outer function
* @param {int} needle Value received from the... | stackexchange/codereview |
I wrote a simple function that finds a word in a string without use of the re module.
My function looks like this:
def find_in_string(string, word):
Indices = ()
wordlength = len(word)
for i in range(0, len(string)):
if string[i:i + wordlength] == word:
Indices += (i,)
return Indices... | stackexchange/codereview |
How can this code be improved? I'm a novice programmer trying to learn ml by doing it from scratch. This code is part of a transformer model that I'm working on. Do you have any ideas about how to improve it for better performance and easier reality?
import jax
import jax.numpy as jnp
class Embedding():
def __in... | stackexchange/codereview |
I've made a little function to eliminate continuous duplicate from a std::vector. I have to use C++03.
For example, if a vector of ints is composed of: 1,1,2,3,,3,1,1,2 my function should return 1,2,3,1,2. I've tried to use templates (I've just began to use c++) and made it as fast as possible!
template<class T>
vector... | stackexchange/codereview |
I'm not sure if this is the right way to do this, but I want to simply this script and hopefully use CSS3 animations. The code is really large, and parts are very irrelevant, so I'm wondering if I should first get rid of all the irrelevant parts, then go from there?
Here's the code:
var _target = null,
_dragx = nul... | stackexchange/codereview |
As a casual Rubyist I am mainly interested, how ideomatic my solution is.
class Integer
def divisible_by?(n)
(self % n).zero?
end
end
def fizzbuzz(upper_bound)
1.upto(upper_bound).map do |number|
next "fizzbuzz" if number.divisible_by? 3 and number.divisible_by? 5
next "fizz" if number.divisible_by?... | stackexchange/codereview |
I was having a discussion with my coworker about a function that returns either an empty string, or a string of a css class. The function is passed an object which has an HTTP status code, and then depending on that statusCode, it returns a value. We couldn't agree which is cleaner.
He wanted the function written as so... | stackexchange/codereview |
This code is part of a growing "primitive" tools collection here on github
Use Case
Consider:
IntArray ia = new IntArray();
ia.set(300, 5);
System.out.printf("Values at 10, 300, and 3000 are: %d %d and %d\n",
ia.get(10), ia.get(300), ia.get(3000));
This gives:
Values at 10, 300, and 3000 are: 0 5 and 0
Prim... | stackexchange/codereview |
This function has a set of radio inputs, for each radio there is a hidden text input. When a radio input is checked it shows its chained text input.
I've done it with a function constructor, and I could have done this with closures or with simpler invocation patterns. My idea is to have some robust function which I cou... | stackexchange/codereview |
Fishstacks is a deadfish derivative based on a stack the stack can only hold four elements when a fifth element is pushed the bottom element is kicked out and eventually printed out to the screen.
I've come up with an interpreter in TI-BASIC for my calculator. However, I fell slightly guilty about using all four variab... | stackexchange/codereview |
I have a function that sums two arrays element-wise and stops if the sum at a certain index is greater strictly than 1. This function is called lot of times (15817145 times for a small simulation and expects to grow a lot more as the simulation size grows). Profiling my code shows that it is among the five most consumi... | stackexchange/codereview |
I program python as a hobby and wanted to learn how to apply databases in a functional program, while at the same time make something useful. so I made a to do application with some basic functionalities.
add new to do task
look at all tasks
delete a task
This is the first time I used sqlite3, and I'm not very experi... | stackexchange/codereview |
In order to learn C++ I have written a solution to this Kattis "Hitting the Targets" problem
Basically the program is to accept some shapes (circles and rectangles) on std in and a set of points and output the number of shapes that include each point.
Seeing as it is my first C++ program I'm sure I have made significan... | stackexchange/codereview |
Project Euler #4 asks:
Find the largest palindrome made from the product of two 3-digit numbers.
The code is as follows:
module Main where
import Data.List (sortBy)
import Data.Ord (comparing)
palindromes :: [Integer]
palindromes = [calcPalindrome a b c | a <- [1..9], b <- [0..9], c <- [0..9]]
where
cal... | stackexchange/codereview |
How would you improve on this? It's been fairly long since I last did something slightly more extensive in C++, so I'm looking for ways to be more compatible with modern C++ ways, and this style of OOP. I think especially the user action part and new opponent generation might be what needs the most work?
main.cpp
#incl... | stackexchange/codereview |
The code is an implementation of looping text (similar to a circular buffer - wraps around when it reaches the edge of the defined bounds) with directional control.
The code is functional and works as intended, but I'm curious if there is anyway to improve the code even if it is only a small improvement (e.g. less garb... | stackexchange/codereview |
I have written a very simple web service with MVC and WebApi. Now I'm working on the client code which will be a WPF application (and soon Windows 8 Store/Phone app). What I have done works, but I'm not sure I'm doing it the "right" way. The purpose of the service is to check if there are any new software updates to th... | stackexchange/codereview |
I've done some reading about implementing AES256 and deriving a key from a password. If I understand correctly:
I want to generate a new salt (for the key) and a new IV (for the encrypted message) for every new message.
It should also not be a problem sending the salt and the IV together with the message.
I decided ... | stackexchange/codereview |
So I want to import and edit a huge amount of data. I have a file with multiple data sets from time series that are chronologically ordered. Now I want to open them and edit to have a final dataset where the files are edited and ordered.
The code looks like this but it is taking some time to load the data:
setwd <-("C:... | stackexchange/codereview |
I have an Engineer which doesn't look very good. How can I make him better organized? What about good practices?
Interface:
public interface Engineer {
String HOMELESS = "homeless";
String ENGINEER = "engineer";
String SOFTWARE_ENGINEER = "softwareEngineer";
String TEST_ENGINEER = "testEngineer";
S... | stackexchange/codereview |
I'm currently working on a tool that needs to decode, modify data, then re-encode that data using the Yaz0 format. Everything has been in a working state, but after running some code analysis on my program it turns out it is spending an obscene amount of time on the encoding portion (Over 95%). However, I cannot think ... | stackexchange/codereview |
I want to add a value multiple times at the beginning of a list, what I have is...
internal static class Helper
{
public static void Prepend(this IList<double> source, double value, int count)
{
for (var i = 0; i < count; ++i)
{
source.Insert( 0, value );
}
}
}
Then use it as follow
// create
v... | stackexchange/codereview |
Helo everyone, I need to review on function swapNode in doubly linked list. It works but I want to make it clearer and better. Are there any errors like memory leak in my code?
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
struct node;
struct list;
typedef struct node node;
typedef s... | stackexchange/codereview |
I build a function(A kind of puzzle) that counts from a matrix the number of valid count (Explanation below).
The matrix is made up of 0,1.
Input-
a matrix- list of lists
row number
column number
Output-
valid count.
Valid Count - This is the number of cells that are in the same row and column that we got in the In... | stackexchange/codereview |
I made my version of a tic-tac-toe game for fun, but as being new to coding, I would assume that there are far better ways to make this. I just want to simplify my code down to make it easier to manage. I would say the main problem is the code is repetitive. I've tried to use for loops to make the code more concise, bu... | stackexchange/codereview |
I have a class that serves to carry data between my JavaScript evaluation class and the player, via the Bukkit Conversations API, available in full on GitHub (you will need Bukkit and Rhino as libraries (you can just comment out the JNBT code, it's not important), and a Craftbukkit server to run it). I was wondering in... | stackexchange/codereview |
I recently suggested this method for emulating the Unix utility split in Python.
Is there a more elegant way of doing it?
Assume that the file chunks are too large to be held in memory. Assume that only one line can be held in memory.
import contextlib
def modulo(i,l):
return i%l
def writeline(fd_out, line):
... | stackexchange/codereview |
This is my brief summary of Pyglet: it's a powerful, efficient, high-tech cage. But once you're in there, once you call pyglet.app.run(), it's all over - you can't go back. Thus, there is this huge initialization process that you must split up into as many separate pieces as you can or you'll get lost.
I tried to split... | stackexchange/codereview |
I am learning Vue after working for some time with Angular and I'd like to hear experienced programmers concerning the implementation of my Progressive Bar service (in Vue it's called Plugin).
The idea behind it is to have a solid service which is responsible for the progress bar indicator.
I've got there a component w... | stackexchange/codereview |
I'm back with a hopefully revised and improved version of my RPG pokemon console game! Well, it's more like a "randomized" pokemon simulation as there isn't really any kind of strategy, it's only about getting lucky lol.
I have added more functionalities and made lots of changes and corrections as suggested, but I'm su... | stackexchange/codereview |
The following code has a Handler class that follows the classic Chain of Responsibility pattern. But we don't want to write a new handler class for every new type that we want to handle. I tried making Handler a template class, but it could not work because the class Worker is to derive from Handler, and thus I resor... | stackexchange/codereview |
I used numpy for the O(n) parts, but I didn't add any ability to change grid size because I still wonder if there's a way to make it better than O(n).
main.py:
import pygame
import numpy as np
from random import randrange
from clickablebox import ClickableBox
# values of grid spaces
EMPTY = 0
BUG = 1
SNAKE_UP = 2
SNAK... | stackexchange/codereview |
I'm implementing a Tic-Tac-Toe solver in Python. It contains two functions: assess to determine whether a given board position is a win for either side, and is_winner to traverse the game tree.
The end goal is to use this program to construct a lookup table that will be used by a JavaScript Tic-Tac-Toe frontend. But I ... | stackexchange/codereview |
Here is my code for implementing a linked list with custom allocators (the standard malloc/free and a simple bump allocator). I appreciate any comments or critiques about architecture, formatting, and anything in between. There are a number of files so I am very appreciative of comments even concerning singular functio... | stackexchange/codereview |
Imagine the following situation:
It is the year 20XX. You are a prodigious baker, capable of baking cookies at an astonishing rate of 1 cookie per second. Your archnemesis, an equally excellent baker, challenges you to a bake-off.
In this bake-off, you will need to bake 1,000 cookies total as fast as you possibly can, ... | stackexchange/codereview |
I would like to ask how I can make my code more simple and effective. I know that this code can be 100% better. I am supposed to load number for each array and then take the 2 arrays (4*3 and 3*4) and multiply them into 3*3 array.
The main point is making thescanf_s for both int a and int b in one "piece of code."
#inc... | stackexchange/codereview |
Linked:
Google reCAPTCHA Validator: Iteration II
I have also created a simple Google Recaptcha Validation class to handle verification.
I used some code from CodingFusion's post Google New reCaptcha I am not a robot using asp .net, but I have altered it so that it fit my use case, and to make it extendable and reusa... | stackexchange/codereview |
This is a Python discord.py bot I am working on. It shows the prices, 24-hour volume, 1h percent change, 24h percent change, 7d percent change and much more of the cryptos. I'm still working on adding the same stuff as I have for Ethereum as I do for the other cryptos, but it's a work in progress.
If you have any quest... | stackexchange/codereview |
What do you think about this code? Do you have some advices and remarks for me about them? I have started learning python recently.
types = {
"str": str,
"int": int,
"float": float,
"complex": complex
}
def my_input(kind, msg, msg_wrong, detail):
""" Add-in for input(). Performs validation of the ... | stackexchange/codereview |
I have the following code:
items = set() # use a set to not have duplicate items
a = requests.get(f"{BASE_URL}?{BASE_QUERIES}&cursor=*")
amount = a.json()["totalResults"] # in the range of 30 million
items.update(item["guid"].split("?")[0] for item in a.json()["items"]) # we only want the url before the query stri... | stackexchange/codereview |
I've gone through the docs in a fair bit of detail and understand that a setState function can be passed a function if the previous state is needed.
Here I am trying to, based on the state of a variable, set the state of another variable. This seems logically correct to me, but just feel weird. Looking for someone to s... | stackexchange/codereview |
I need my trading system demo reviewed. It implemented a simple system which parse the trading flow (logged in file) of different trader and calculate some important feature.
packets.h
#ifndef PACKET_H
#define PACKET_H
#include <stdint.h>
class Header{
public:
char marker[3];
uint8_t msg_type;
uint64_t seq... | stackexchange/codereview |
I'm trying to practice and learn design patterns, and I decided to create a weather app using the revealing module pattern. How can I improve on this, and what mistakes did I make?
Main.js
import '../styles/main.scss';
import {weatherModule} from './weather';
import {dateModule} from './date';
dateModule.getCurrentDa... | stackexchange/codereview |
I have done some research about intentions of UnitOfWork pattern. In short, what I understood is that UoW is needed for transactions. But I saw some code examples where people use UoW as factory for Repository objects as well, one example is DbContext from EF. My first thought about it doesn't it break single responsib... | stackexchange/codereview |
I hope someone can guide me in a way to make this code more efficient. Please explain the things you do simply because I'm no pro so more complex things I am unlikely to get.
If you have issues with variable names or are unsure of functions of the code please let me know! I will clarify and help in any way I can.
progr... | stackexchange/codereview |
I'm just getting started on the site CodeEval, and I submitted my first solution today. What I don't understand is why it's marking my (working) answer as only a "partial solution". The site doesn't seem to want to explain why my answer is only "partial", and I'm hoping someone here can explain why.
The challenge I was... | stackexchange/codereview |
Background
Disclaimer: Skip if you are not interested in the background. The code is far far simpler than this.
The problem is more about programming than math. Here is the definition of multiplication with broadcasting in human readable language.
I am trying to optimize the multiplication of large n-dimensional a... | stackexchange/codereview |
The puzzler:
This was sent in by a fellow named Dan O'Leary. He came upon a common
one-syllable, five-letter word recently that has the following unique
property. When you remove the first letter, the remaining letters form
a homophone of the original word, that is a word that sounds exactly
the same. Replace ... | stackexchange/codereview |
I am trying to achieve matrix multiplication using the concept of concurrency and cyclic barrier.
Here is the code snippet:-
import Jama.Matrix;
public class Application {
public final CyclicBarrier cyclicBarrier;
public Matrix A = new Matrix(200,120);
public Matrix B = new Matrix(120,100);
public Matrix C = new Matrix... | stackexchange/codereview |
Recently I was trying out this problem and my code got 60% of the marks, with the remaining cases returning TLEs.
Bazza and Shazza do not like bugs. They wish to clear out all the bugs
on their garden fence. They come up with a brilliant idea: they buy
some sugar frogs and release them near the fence, letting the... | stackexchange/codereview |
I'm doing some code revision and I'm looking at this portion of my Worksheet_Change() event:
If Target.Address = "$A$4" Or _
Target.Address = "$A$7" Or _
Target.Address = "$A$10" Or _
Target.Address = "$B$21" Or _
Target.Address = "$B$22" Or _
Target.Address = "$B$23" Or _
Targ... | stackexchange/codereview |
This is my first time I tried to implement a custom STL vector with iterator. I have some questions:
What are better ways to write an iterator?
I know that there is a const iterator so in my case I need to create a second class for iterator? Is there any approachable way to not repeat yourself with second (and others)... | stackexchange/codereview |
I have the following code for importing Yahoo contacts from an address book, but it imports only the top 30 contacts, not all of the contacts.
Anyways, I think another alternative (and better) way of doing it is by using another latest Yahoo API.
private const string _addressBookUrl = "http://address.mail.yahoo... | stackexchange/codereview |
basically I'm learning Java Swing by myself and I'm wondering what is the correct way to wrote code for it?
I don't want to have a big class with everything in it and I want to do in the most "correct" way.
For example, I have this program right there that it is supposed to paint N rectangles, where N is given in input... | stackexchange/codereview |
I recently made this tic-tac-toe program using tkinter, but I am quite new to tkinter, so I would be grateful for tips on how to improve the program. (Note that the actual tic-tac-toe logic is being done by the python-tictactoe library.)
This is my code:
import tkinter as tk
from tictactoe import Board
from tictactoe ... | stackexchange/codereview |
Can someone give me suggestions on how to improve this program?
The objective is to find the sum of all the multiples of 3 or 5 below 1000.
#include <stdio.h>
main()
{
int S, s3,s2,S1;
int a=333,b=3,c=999, i=5,j=995, k=199, m = 15, n= 66, o= 990;
S1= a*(b+c)/2;
s2= k*(i+j)/2;
s3= n*(m+o)/2;
S= ... | stackexchange/codereview |
my use-case (an home task to practice abstraction, exception handling, unitests) is regarding a message-queue with small-fixed-size client requests from stdin of such:
[ENQ] data (insert json data to queue)
[DEQ] (get latest in queue)
[STATUS] (status of queue)
[STOP] (stop server)
[EXIT]
Without an... | stackexchange/codereview |
First LOLCODE program, run here. This program inputs a Fibonacci number from the user, then determines and prints whether the number is in the Fibonacci series. What do you think?
HAI 1.2
HOW IZ I GetNum
VISIBLE "Entr yr numbr: "
I HAS A WatzNum
GIMMEH WatzNum
FOUND YR WatzNum
... | stackexchange/codereview |
The following small function receives a range and returns it with only the cells that contain constants or Nothing if there's none.
Private Function GetConstants(ByVal Cells As Range) As Range
On Error GoTo ErrHandler
Set GetConstants = Intersect(Arg1:=Cells.SpecialCells(Type:=xlCellTypeConstants), Arg2:=Cells)
E... | stackexchange/codereview |
I wrote this program to help myself learn C. It is the result of a few days of hacking things together until it worked.
This program takes 2 integers as inputs in the range of 0 to 10100 and outputs the sum of the inputs.
The code used to generate the final result doesn't really feel that elegant so it would be great ... | stackexchange/codereview |
I have a method which is part of a request-handling class. It creates a URL, depending on the resource send request.
This is a part of the REST service:
private static URL addQueryToUrl(String qry) {
try {
if ("playerProfile".equals(requestingService)) {
return new URL(PLAYER_URL + qry);
... | stackexchange/codereview |
I am new to F#. Is the following code, which represents about three hours of work, a canonical way to achieve binary search? If not, how can it be improved for readability and maintainability?
let binarySearch (array: 'a[]) (target: 'a) =
let rec search min max =
match (min, max) with
| (min, max)... | stackexchange/codereview |
Challenge:
Given two strings, A and B. Find if there is a substring that appears
in both A and B.
Specifications:
Several test cases will be given to you in a single file. The first
line of the input will contain a single integer T, the number of test
cases.
Then there will be T descriptions of the test cases.... | stackexchange/codereview |
I have this PHP curl function to check if a site is online or not:
function check($proc,$url,$keyword,$method,$timeout,$maxredirs) {
// Format Link
$link = $proc."://".$url;
// Agent
$user_agent='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.... | stackexchange/codereview |
Perfect numbers are strictly positive whole numbers of which the sum of their positive divisors equals a multiple of the number itself. An example of a 3-perfect number is 120. The sum of all divisors of 120, namely 1+2+3+4+5+6+8+10+12+15+20+24+30+40+60+120 = 360 equals three times 120.
My code does work, but it's not ... | stackexchange/codereview |
I wrote wrapper for Connection. It uses my Connection pool implementation. When the wrapper closes, the connection goes back to pool.
public class ConnectionWrap implements Connection {
private Connection delegate;
private ConnectionPool pool;
public ConnectionWrap(Connection delegate, ConnectionPool pool)... | stackexchange/codereview |
Looking around for modern Crypto libraries.
Could not find anything good.
I know I probably did this all wrong so work with me here. There will be four different reviews for four structures that build on each other:
Hashing
Hashed Key
Password Key
Salted Challenge Response
This is the hashing code and provides a simp... | stackexchange/codereview |
I'm beginning the long process of developing an Adventure Game/RPG and I was hoping to get some review on a resource system I'm coming up with. How it works is, a resource is generic to every resource in the world. Each resource will have a name, a random yield, and a random quality. So I've created an interface for ... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.