instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
Following this idea for pretty printing of numpy ndarrays, I have developed a very primitive prototype:
def ndtotext(A, w=None, h=None):
if A.ndim==1:
if w == None :
return str(A)
else:
s ='['+' '*(max(w[-1],len(str(A[0])))-len(str(A[0]))) +str(A[0])
for i,AA in e... | stackexchange/codereview |
I have rows in a database table with a hierarchypath column. The values in the column are hierarchy paths with up to four levels:
HIERARCHYPATH
---------------------------------------------------
FACILITIES \ FIREHALL \ PLUMBING
FACILITIES \ PARK
ROADS \ GRASS/TURF BLVD MAINTENANCE
ROADS \ SIDEWALKS \ REPLACEMENT
FACI... | stackexchange/codereview |
Background
The platform I'm coding for is an esoteric scripting engine coded some time ago that only has limited capabilities. Because I cannot produce a version of the engine that can be run on its own (it needs to attach to a running instance of a game), I have translated the code into C# with limitations to mimic th... | stackexchange/codereview |
Can you please review the following code and give any suggestions for improvment?
Class ContactList.java
import java.io.*;
import java.util.*;
public class ContactList {
public static void main(String args[]) throws IOException {
Contact contact;
contact = new Contact();
int action = 0;
ArrayList<Con... | stackexchange/codereview |
I have this program finding 2 numbers in the array (unsorted) so that its sum equal to the target sum. Here is my program:
vector<int> findNumbers(vector<int>& nums, int target)
{
vector<int> result;
for(int i = 0; i < nums.size() - 1; i++)
for(int j = i + 1; j < nums.size(); j++)
... | stackexchange/codereview |
I will first explain the context. I want to read serie subtitles contained in .srt files. I have already done the part of extracting the words from the files (and how many times the word appears for a serie) but when it comes to inserting the data in my SQL Server database, it takes more and more time to do the updates... | stackexchange/codereview |
A member of SO who I immensely respect just told me that the code below makes him uncomfortable.
class GameData:
def __init__(self):
self.date = []
self.time = []
self.game = []
self.score = []
self.home_odds = []
self.draw_odds = []
self.away_odds = []
... | stackexchange/codereview |
I wrote code for the following problem:
Given a string, print out the number of deletions required so that the adjacent alphabets are distinct.
Please suggest different methods by which I can increase the speed of execution.
tst = int(input())
for i in range(0,tst):
str = input()
length = len(str)
str = l... | stackexchange/codereview |
Rags, again.
This is the rewrite of Read stdin like a dictator.
From that post:
All too often I find myself wanting to allow only a certain list of characters to be written to stdin, and only recently did I actually bother to implement it. In Python, of all languages!
Essentially, this module provides a few APIs that... | stackexchange/codereview |
I have a table in my database containing email and email_state amongst other values.
Email is the email of the contact, and email_state is the existence of the email. It can contains 3 values: null (not checked), EXISTS or NOTEXISTS.
When the application (a PlayFramework Java application) starts, I call the start() met... | stackexchange/codereview |
Is this the best way to do this sort?
assets.OrderBy(a =>
a.GalleryItems != null &&
a.GalleryItems.FirstOrDefault() != null
? a.GalleryItems.OrderBy(gi => gi.SortOrder).First().SortOrder
: 1000)
Basically I have a group of assets, which contain a group of gallery items with a sort order. I nee... | stackexchange/codereview |
I've decided to try and start programming using Object-Oriented-Programming, so I built a small terrain generator that could be done using something as simple as this:
import random
for _ in range(1000):
print random.choice('*#~o'),
Instead, I decided to have a go at OOP and made it like this instead:
# Terrain ge... | stackexchange/codereview |
I'm working on a vue.js / nuxt.js project, applying the Atomic Design methodology, I need to do one to set the grid layout and using CSS Grid Layout.
I already did the component, but I think I did not do it the best way ... the code is great and not very smart, lots of manual work, I would like your opinion and help to... | stackexchange/codereview |
I just started learning OOP from Mosh on YouTube and I looked for easiest exercises to practice. Can I get a feedback on my code please? What I did wrong and what I should change?
In the code there are two exercises: the first one is a temperature converter and the second one is a currency exchange.
let cel = "";
let f... | stackexchange/codereview |
I have been solving the following problem:
Input array: \$[7,4,2,5,1,9,6]\$
Output array: \$[1,4,6,9,7,5,2]\$
I tried to do it in the following way:
Sort the array. So, Input array becomes \$[1,2,4,5,6,7,9]\$ run time \$O(n \log n)\$
Numbers in even indices are \$[1,4,6,9]\$ an in odd indices are \$[2,5,7]\$. Move al... | stackexchange/codereview |
I've already written simple to do app using VanillaJS. Can you make any code review - JS? It also contain basic validation, if user type some thing two times.
(function() {
"use strict";
var addinput = document.getElementById("addinput"),
addbtn = document.getElementById("addbtn"),
todoList =... | stackexchange/codereview |
Consider two versions of implementing the same functionality.
Version 1 -
Functions calculateA(),calculateB() and calculateC() dependent on iteration variable of calculateAll().
class Box
{
void calculateAll()
{
for(unsigned i = 0; i < _values.size(); i++)
{
calculateA(i);
... | stackexchange/codereview |
The code below shows the pattern I use to manage properties in my classes when I have the following requirements:
Some properties are slow to calculate and are rarely used, so I want them to be lazy
Some methods change the value of a property
The properties are defined the first time they are requested and are delete... | stackexchange/codereview |
I am trying to implement Deep Quaternion Networks. I was able to implement the batch normalization technique. But it requires a lot of GPU memory. Is there any way I can optimize the code provided below?
class MyQuaternionBatchNorm2d(torch.nn.Module):
def __init__(self, num_features, eps=1e-5, momentum=0.1, affine... | stackexchange/codereview |
Recently I needed to manipulate with cookies using JavaScript, so I wrote a class:
function Cookies() {
var cookieLifeTime = null;
this.setCookie = setCookie;
this.getCookie = getCookie;
this.deleteCookie = deleteCookie;
this.setLifeTime = setLifeTime;
function setLifeTime(lifeTime) {
... | stackexchange/codereview |
Assume I have the following list (List<string>)
G
G
M
T
I'd like this to be in an order where the same letter will not occur twice, such as
G
M
G
T
(I appreciate other variations would also suffice)
Please note, if I had the following
G
G
G
G
G
M
T
Then of course some values will have to occur concurrently. The posit... | stackexchange/codereview |
I've created a React widget that pulls data on crypto-token pairs from a remote API and makes that data sortable by headers and searchable.
You can view a demo of it here.
Is this a maintainable way to get this data and provide sort and search functionality? Am I using async/await correctly?
import React, { Component }... | stackexchange/codereview |
The objective of this code is to create a command that move files and leaves links in their place. I'm just a beginner in shell scripting and it would be quite useful to hear your opinions on how to improve my code.
I already used https://www.shellcheck.net/ to check my code.
Questions
I change directory several times ... | stackexchange/codereview |
I have written the following routines to work with digital images in various representations.
Can I optimize them for better accuracy and performance?
public static partial class ImageDataConverter
{
#region Bitmap ToBitmap32(int[,] image)
//Tested
///Working fine.
public static Bitmap ToBitmap32(int[,... | stackexchange/codereview |
I wrote a small reusable component based of some of the examples to this question on Stack Overflow about Activating OnBeforeUnload only when field values have changed.
It works like this:
You can specify the portion of the page that it will use to listen for any data changes to input fields by adding the class .alert... | stackexchange/codereview |
I have the following SCSS and I'm curious as to how I can improve it, and reduce the amount of repetition...
I plan on adding more colors, but I don't wish to keep copy/pasting the same block over and over.
.panel-alt {
&.panel-default {
border-color: $btn-default-bg;
> .panel-body {
ba... | stackexchange/codereview |
I got an idea to make a Roman/Arabic number converter, and I would like to hear your thoughts, where I could improve it, if there are Python specific things that I missed, so on and so forth.
# Decodes roman numerals
def get_arabic_numbers(t):
# Hold the numbers in the list
l = list()
# The format
form... | stackexchange/codereview |
Several years ago (must have been 2012 or so) I wrote a module to manage command-line parameters in a unix-like fashion. At the time, the compilers I had access to were still working their way up to the 2003 standard. In particular, allocatable strings and class(*) still had issues. So far, the module has served me wel... | stackexchange/codereview |
Problem statement is at http://www.codechef.com/DEC13/problems/MARBLEGF
Lira is given array A, which contains elements between 1000 and 2000.
Three types of queries can be performed on this array: add a given value to a single element on it, subtract a given value from a single element on it and find the sum of the ... | stackexchange/codereview |
I have been meaning to learn LISP and for a small task I wanted to find out the sum of all integers on STDIN. So for
> clisp a.lisp
1
2
3^D
6
My code is as follows. I have a small helper function, my core function and the invocation of it.
(defun read-int()
(parse-integer (read-line)))
(defun sum-stdin()
(handl... | stackexchange/codereview |
I am new to rust and wanted to get going with a medium-sized project to help learn. I've settled on creating some basic quantum mechanics code which starts with this bare-bones file reader. It takes a pdb file which is just a list of atom coordinates and the connections between them - with some extra information. I've ... | stackexchange/codereview |
I'm learning web services using Java. I just don't know which method has what advantage over another, like which one is more secure? Which one will be more faster?
POST resource is as follows:
@POST
@Path("postactivity")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String createAct... | stackexchange/codereview |
I've designed and implemented a CPU architecture in one day. Of key architectural details: Processor is supposed to support updatable microcode, Architecture extensions and Is designed to be implemented sortof like a real CPU (at least in Logisim Evolution). As I was coding for speed, this 0.5 kiloline monster appeared... | stackexchange/codereview |
A while ago I had the idea to store all the important configuration and dotfiles from my system in a Git repository. That saved me a few months ago: My harddrive died, but I could get back to work with Ubuntu and that repository quickly.
Only problem: I maintained that repo by manually copying the files from the variou... | stackexchange/codereview |
The purpose of this little program is to:
Separate IPv4 addresses and IPv6 addresses
Will be able to sort them even if the formatting of the input is not great
Sort them into an order
Print them into the system terminal in ascending and descending order
I would like to know if you think the program what it is meant t... | stackexchange/codereview |
I have a set of template functions that have itrator types as template parameters, so can be used with any kind of iterators. std::find can be a good example.
Also I have a class that uses this function in its implementation and I don't want to expose my algorithms' header. Regarding the template function, inside my cl... | stackexchange/codereview |
The goal is to construct a DbContext with a connection that uses an access token. The access token is acquired with ADAL (Active Directory Authentication Library).
The problem is that acquiring an access token is an async operation. Luckily, ADAL uses ConfigureAwait(false) for its async calls, so it should be safe to d... | stackexchange/codereview |
I recently submitted a code-challenge for an interview according to the following guidelines:
About
Write a function or method that accepts two mandatory arguments and returns a result.
Requirements:
Use Ruby or another language of your choosing, and write production quality code.
Your function or method should not us... | stackexchange/codereview |
This is a follow-up of 'any' class implementation. After posting my answer, I kept working on the code towards parameterizing with respect to memory management as I had promised. I ended up in some pretty non-trivial piece of code that I decided to post here as a new question for review.
Basically, this is quite close ... | stackexchange/codereview |
I created my first java game in LibGDX and it's working fine but I'm 100% sure a lot of my code can be written shorter than now. Does anyone have tips how I can make this code better?
Like the Gdx.input.getX(), if I run this on Android, it's fine, but when I run this on PC, you just have to hover over your screen to ch... | stackexchange/codereview |
Let's assume I have an enum type with currency:
public enum CurrencyType {
USD("American Dollar", "USD"),
EUR("Euro", "EUR"),
JPY("Japan Yen", "JPY");
private final String fullName;
private final String shortName; // enum valirables can change in the future, so I do not use Currency.name()
pr... | stackexchange/codereview |
The main purpose of my program is to extract GPS information from text messages sent to several GSM modems send from various GPS tracking devices. The main flow of my program loops in three steps:
Receive SMS message (with the help of SMSlib)
Extract data with regex
Push data to MySQL database
I've only been exposed ... | stackexchange/codereview |
Background
We have to cater to large screens. So I created this portion of a grid system which is shown to users with screens larger than 1800px.
Solution
This grid is 1800px wide but can shrink down to 1200px, has 8 columns. I wanted 10px margin around the sides of each column. So I arrived at the number of 0.55555%. ... | stackexchange/codereview |
I think the general functionality is there, but sometimes it looks a little slow/clunky when I try to run my app. Highlighting cells can be slow as it skips over some of the cells I hover over if my mouse is moving somewhat fast. Also the speed the grid evolves doesn't always consistent.
I suspect that calling setState... | stackexchange/codereview |
I tried to implement a generic stack in C using void pointers and tried to keep it as simple as possible by delegating all responsibility to the caller of the functions and avoiding more sophisticated approaches.
stack.h
#ifndef STACK_H
#define STACK_H
#include <stdbool.h>
struct Stack {
void *data;
struct St... | stackexchange/codereview |
I've got the following task:
Keeping in mind Horner's Scheme, write an application that converts a given number x in n-number system to m-number system where m, n <= 10. x is a natural number or zero, x <= unsigned(-1)
My code is as follows:
#include <iostream>
int toDecimal (int, int);
int fromDecimal (int, int);
i... | stackexchange/codereview |
The purpose of this code is to ask the user to input an email address but it must contain "@" and ".co". The code works but it is too long so I would like to know if there is any way to shorten it using functions.
email_address = input("What is your email address? ")
while "@" not in email_address:
email_address = ... | stackexchange/codereview |
I'm writing some code to return results from a web service and display them on screen. If the service is down I want to use Lawnchair to serve cached results.
<h2>Test</h2>
<p>Click to load!</p>
<button class="btn" type="button" onclick="loadData()">Load</button>
<div id="results"></div>
@section scripts{
<script>... | stackexchange/codereview |
This is a follow-up to my ex-posted Blackjack game that uses a MySQL database to store the accounts and user's money. I tried splitting display_info() a bit, I also added a check for validating the Email address and the passwords are now hashed.
from random import shuffle
import os
import cymysql
from getpass import ge... | stackexchange/codereview |
This is a version of C++17 regex_replace that handles arbitrary functions to do the replacement, instead of using regex_replace's weird minigame language ($&, $', and $`). Also, I made it take string_view instead of const string&; that's more to see if people have opinions on string_view than for any practical reason. ... | stackexchange/codereview |
I am rewriting a VB.NET application in C#. This code was originally done in 50 lines and I am trying to clean it up. As you can see I have gotten it down to 10 but I still feel its ugly. I want to convert the call and assignments into one Linq statement or method chain. See Comments:
public void Update(IEnumerable<MyOb... | stackexchange/codereview |
I must write updates in a database from a flat file (CSV). I want to do that in the shell, with tools such as AWK.
#!/bin/bash
cat in.csv | sed -e '1d' | awk -F';' -v q=\' '{ # For each line.
print "DECLARE @v_trmID varchar(16) = " q $1 q
print "DECLARE @v_trmNom varchar(6) = " q $3 q
print ... | stackexchange/codereview |
I have two classes ExceptionLog and DebugLog
public class ExceptionLog {
public static String StackTrace {get; set;}
public static String ClassName {get; set;}
public static String MethodName {get; set;}
public static String LogType {get;set;}
public static Exception ex {get;set;}
public Static... | stackexchange/codereview |
I am making a filter to get posts by status that are saved by post metavalue in a Wordpress plugin. It is a question and answer system, where the question and answer are post objects.
// Filter post where
function posts_where( $where ) {
global $wpdb, $dwqa_general_settings;
switch ( $this->filter['filter... | stackexchange/codereview |
I'm trying to solve the 15 Puzzle problem using IDA* algorithm with a Linear Conflicts heuristic. I already implemented the heuristic from what I understood : link
Here's my goal state ("snail" format) and initial state :
GOAL_STATE =
[[ 1 2 3 4]
[12 13 14 5]
[11 0 15 6]
[10 9 8 7]]
INITIAL STATE =
[[11 ... | stackexchange/codereview |
I'm making a code that, starting from an xml file:
stores the index of child elements of a tag and the child elements as key, values in a dictionary;
deletes keys whose values contain a certain string;
joins the dict values and extracts their text;
replaces certain values with "";
counts the occurrences of specific re... | stackexchange/codereview |
I had a look on Stack Overflow etc. on how to perform a contains ignore case with n given strings. Most answers suggested using regex for this task. Although it's a valid option, I prefer doing upper-case for both strings and apply a .contains afterwards.
The solution I came up with looks like this:
(defn desc-matche... | stackexchange/codereview |
I would like to improve the function below without calling twice InserisciRigaNote.
Before I fill my dictionary. When I compare idNota with the current database id I check if it is equal or not, if different means that the dictionary is filled and I can proceed with the insertion of the row in DataGridView
I have a que... | stackexchange/codereview |
I posted an answer on StackOverflow which I believed to be adherent to the principles of Functional Programming.
However, I was told by the original asker that it was not 'functional' as my function used an internal variable oldData which kept track of results.
I believe that the code still satisfies the paradigms of... | stackexchange/codereview |
I am going through the CodingBat exercises for Java. Here is the one I have just completed:
Start with two arrays of strings, a and b, each in alphabetical order, possibly with duplicates. Return the count of the number of strings which appear in both arrays. The best "linear" solution makes a single pass over both ar... | stackexchange/codereview |
I'm practicing by writing utilities for myself; I prefer CSS3 transitions over jQuery animations whenever possible. This is intended to be used for transitioning multiple DOM elements who's relationship to one and other is only given by the context (ie. on clicking a menu icon, hide/show, relocate, resize, etc. multipl... | stackexchange/codereview |
This takes a collection of Objects from JavaScript and puts them into a Java project. How can I improve this code? What's the best solution?
// JavaScript fetch data into List ChartData
int i = 0;
int k = 0;
// output
for (Object currObj : ChartData) {
// get all fields of Object
for (Field field : currObj.g... | stackexchange/codereview |
Is there any way I can cut down on code? I'm new to this.
Sub addtest()
Dim decision As Char
Dim fullline As String = " "
Dim word(9), def(9), minorerror1(49), minorerror2(49), minorerror3(49), minorerror4(49), minorerror5(49) As String
Console.Clear()
Console.WriteLine("Please select the year o... | stackexchange/codereview |
I am working on a project that needs algebra operations. I have coded a Matrix class (only needed 4x4 matrix), and a Vector4 class. The classes working fine, but I would know if there are some bad practices that I use, and want you to help me improve this classes. Last time I encountered some problem when wanted to cod... | stackexchange/codereview |
I am currently reading an algorithms book and I read on the insertion and merge sorts. I implemented the merge sort in C++, The first function MERGE is responsible for the merging of the two subarrays part and the function MERGE_SORT is the actual algorithm. I am interested to know whether or not my code has a good rea... | stackexchange/codereview |
One day I realised that my Android project utilizes AlertDialogs here and there in very ineffective way. The heavily duplicated portion of code looked like this (actually, copied and pasted from some documentation):
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("Are you sure you wan... | stackexchange/codereview |
My code works and does what it is supposed to. However it needs to be more efficient. Could anyone help me tidy this up and show me where I could perhaps not rely on large loops (which it does a lot and slows it down).
import java.util.ArrayList;
public class PigLatin {
public String translate(String str) {
fin... | stackexchange/codereview |
(Please note: the post about the compose implementation announced below is now available.)
This is about decorating callables by making their argument and return value to be a std::optional. Therefore I created the template function make_skippable that takes a callable and returns a wrapping lambda having an optional a... | stackexchange/codereview |
I am upgrading an old massive website that is a Classic ASP \ ASP.NET hybrid. I still have a long way to MVC.
Right now I want to convert all code that uses ODBC to the mysql connector specific code.
I've made these 2 functions:
1:
DataTable GetData(string query, List<MySqlParameter> sqlParams, string sComment="")
{
... | stackexchange/codereview |
Discussion
I just started learning about Merkle Trees and wanted to get some practice by attempting to implement a very simple Merkle Tree.
The constructor for the tree takes some type of hash function, and an array of byte[] values that represent the "leaf" node values.
I construct a tree by first hashing the leaf nod... | stackexchange/codereview |
It would probably be too easy if the old Scheduler worked as intended being that simple. But an eye-openig review showed that from time to time it'll miss one second due to 14ms timer incaccuracy. This of course would have bad implications on the schedules (they wouldn't fire if their second was skipped).
I spent some... | stackexchange/codereview |
I am trying out a small piece of code that would generate HMAC-SHA1. I have been asked to code the HMAC implementation myself using the OpenSSL libs for SHA1 calculation.
After 'wiki'ing for the algorithm, here is what I have below. I have used input with RFC 2104 specified test values:
key = 0x0b0b0b0b0b0b0b... | stackexchange/codereview |
I am coding a web based solution which consists of N number of tiers, these are:
UI
Web API
Business
The question I have is related to validation, repository and CRUD operations. I am adopting the command / query pattern whereby I have my repositories for data retrieval only (see below) and its query dependencies inj... | stackexchange/codereview |
This is my second attempt with unit-tests. Like my previous attempt, I would prefer a focus on the unit-tests, however I am always happy to improve my code in any way reviewers can help.
Once again it is just a single class along with supporting unit-tests. The class is named UpgradeButton and represents upgrades that ... | stackexchange/codereview |
Exercise description:
"Write a program that takes a double word (4 bytes) as an argument, and then adds all the 4 bytes. It returns the sum as output.
Note that all the bytes are considered to be of unsigned value.
Example: For the number 03ff0103 the program will calculate 0x03 + 0xff + 0x01 + 0x3 = 0x106, and the out... | stackexchange/codereview |
I'm looking for feedback on this AVL tree implementation. Particularly on the overall structure, readability and abstraction. I've tried to keep all AVL specific operations inside the balancePath method to allow for easy conversion to a red/black tree with only minor changes to the rest of the code. Are there any furth... | stackexchange/codereview |
I decided to solve a problem from Code Golf called the four fours.
Problem description:
The Four fours puzzle is a popular recreational mathematical puzzle
that involves using exactly four 4s (and no other number) and a
defined set of operations to reach every number from 0 to a given
maximum.
In this version, the onl... | stackexchange/codereview |
I was given this project and have changed a lot of code on it, now I am going over the code to make sure that I know what everything does and can maintain it efficiently, and to make sure I want my name on it.
Here is the method they have been using to validate e-mail addresses from a textbox input.
private string Vali... | stackexchange/codereview |
I'm creating a website about an auto show that the user is going to. I'm collecting input from them via textboxes, check boxes, radio buttons, etc. I'm presenting them with a confirmation that the information they entered is correct. Is the way I'm doing this the most efficient, injecting the HTML into the website via ... | stackexchange/codereview |
I am writing a JavaScript application and would like to validate function arguments in many places. Most of these checks will be for correct argument types, or numeric values within specific ranges.
Here is a simple function I came up with to check any number of preconditions:
function requires(conditions)
{
for (... | stackexchange/codereview |
I have implemented some methods to make the creation of multithreaded programs easier for me in the future
The requirement was:
Be able to add as many Tasks as I need to the pool
Be able to restrict the amount of concurrently running threads
Be able to set the thread creation speed
Be able to cancel the thread creatio... | 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 |
This is our first attempt at building an unbalanced k-dimensional tree with nearest neighbor (1NN) lookup to process multi-dimensional data. In particular, the "suspect region" in the NN() function is where we are having the most questions:
Is a distance calculation (distCheck) necessary on every element in the subtre... | stackexchange/codereview |
This is my attempt at implementing debounce in Scala without any 3rd party library. How can I improve the code/make it more idiomatic (and any bugs I might have missed)?
import scala.compat.Platform.{currentTime => now}
import scala.concurrent.duration._
import scala.util.control.NonFatal
/**
* Return a fun... | stackexchange/codereview |
I created a template registry class. It supports custom factory functions and custom constructors. Any kind of feedback is welcome (style, performance, bugs)
registry.hpp:
#ifndef REGISTRY_HPP
#define REGISTRY_HPP
//STL
#include <unordered_map>
#include <memory>
template<typename Key>
class RegistryConstructionError ... | stackexchange/codereview |
The method below converts an array of TheatreListData objects to an array of TheatreListDataWrapper. It also loads additional attributes such as patientIdentifierNumber and requestText to enrich the converted data.
This method is called by many EJBs, and so I'm especially looking for ways to improve performance.
/**
*... | stackexchange/codereview |
I am creating a game that contains a Board and Pieces. The Board is basically a 2D array of Pieces. [Think smaller chess board]
One of the things that I want to accomplish is to be able to retrieve the left piece of a given.. (Also want to be able to retrieve the right, up, and down).
The easiest way to achieve this is... | stackexchange/codereview |
I'm implementing a password hashing method for a website. The code below is part of the User class.
Any pointers on what I could do better?
private string GenerateSalt(int SaltLength) {
using (var rng = new RNGCryptoServiceProvider()) {
var salt_bytes = new byte[SaltLength];
rng.GetNonZeroBytes(salt... | stackexchange/codereview |
“There are only two hard things in Computer Science: cache
invalidation and naming things.” -- Phil Karlton
That being said, I created this SimpleCache class which I intend to use to cache database queries and results over a relatively short period of time.
I'm just asking if there are any immediate faults or erro... | stackexchange/codereview |
I am currently learning C and playing around with the rand() and if/else statement. This code looks long, just curious if there is another way to make the code shorter?
The code below works fine, it's just randomize the output every time someone answers the question incorrectly.
while(input != c){
srand(time(NULL))... | stackexchange/codereview |
Given I have a linked list, and I want to move a given node to the end of the list, is there a more elegant way of doing this, than what I've done here?
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int val;
struct node *next;
} node_t;
void insert(node_t **head, int val)
{
node_t *new_node = mal... | stackexchange/codereview |
I am creating a few functions that wrap around jQuery's Ajax function to make it a bit quicker and easier to perform a request. For this I have this JavaScript file:
$( document ).ready( function ()
{
var ajax = {
url: "", type: "", success: "", beforeSend: "",
preform: function ( $url, $type, $succ... | stackexchange/codereview |
I'm new to Ruby, but not to programming. I just need a simple script that, given a text file, will pull out around 10% of the lines at random. Below is what I came up with based upon a Python script I wrote. What do I need to do differently to make it more Ruby-like?
prng = Random.new
File.open('english-words-parti... | stackexchange/codereview |
Like everyone, I use ListViews in a lot of apps. And I pretty much always end up making a custom Adapter. Yet 90% of my custom adapters end up doing the same thing (mapping directly from an ArrayList or array) with getView() overridden to update the views. I hate rewriting this part of the code. I also hate that th... | stackexchange/codereview |
I have a HashMap and I want to convert data in it to a Response object. Is it possible to achieve this code that parses the string in a better and optimized and cleaner way, maybe by using streams?
class Converter{
public static void main(String[] args) {
Map<String, Long> map = new HashMap<String, Long>();
... | stackexchange/codereview |
Here's the JSFiddle, the GitHub repo, and here it is out in the wild.
Note: the application uses Chrome's Speech Synthesis API and only works on Chrome or Safari for iOS7 (oddly enough).
It was my first voyage into jQuery-UI. I'd love some feedback on structure, coding style, and things that could break.
JS
var json... | stackexchange/codereview |
I'm getting these errors:
error C2512: 'course' : no appropriate default constructor available
error C2374: 'co' : redefinition; multiple initialization
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
class course
{
string coursename;
int courseid;
int passinggrade;
publ... | stackexchange/codereview |
For practice, I solved Leetcode 139. worbreak question:
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
I have the solution to use the recursive with in-memory hash table to redu... | stackexchange/codereview |
This is a simple implementation of an ng2 filter pipe, which can currently take 2 optional facets: <string>status and <string>description. A "filter pipe" is an angular2 view decorator.
The filter receives a list of objects (values) which I want to filter by some criteria specific to the type of data object passed to i... | stackexchange/codereview |
This code needs to get two inputs:
one is the full address of a directory
and another the file extension that it will be changed.
These inputs cab be added in the default section of parser.add_argument as in the example. It will overwrite the files with the new copyright:
import csv
import argparse
import os
clas... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.