instruction stringlengths 71 71.9k |
|---|
I have a serial device (RS232) from which I am requesting (binary) data.
This interface answers with a sequence of 5 bytes, or 17 bytes when it has some new data.
I figured out, that I have to turn the RTS pin of before sending, and turn it on to receive. But the problem is, that in 1 of around 30 cases I receive only ... |
Over the past couple of days I have been working on a super-basic text editor with Tkinter.
It can:
Open new files
Open files (general)
Save files
Obviously you can edit any file you open or make. This is very similar to this question, though I did not see that until I checked for duplicates of this question.
I did n... |
I have written this code for the question:
Finding k largest (or smallest) elements in an array
My approach uses a temporary array. Please suggest any improvements for readability or better performance.
public static void kLargest(int[] array, int k){
if(k < 0 || k > array.length){
return;
} ... |
I am trying to find the number of string pairs in an array that are palindromes.
import java.io.BufferedReader;
import java.io.InputStreamReader;
class TestClass {
public static void main(String args[] ) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line =... |
I'm developing a Go REST service that uses JWT (JSON Web Tokens) for authentication.
I've written a JWTHandler which validates the token using a Validation Handler. If validation succeeds, the request is passed on to a Token Handler. If the request fails, it is passed to an Error handler. All three of these handlers a... |
The following description is taken from CodeChef.com's Lapindrome problem.
Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check fo... |
Here is a snippet from my python script where I am performing:
a dictionary lookup
a cartesian multiplication of a list of len=500 against a list of len=60,
calculating a cumulative addition for each multiplcation combination
repeat this down a 20,000 rows
This is slowing things way down and making it hard to debug w... |
I set myself the task to calculate the average of a list, but with two conditions:
negative numbers are ignored
numbers greater than 100 are counted as if they were 100
So the "skewed" average of the list '(1 -3 42 297 14) should be (1 + 42 + 100 + 14) / 4 (157/4).
I wrote 2 functions that do that. Please review and ... |
Here is my solution for Project Euler Problem 42, which is described in the following:
The \$n^{th}\$ term of the sequence of triangle numbers is given by, \$t_n = ½n(n+1)\$; so the first ten triangle numbers are:
\$1, 3, 6, 10, 15, 21, 28, 36, 45, 55, \ldots\$
By converting each letter in a word to a number correspon... |
I want to perform mathematical operations on a range of values, where zeros should be ignored. This means that multiplication by zero does not result in zero but returns the first operand and likewise (\$5x0=5\$), division by zero does not throw an ArithmeticException but returns the first operand (\$5/0=5\$).
I would... |
I saw this interview question in the book Cracking the Coding Interview:
Implement an algorithm to determine if a string has all unique characters
The authors solution uses bit-shifting for a pretty efficient solution.
I wanted to give it a shot to discover some new things and practice some. I'd like for this to be... |
Is there a way to make my code simpler/more Pythonic?
Given three int values (a, b, c), return True if one of b or c is "close"
(differing from a by at most 1), while the other is "far", differing
from both other values by 2 or more. Note: abs(num) computes the
absolute value of a number.
close_far(1, 2, 10) → ... |
Could someone kindly have a look at the recursive merge sort below and let me know if there are any improvements? I'm mainly interested in either improving the code speed or making the code shorter.
def mergesort(alist):
if len(alist) > 1:
mid = len(alist)/2
left = alist[:mid]
right = alist[... |
I have some code to accomplish the objective of finding out which user has made the most progress. Progress is measured in integer values, the higher the better. SubmittedAnswers consist of among others a int UserId and a int Progress.
The answers variable consist of a list of SubmittedAnswers as described above. To fi... |
I am writing my own wrapper for PostgreSQL (but it can be used for other engines too).
I am using this desgin:
PSQLPreparedStatement st("SELECT ? FROM ? WHERE name = '? xx' AND surname = 'xx ? xx';");
st.SetValue(0, "*");
st.SetValue(1, "test_table");
st.Prepare();
st.SetValue(0, "name");
st.Prepare();
PostgreSQLWrap... |
I'm making a Mario clone in PyGame and I am writing a function that, after releasing the left and right button while Mario is moving horizontally, slows him down until he is at rest. As of right now, the code I am using is functional and works the way it should. Though, I am not sure if there is a way I can write the f... |
Given an unique string that represents a sequence of characters, the class should implement three methods (getNextChar, getNextString and the genSequence generator).
How it works
We give a sequence of characters. For example: "abc"
We give a starting string. For example: "a"
The generator yields the following strings ... |
I made this Renderer class recently, to simplify the user interface of my library's API. I would like to ask advice about the move semantics (copy constructor, std::unique_ptr, ...), or any other things you can point out to improve my code.
As you can see, I take in parameters in RenderObject in the form of a pointer. ... |
Since I posted my first version of the spelling corrector here, I've been working on improving it a little in my free time. I've also gone ahead and put the project up on Github so that others can now make contributions to the project if they wish to do so.
checkmate.c:
#include <stdio.h>
#include <stdlib.h>
#include ... |
Integer permutation using Heap's algorithm:
import java.util.Arrays;
public class IntegerPermutation {
private static void swap(Integer[] integerArray, int i, int j) {
Integer temp = integerArray[i];
integerArray[i] = integerArray[j];
integerArray[j] = temp;
}
private static void ... |
I wrote a little script that asks the user to choose a number between the 0 and 9. Wile he/she is entering a choice, the program tells him/her if the number is too high and too low.
Nothing fancy, just a couple of while and ifs. It's very ugly and has imperative code with mixed responsibilities. I was wondering if ther... |
I have coded binary search in shell, just for practice.
Input
Input data is already sorted set of numbers streamed to the script. $1 is the sought number.
for i in {1..1000000}; do
echo $RANDOM
done | sort -n | ./binsearch.ksh 10
Code
I use ksh as the fastest shell against bash, zsh and other bash clones, and as a... |
This is the code from my answer to a another CR question. My goal was to provide a fast and simple computation and I'm rather unsatisfied with it. It's maybe 10 times faster than the original, but this may be still too slow for bigger displays and/or weaker devices.
I'm mostly interested in performance improvements, i... |
How is this? Any ways to improve?
public void DownloadPDF(Uri uri) {
downloadProgress.setVisibility(View.VISIBLE);
downloadComplete.setVisibility(View.INVISIBLE);
openFile.setText("Wait..."); // My button
openFile.setEnabled(false);
if (uri != null) {
DownloadManager.Request request = new Do... |
I've refactored my previous inventory system, and added a few features like removing items from the Inventory class, easily obtaining the current selected item through Inventory.GetSelectedItem, and some things have been renamed as well. My concerns are once again:
Is this the correct usage of F#'s type/class system? ... |
Using the following HTML:
<input type="date" value="2015-07-26" name="startdate">
<input type="date" value="2015-07-29" name="enddate">
First, the JS calculates the number of days between two dates:
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var start = document.querySelector('[name="startdate"]... |
Given a set of ranges with lower bound and upper bound, I need to combine these ranges to produce minimum number of ranges which will cover all the values in the original set and nothing else.
Example 1:
Input:
[100, 200], [120-170],[210 - 230]
Output:
[100-200], [210-230]
Example 2:
Input:
[100, 200], [120-210],[21... |
This is basically a logger which I use/wrote. It has convenient features like including one-line stack traces with print statements, making the text easier to find, and piping all output to either standard out or standard error to make it so that no print statements will be out of order.
This is part of my LogAppTester... |
I bring this code review plea over from suggestions from SO. I've made the suggested edits from that thread, except I kept one sys.exit() call because I was having trouble exiting otherwise. Overall, the code works as desired, and I'm looking for advice on how I can make it even cleaner.
import time
import sys
done = ... |
I'm completely aware that I'm not using NIO, but this is my first polished C project. All criticism is welcome, if I'm doing something wrong, I want to nip it in the bud before I'm used to it.
/*
* TCPTunnel.c
*
* Created on: Jul 25, 2015
* Author: javaprophet
*/
#include <stdio.h>
#include <stdlib.h>
#inclu... |
There have been a lot of calculators lately. It seems like this community challenge all over again, I didn't make a proper one then, so I'm joining the calculatrain now.
Building from the lessons learned from a preceding far simpler calculator.
The goal was to encompass corner cases that are otherwise easy to miss. I'... |
I have this (simple) data structure that maintains multiple LIFO stacks. Each such stack is assigned a priority. The less is the value of a priority key, the higher the priority. Pushing operation requires the element to push and its priority key. Whenever popping the queue, it removes the most recently added element o... |
Knowing my solution ...
Return True if the given string contains an appearance of "xyz" where
the xyz is not directly preceeded by a period (.). So "xxyz" counts
but "x.xyz" does not.
xyz_there('abcxyz') → True
xyz_there('abc.xyz') → False
xyz_there('xyz.abc') → True
def xyz_there(str):
return str.count("... |
I am trying to recognize a sentence that I have read through optical character recognition software. This code will eventually run on a Raspberry Pi.
I know for certain that it's meant to be one of a few thousand sentences which I have written down in a file (sentencelist.txt), but the character recognition has messed ... |
Is there a way to make my code more concise?
Given 3 int values, a b c, return their sum. However, if one of the
values is 13 then it does not count towards the sum and values to its
right do not count. So for example, if b is 13, then both b and c do
not count.
lucky_sum(1, 2, 3) → 6
lucky_sum(1, 2, 13) → 3
... |
Here is the source of the question.
Revision 1.
Revision 2.
When I started the second round of code review, I wanted to make sure that I had included all the possible input types. However, I received many useful suggestions from @200_success.
I took some time to learn them, and now I want to post my code again.
In thi... |
I'm trying to solve this question on a contest programming judge.
Description of the problem:
There are N birds in a forest, each in their respective tree. There are N tired crows in this forest, and they wish to land in different trees as soon as possible (crows are extremely quarrelsome and they can't share the same... |
I'm reading Head First Design Patterns and I'm currently reading about the observer pattern. Is what I produced correct?
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
class ObserverInterface
{
public:
virtual void update(std::string message) = 0;
};
class concreteObserver : Observe... |
I was in need to sort Colors, so the first thing that I tried was this:
Arrays.sort(new javafx.scene.paint.Color[] {Color.ALICEBLUE},Color.AZURE,Color.BLUEVIOLET,Color.AQUA,...);
But unfortunately Arrays.Sort is not compatible with javafx.scene.paint.Color, so I ended up with this:
public static void main(String[] arg... |
This uses HTML5 data attributes to load the image according to the screen width. For example, for laptops. it loads only laptop-sized images. saving bandwidth and optimizing speed.
Live example
//---------------------------Setting ViewPort Widths-----------------------//
var sSize=768; // High End Mobile Phones
var... |
The purpose of this code is to allow to add functions to a queue, that will execute them sequentially.
With this in mind, it also allows to execute them with a defined delay, to prevent them from blocking the browser.
(function(window, undefined){
'use strict';
var queue = [];
var running = false;
var s... |
I've been learning Java for a month now using programmingbydoing.com in addition with reading the Java reference. I've had very very basic programming experience and I'm trying to improve my skills. These assignments are my first large projects that I've attempted.
I attempted an address book twice. The first time I ... |
I made a script in JavaScript to calculate how long it takes until a certain date.
Do you find it user-friendly enough? Is the code correct?
var object = "object"
function formatDate(date) { // get the date in proper format
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
yea... |
I have been thinking of a sql-injection free implementation in dynamic languages. Here's what I came with. All the code was written just for fun and learning purposes.
I would like to share it and get some feedback about it.
Mainly about performance, efficiency and usability.
All the information you need is directly wr... |
I am looking to optimize the performance of a big data parsing problem I have using Python. The example data I show are segments of whole genome DNA sequence alignments for six primate species.
Each file contains multiple segments with the following format:
<MULTI-LINE HEADER> # number of header lines mirrors number o... |
The rubberduck project has reached a turning point. The core features are implemented (except the SmartIndenter embedding - we're keeping that for 2.0), the next few releases will probably just build on the architecture in place.
One of the biggest architectural issues, is tight coupling, with dependencies being new'd ... |
Is there a better way to calculate the download speed than what I'm currently doing now? Are there any suggestions on improving the updated code?
Pure version:
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Threading;
namespace Downloader
{
public interface ILogger
{
... |
I start coding a simple application: I transform markdown files in folders into documentation.
My architecture is very flat. My code looks like a series of unit function called one after the other.
def main():
config = get_user_config(os.getcwd())
sources_dir = config['sources_dir']
for root, dirnames, file... |
I'm not sure if this code is industry-standard or not. Please review it and let me know if any improvement is required.
class Node(object):
def __init__(self,data,next):
self.data=data
self.next=next
class getLinkRest():
head = None
tail= None
def insert(self,data):
node=N... |
I'm getting my feet wet in embedded development, and like all those before me, my first task was to make an LED blink. I went a bit further than that and made a "runner" that lights up each led from 0 to 7 in sequence. The sequence begins as soon as the board is powered on. You can see it in action here.
I'm using an A... |
Can I make this:
if (oneFour == 1 || oneFour == 2 || oneFour == 3 || oneFour == 4)
shorter, especially if I'm gonna need a wider range of integers?
Do I need to use a string _warning twice like I did?
static string _warning = "Please, enter a number from 1 to 4!";
static int oneToFour()
{
int oneFour = 0;
... |
In response to another recent question I mentioned that one mechanism to avoid runtime overhead for creating a data structure was to create it at compile time and use it directly. Since there was some interest in that concept, I thought I would write code to show how that might be done and submit it for review here.
T... |
I want my generator function to raise as soon as it can. If I make it yield the elements directly, then the KeyError won't happen until iteration begins. Is the following code the best I can do?
def cluster_terminals(self, key):
"""
Deals with forwarding.
"""
return_list = self.cluster_map[key]
de... |
I'm developing a system in which users can upload their .doc file and the system will check whether the file contains certain words, and the system will tell the users whether their doc file falls under 'Sustainability' category.
The system will find any word in doc file and match it with the keyword that have been pre... |
This is a challenge from codeeval
Write a program which determines the Mth to the last element in a
list.
Input sample:
The first argument is a path to a file. The file contains the series
of space delimited characters followed by an integer. The integer
represents an index in the list (1-based), one per line.
For exa... |
This is a question about best practices. I have a project I am building and I have the following base Exception class:
Namespace Project;
class Exception extends \Exception{
//=============== BASE EXCEPTIONS 0 - 1000 ===============//
/**
* placeholder for unknown exeptions - the default type
* @var... |
This currently works properly, but just takes too long. Some of the functions in it are necessary and need to remain, such as resizing, and double saves. But it probably has room for improvement. I just need it to post image as it does, but faster.
<?php
ini_set('memory_limit', '-1');
$target_dir = "";
$target_fil... |
I am given a string containing the possible characters of : 0, 1, and ?, iterating over possibilities, replacing the wildcard ? with either 0 or 1.
For example; given "1?00?101", the outcome would be: ["10000101", "10001101", "11000101", "11001101"].
My code seems to work, I tested with two wildcards and three wildcar... |
Overview:
Here's the look of my form.
In this example, I have a form that allows dynamically adding fields in each category. Like, I can add multiple attractions like 5 attractions, same goes for Featured artists, so basically I can add an infinite set of data per category in this form.
So after submitting, all those ... |
I am no expert in C#, the opposite really, I just wanted an overall review on my UserInfo class that gets user information from a database using MySQL. I was also wondering if it is a good idea to really process the data in the way I did, getting everything from the database, even the things that aren't needed. But I t... |
I am posting here to get a code review on my DatabaseManager and DatabaseConnection classes, and for answers on how I can improve. I won't spend too long drolling on, but this is a database manager that uses MySQL and creates a new DatabaseConnection for each operation.
Database Manager -
using System;
using System.Col... |
I've implemented the algorithm below for the maximum contiguous subarray problem and would like a review on three specific things:
Making the code shorter
Making the code faster
Any other algorithms that can do the job with lower complexity
def crossingsubarray(A, low, mid, high):
negetiveinfinity = -1000000000... |
I sometimes save nice fortune outputs to my Evernote. The data looks like this:
/ Abou Ben Adhem (may his tribe increase!) \
| Awoke one night from a deep dream of peace, |
| And saw, within the moonlight in his room, |
| Making it rich, and like a lily in bloom, ... |
I want to make a general alert dialog to use across the whole app. I created a class called AlertDialogManager and just one method to show AlertDialog.
Is there a way to refine my code or this code?
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
public class Ale... |
Today's question will just be about a small utility that I needed at some point for one of my projects: a template to detect whether a template is specialized for a given type. The utility uses std::void_t from C++17, but this alias template is simle enough to be implemented in you favourite C++ revision, whichever it ... |
I have written a BASH script to parse and compile HTML code into a single page. The script works as expected, although my code is not completely re-usable and the standard output messages could be more helpful.
Besides my intended improvements, are there any other problems with my code?
#!/bin/bash
#Append each section... |
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1->1->2->3, return 2->3.
**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *... |
Is this a good method to render sprites (textured quads) or is there a faster or better way?
Example use:
renderer.beginTextureRendering();
for(Enemy enemy : enemies)
{
renderer.renderTexture(enemy.getX(), enemy.getY(), 0.5f, 0.5f, 0, 0, 1, 1, 1, 1, 1, 1);
}
renderer.endTextureRendering(cameraTransform, gameTexture... |
Basically I solved this question on one of the competitive websites:
Given the total n number of String on first input, n input follows:
We have to find such pairs of string (i,j) such that that the inverse
of j equals i.
I implemented the code below, but for larger inputs, it exceeds 1 sec. What more can I do to m... |
Calculator class:
class Calculator
{
/**
* @return array
*/
function doPowTable ($n)
{
$table = array();
for ($i = 1; $i <= $n; $i++)
{
$table[] = array(
'i' => $i,
'factor' => pow($i, 2)
);
}
return $t... |
I am specifically looking for input on naming ModifierCalculator and Modifiers. I would also appreciate input on whether ModifierCalculator should extend EnumMap instead of having it as a field.
These classes are for modifying the status of units. The StatType enum contains different types of ..stats, such as "life", "... |
I am currently writing a decent amount of ajax to help me delete a section of a website.
It's already becoming a pretty big piece of code, I wondered if it were possible to compact a section of my code.
$('.trg-finished').on('click', function() {
if(confirm('Are you sure?')) {
var that = $(this);
v... |
First I create a .tar of the root directory with all the file permissions saved and excluding all irrelevant directories (are these the right folders to be excluding?).
sudo tar -cvpzf /HDD/systemBackup/backup.tar.gz --one-file-system --exclude=/HDD --exclude=/NAS --exclude=/proc exclude=/tmp --exclude=/mnt --exclude=/... |
I am trying to fill values based on group, in my case id. I would like to fill the missing values according to the available date info for each id.
id date
1 1 23-04
2 1 23-04
3 1 <NA>
4 1 <NA>
5 2 24-04
6 2 <NA>
7 2 <NA>
8 2 <NA>
9 3 23-04
10 3 <NA>
11 3 <NA>
12 3 <NA>
13 4 <NA>
14 ... |
I've created a small project that contains a league table from Premier League updated constantly using local node.js server. Data is fetched from local server.
I'm wondering whether my solution is optimal, especially table ordering.
'use strict';
var React = require('../node_modules/react/addons'),
GamesService = ... |
For fun I decided to make an algorithm in Python that would create a 2D list of a specified size that it can populate with a list of words and fill the gaps with random characters. It's basically a wordsearch.
You supply it with the words, optionally a size and then a count of how many times to retry when invalid board... |
I have two objects, a bet and a match. A match has 2 teams and both teams get a score at the end of the match. A bet has two scores set up before the match begins. Here I need to know if the bet specified the same winner as it's set on the match (once it's done).
// isGoodWinner
//
// @description :: return true if has... |
My first learning project in C. Looking for general feedback e.g. gotchas, coding standards, formatting, naming etc. I'm here to learn!
webserver.h
#ifndef __Webserver__webserver__
#define __Webserver__webserver__
#include <stdio.h>
struct webserver_connection {
int status;
int socket;
char *path;
};
st... |
This function conditionally copies and pastes information from one sheet to another based on the column headings to standardize data before exported to SQL database.
I am not an expert in VBA and started learning but when I run this code, it takes way too long to process huge data (ex: Excel sheet with 70k rows would t... |
A Plane of existence is like a universe in the multiverse. At first, I thought that a Plane will consist of many Worlds, and each World consists of many Locations. But it is not so simple.
Here are some instances of Planes:
MaterialPlane: It has different Worlds, as I originally understood Planes to be.
Arcadia: An ... |
Given a string sequence and a string, the function should output the next string of that sequence.
For example, for sequence "abc":
a
b
c
aa
ab
ac
ba
..
cc
aaa
aab
How can I improve my code while maintaining a balance between performance and readability?
data Sequence = Sequence {
getSequence :: String,
getF... |
Here is a simple decompression implementation. I'd very much appreciate any advice or comments about the structure/logic of the program, style of the code, or reusability of the features. I'm a real novice and really eager to learn from people here, so fire away!
:
/**
* lzw.h
* Function declarations for lempel ziv... |
I'm making a Mario clone in pygame and I have just wrote a function proccesses inputs and acts as a state machine for Mario. Everything is working just as I want it, but I was wondering if you can think of any more efficient way to write this code.
A note that these methods are all a part of a class called mario.
def _... |
I'm about learning about implementing the solid principle in PHP.
I want to create simple content crawler/grabber from some websites. This crawler will grab the content from the website url. Since we know that every website has different html tag structure, so I created an interface.
<?php
interface BotInterface
{
... |
I've got a list of geographic coordinates ([lat, long]) and want to compute the corresponding matrix of distances. Distance shall be spherical distance in km.
def distance_on_unit_sphere(coord1, coord2):
lat1 = coord1[0]
long1 = coord1[1]
lat2 = coord2[0]
long2 = coord2[1]
# Convert latitude and lon... |
I've worked out a functioning Vigenère encryption in Scala, and while it doesn't seem like my code is too hideous, I'm sure I could make it more functional and Scala-esque. Primarily, it seems like:
I've made the full key with a for-expression / zipWithIndex, I'm wondering if this is the best way to do this though. Wo... |
This is my code for lazily reading a very large file which contains numbers separated by a new line character. Is there a way to simplify this using the ByteString module or would I have to use Data.Text
import Data.ByteString.Lazy.Char8 as L
main = do
contents <- L.getContents
print (sumFile contents)
where s... |
I would apreciate any suggestions on how to make my code better and more efficient.
#include <stdio.h>
#include <time.h>
#include <windows.h>
struct SnakeNode
{
int x;
int y;
struct SnakeNode *next;
};
struct Food
{
int x;
int y;
int isEaten;
};
void Gotoxy(int column,int row);
int CreateScor... |
I have a piece of parsec code that parses a unit optionally followed by ?, + or *. Depending on which type I build my Regex (this is a part of a regex parser) as follows:
factor = unit >>= (\x -> (try (char '?' >> return (Or Epsilon x))
<|> try (char '+' >> return (Then x (Star x)))
... |
I hate to have to write a custom exists promise every time I need to know if a file exists, so I came up with this. Thoughts?
var Promise = require("bluebird")
var fs = Promise.promisifyAll(require("fs"))
function fsExists(_path){
return fs.lstatAsync(_path)
.then(function(){ return true })
.catch(function(){ re... |
I have been a developer for many years and get core development concepts, as well as unit testing ones such as DI/Ioc, Mocking etc. I also understand the values, importance of unit testing and writing good tests, as well as asking myself often: "What Would Roy Do?".
I am however slightly unsure on some approaches and p... |
A train operator has decided to hire an observer to track the
different types of trains transiting at a major train platform in
Europe. Write a program, using a for loop, to track the different
train types at the major train station.
The different types of trains are shown in the following table:
Train types | ... |
I'm writing a little math module in C to handle vectors and matrices. This will be column-major style but right now I've only finished the basics of the vector functions and wanted some feedback on optimization tips, naming conventions, etc. This is C so no real function overloading. I would like to keep it C style.
ve... |
I'm sorting my object by its property ActivityOrder, which will sometimes contain null values if the user has not explicitly stated an order which an activity should appear.
Since null will always appear top most in the sort (unless reversed), it messed up my sort.
The solution I came up with was to sort by the id if... |
I wasn't quite sure where to go with this, and this seemed to be the best place I could think of so I thought why not. I threw together a build system for C++ projects today using CMake and I wanted your opinions on it, on things I could do better, or change to better comply with best practices.
Here's my directory str... |
I have the following code and I think it's almost impossible to read and to maintain. I prefer self-explaining and modular code where variable and function names tell what I'm trying to do, but I don't know how to change the part using Eval and inside an ascx.
I'm doing much research but I still cannot understand it co... |
Question
Write a program which removes specific characters from a string.
The first argument is a path to a file. The file contains the source
strings and the characters that need to be scrubbed. Each source
string and characters you need to scrub are delimited by comma.
Input sample:
how are you, abc
hello wo... |
Interface for logger:
public interface ILogger
{
void Log(Exception ex, string contextualMessage = "");
void Log(string message);
}
Interface for web job logger:
public interface IJobLogger : ILogger
{
void SetWriter(TextWriter logWriter);
}
Web job logger:
public cl... |
Following is my attempt for a simple implementation for the std string class. Please review my changes and share your feedback.
string.h
class string
{
char *pcString;
int iCapacity;
const static int npos = -1;
public:
string(void);
string(int);
string(const char*);
string(const string&);
... |
Here is an update to my previous thread which you can find here. Again, I'd very much appreciate any advice or comments about the structure/logic of the program, style of the code, or reusability of the features.
The fread_twelve function has been heavily modified to deal with detecting and reading the last entry, whic... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.