instruction stringlengths 71 95.1k |
|---|
I don't know if this is exactly refactoring but I recently completed a programming challenge to learn more about Ruby's iterators. However, I feel that the code is extremely "un-Ruby like". Would anyone have any suggestions as to how I could improve it?
numbers = []
binary = []
binary_count = 0
File.open('decimals.txt... |
Here are two methods of code that only vary in one place. Specifically, the first method calls GetReleaseYear(), and the second calls GetReleaseDate().
This is one example of a one-line difference in multiple methods, and each time the difference might be on a different line or couple of lines. One possible design I've... |
I found myself struggling when it came to refactor the following (working) code. Since can't be found a lot of documentation about Rails 'accepts_nested_attributes_for' applied to a many-to-many relationship (furthermore, with ancillary data), I figured out it would be interesting to challenge this brave community abou... |
I saw this article that proposes a refactoring exercise and thought I'd give it a try.
Spoiler alert: I'm going to show my solution to the Kata below. You might want to attempt the Kata yourself before you look at this code, so this will not influence you in any way.
I ended up with the following three classes:
Person.... |
I had originally posted this question without posting the full algorithm. Here is the whole thing.
I have an HTML page like this:
<table id="inputTable">
<tr>
<td>Label1</td>
<td><input type="text" value="" id="inputA1"></td>
<td><span id="inputA1ErrMsg"/></span></td>
<td><input type="t... |
I'm very new to backbone.js and JavaScript. I would like to hear some reasonable critiques / advice against my JavaScript code based on backbone.js framework with backbone-forms.
The aim of this simple app is to present a user with a simple registration form (twitter bootstrap modal dialog) and upon clicking on regist... |
I need a simple singly-linked list to help implement some memory management functionality. I just finished writing it up and would really like a code review since I haven't written this particular data structure in a long time.
struct pid_node {
int PID;
struct pid_node* next;
};
struct pid_node* pid_node_crea... |
I'm trying to use inheritance and polymorphism to make it easy for the program to be enhance to many more rules. ClassificationRule is the base class and RuleFirstOccrnc and RuleOccrncCount and derived classes and by using the same non-static apply() method ClassificationRule should invoke all other non-static apply() ... |
What can I do with this program to improve its performance?
#!/usr/bin/env ruby
require 'open-uri'
print "URL: "
add = gets
puts "Info from #{add}"
begin
open(add) do |f|
puts "Fetching images..."
puts "Fetching links..."
puts "Fetching div tags..."
puts "Fetching headers..."
puts "Fetching forms.... |
After a whole night of work I finally have my first useful class - for reading database.
It works like a charm, but if you got a moment, please take a glance and give me feedback. Harsh criticism welcome.
Please note that security is not addressed yet, as well as usual SQL clauses, but I'd like to know am I on the righ... |
I used this code in several projects. But I am not sure if it is stable. However on production it is working well, but I want to listen your advices:
/// <summary>
/// Standard abstract parent for Timer-powered classes. Has Start|Stop|Pulse events
/// </summary>
public abstract class TimerContainer : IDisposable
{
... |
Python Cryptography Example
Last weekend I wrote some code to help people use PyCrypto in a canonical fashion to symmetrically encrypt and decrypt strings and files. By canonical I mean I've followed Colin Percival's advice in Cryptographic Right Answers.
The code isn't very verbose, and I'd appreciate any comments or ... |
I am having some performance problems with a little R script of mine that I use to visualize simulation results of a project of mine. It now takes longer on my machine to run the R script than the simulation itself, and I guess I am doing something wrong.
library(ggplot2)
DownloadTime <- function(data, prefix) {
... |
I have this simple object setup in JavaScript - Full code on jsbin
I'll break it up below, but the question(s) -
Does it break? I mean, I'm sure we can find a interesting case where this would be broken, but how much work do we have to do before it breaks?
I started out thinking I needed to explicitly store a list of ... |
I've added a function that checks if the user is trying to use/access something which requires a session. I'd love to hear some criticisms of my choice of design.
class MY_Controller extends CI_Controller {
function __construct() {
parent::__construct();
if(!$this->input->is_ajax_request()) {
... |
I'm a not-really-recent-anymore graduate of Michigan Tech. I've been a cook since graduation and I'm an eensie teensie bit rusty in pretty much all my learnin'. Couple weeks ago I got hired on to help create an online learning system. Essentially, it's going to be an online school. I need to be able to have departments... |
Pvik is a lighweight PHP framework that uses the model, view, controller principle.
-- EXAMPLE --
Here is a very simple example how you build a website with the framework. I'm asking you if this is easy to understand or just for me because I know the framework and of course if there are things that I can build better. ... |
The problem description is:
You are given n types of coin denominations of values v(1) < v(2) <
... < v(n) (all integers). Assume v(1) = 1, so you can always make
change for any amount of money C. Give an algorithm which makes change
for an amount of money C with as few coins as possible. [on problem
set 4]
... |
Is this going to leak memory or is it ok? Please also let me know if there is something else that I need to pay attention to.
typedef struct
{
int len;
UC * message;
}pack;
pack * prepare_packet_to_send(const int length,const unsigned char tag,const int numargs, ... )
{
pack *layer= malloc(sizeof(pack));
va_list l... |
This is a script that emulates a recycle bin in the CLI.
You can undo your last changes and delete files
This is my first bash script so don't hesitate to bash me. Thank you for taking a look.
#! /bin/bash
usage(){
cat << EOF
Sends and restores files to and from the recycle bin
Usage: rm [options] file1 [file2] ...
... |
I have a Java class which accepts some data and reads it in as a raster of characters x by y. The class is used then to look for occurrences of a certain word in any direction of the raster and store them in a multidimensional array.
My code works, but I would like to see the code optimized because to me it looks too c... |
Task:
On an alphabet set [a-z], a simplified regular expression is much
simpler than the normal regular expression.
It has only two meta characters: '.' and '*'.
'.' -- exact one arbitrary character match.
'*' -- zero or more arbitrary character match.
Note that it is different from the normal regular expression in... |
Please review this implementation of thread-safe chache.
public class StaticCacheImpl<T extends Entity> implements StaticCache<T>
{
private boolean set = false;
private List<T> cachedObjects = Collections.synchronizedList(new ArrayList<T>());
@Override
public synchronized boolean isSet() {
... |
In order for me to get better and create more desired code, I would like to find out if the following situation is bad or acceptable.
I am creating an animation that gets triggered by two buttons, one on the left of a JPanel and the other on the right. Depending on which button is pressed, the animation starts from th... |
This is a short class to take screenshots on mutltiple monitor systems, I made some modifications to the solution at https://stackoverflow.com/questions/10042086/screen-capture-in-java-not-capturing-whole-screen so that the code coped with monitors at different hights and so on. Any and all suggestions welcome :)
/**
... |
You can see each list item has multiple attributes data-whatever. The user will choose from a dropdown box on how things should be sorted and the appropriate method is called. Is eval() the most appropriate choice for this or is there a better way?
$('#sort-options').change(function() {
var sortType = $(this).va... |
I am trying to go through the problems on CodeChef and came across this problem:
In Byteland they have a very strange monetary system. Each Bytelandian
gold coin has an integer number written on it. A coin n can be
exchanged in a bank into three coins: n/2, n/3 and n/4. But these
numbers are all rounded down (th... |
I'm trying to develop an algorithm that generates a 16-digit validation number to interact with a given system.
This is how the algorithm should be implemented:
I have implemented it, and have it working with 2 of 3 test cases that I have found (I will post them below).
The implementations goes as:
public static Strin... |
I'm trying to implement a function that given a data frame returns the same data frame with four columns added. These new four columns are: for each row, I get the maximum element and its index and put them as two new columns. I do the same with the second maximum element. I don't care if they are repeated.
add_2max <... |
Question:
You are given an array that represents bills in certain currency
(for example 1, 2, 5, 10) and an amount, for example 17. You should output
the number of possible combinations of bills that sum to the given amount.
Answer:
{2, 5, 10}
Can I optimize/improve below code? Current complexity is: O(2(n-1... |
I'm new to production code. And also I'm learning how to test code, I'll use the unittest module that comes with python to do that.
One more question, how can I make this code more safe?
"""
Sync your iTunes files with your Android
"""
import os, string, re, shutil
from ctypes import windll
def get_drives(... |
After recently reading up on and watching videos on OO PHP programming I have decided to convert my existing site into OO to gain some experience.
I have successfully (well, I think) converted a page into OOP and would like to know whether this is considered the proper way to implement OOP and whether this should be th... |
Is this best practice way to send messages to the user?
Update: This has been changed to a simple function call.
/**
*Message - Sends message to the .innerHTML of an element
*/
var Message = ( function ()
{
var messages =
{
name: 'Please enter a valid name',
email: 'Please e... |
I'm just getting my feet on the ground with Python (maybe 3 days now). The only issue with teaching my self is that I have no one to critique my work.
Correct me if I'm wrong but I think my algorithm/method for solving this problem is quite promising; but, the code not so much.
The program basically strips a web-page a... |
How could I make this path-finding code dynamic? This is to allow an agent to search the path on its own (from one corner of the grid to another) while hiding it until moved to the grid.
I am new to C++ and tried to write this program, but it appears to be static. I need to make it dynamic, or I could just have the a... |
library.php
My own HTML tag encoder that will print HTML codes according to the input.
<?php
function tag($tagname, $content = NULL, array $properties = NULL)
{
$html = "<$tagname";
if (!($properties === NULL))
foreach ($properties as $name => $value) {
$html .= " $name=\"$v... |
I've written a package manager for OS X in order to improve my Python skills. This is the second programming project I've ever worked on, so I do not expect it to be great, or anything, but I would like to get some input on the code and overall design.
I store the package info inside a SQLite database, which I've writt... |
I have written the following get/set for a username which is stored in local Storage. Do you think this "buys" me anything or even perhaps has major disadvantages? I have never liked relying on global variables so I figured the getter and setter would be tidier and more maintainable.
var namespace = {};
namespace.... |
The question asked to find all the prime numbers within a particular range. The way I approached this was to loop through each of the numbers within the range and for each number check whether it's a prime. My method for checking prime is to start at 3 and loop till number/2 in hops of 2 (essentially excluding all the ... |
For various reasons, I'm parsing a string, this code will explain what I'm after:
string baseString = "This is a \"Very Long Test\"";
string[] strings = baseString.Split(' ');
List<String> stringList = new List<string>();
string temp = String.Empty;
foreach (var s in strings)
{
if (!String.IsNullOrWhiteSpace(temp... |
Can anyone suggest any improvements to this RangeFinder class?
import serial
from collections import deque
def str2int(x):
try:
return int(x)
except ValueError:
pass
class RangeFinder(object):
def __init__(self, mem=3) :
self.mem = deque(maxlen=mem)
self.absmax = -10**10... |
I need help refactoring the javascript. http://jsfiddle.net/BDLYP/
I was able to hide and show fields, but I know this can be improved upon.
If #state is empty, hide #high-schools and #other_high_schools
If #state is picked, show #high-schools and show #other_high_schools (if #high-schools is empty)
I imagine the multi... |
I've decided to write a Chess engine in Ruby. The first step (before any move generation, AI, search trees, etc.) is to get a solid board representation so the computer and I can effectively communicate the game state to one another. The board representation I am using here is of the 64-bitstring variety. (I implemen... |
I have this search script on my page which search through the displayed table. The table is displayed with PHP from a database. It is actually a list, and this list is sorted out alphabetically with the help of hyperlinks of A to Z. Now I need to search the whole database instead of displayed ones. Any helps or resourc... |
I have a model that I've created in Codeigniter to represent a vote. The purpose of the site that it's a part of is to allow users to vote on their preferred pronunciation for a given word.
The routine first checks to see if a user has registered a vote for the given pronunciation and if so, whether it was up or down. ... |
I am trying to learn Prolog, and wrote a bibtex reader using GNU Prolog.
I would like some feedback on my code in terms of: the way I write Prolog, and how it can be improved.
Gist
% CLI for interacting with a bibtex db.
% Enter your bibtex file to .bib.db
% i.e cat wang.bib > .db.bib
% ------------------------------... |
Take 4 (alteration based on feedback from Rainer Joswig):
(defmacro with-gensyms ((&rest names) &body body)
`(let ,(loop for n in names collect `(,n (gensym)))
,@body))
(defmacro let-alist ((&rest lookups) alist &body body)
(with-gensyms (alist-form)
`(let ((,alist-form ,alist))
(let ,(loop for l ... |
I'm VERY new to error/exception handling, previously just echoing everything to screen, and am trying to really clean up my code. My goal was to log everything but only show the user a friendly "oops" page if something was seriously broken. How does what I have below look?
Any best practice advice is appreciated.
<?p... |
I'm looking for a better implementation of the algorithm.
/*
* You have an ordered array X of n integers. Find the array M containing
* elements where Mi is the product of all integers in X except for Xi.
* You may not use division. You can use extra memory.
*/
#include <iostream>
#include <stack>
#include <queue>... |
Two words are anagrams of each other if they contain the same letters, such as "pots == stop".
The easiest way to check is to sort both words, then compare. But that's an \$O(n*log(n))\$ solution and I'd like to find an \$O(n)\$ one.
Is this code \$O(n)\$? I only make one pass per string, but I use a hash Remove which... |
I've written a small markov chain monte carlo function that takes samples from a posterior distribution, based on a prior and a binomial (Bin(N, Z)) distribution.
I'd be happy to have it reviewed, especially perhaps, regarding how to properly pass functions as arguments to functions (as the function prior_dist() in my ... |
I recently graduated from college and applied for a position with a company. I was sent a coding exercise as part of the process. After completing the exercise and submitting it I was told that the code provided the correct solution but was too hard to follow, the logic should be in the Course class, and "..due to refa... |
I have the following code that our users will use to embed a widget on their page:
var ttp_number = "1Z123489754897";
var ttp_key = "1234567890123457890123";
var ttp_width = 850;
var ttp_height = 650;
var ttp_m_width = 260;
var ttp_m_height = 200;
(function(){
document.write('<div id="ttp"></div>');
s=document... |
I have been doing some personal projects for fun and most of them have visual representation of boards (ej: sudoku solvers, chess PGN viewer, etc) and I always end up doing something like this:
var wid=10;
var hei=6;
var len=(wid*hei);
var map="005000200000000008000600000006000700000040000000500030400000".split("");
v... |
I have the following PHP function, which is admittedly not quite as robust as it could be (I'm missing some sanity checks including a proper one for $sendTo for example; odd choices in text formatting, too) but I don't see why it shouldn't work. A version of it certainly worked the other day, though I made a few small ... |
I was writing a program that used a bit of recursion with objects, and it wasn't working at all. After debugging I realized that JS's evil scope was playing nasty tricks.
To spare you guys a wall of text code, I wrote a smaller program:
//Class definition and framework:
TestClass=function(label,level){
this.label=l... |
<?
$debug = (isset($_GET['debug']) && !empty($_GET['debug']))? $_GET['debug'] : false;
define('TYPE_A', 'A');
define('TYPE_O', 'O');
define('DEBUG_STAT', $debug);
//get params from $_GET or setup default value
$payment_type = ((isset($_GET['payment']) && !empty($_GET['payment'])))? $_GET['payment'] : 'fghu... |
I am very new to Objective-C as well as objected oriented programming, and in a book I am studying from there is an exercise in which I was supposed to create a class called Rational, that has hidden data members called numerator and denominator, and methods to add, multiply, subtract and divide the Rational objects (t... |
Can someone please critique my C++ sample here?
#include <iostream> //console io
#include <string> //string handling
#include <algorithm> //transform
using namespace std;
struct to_upper {
int operator() (int ch)
{
return toupper(ch);
}
};
void encrypt_vigenere(const string& plaintext, const string&... |
This shows the minimum of letters needed for a palindrome. It needs tweaking since it works fine for words 1-9 characters, but becomes slow for words with 10-12 characters, and for 13+ characters it really takes a lot of time. Any help is appreciated.
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include ... |
When releasing objects that might have been retained during the app's lifetime, how do you check if the object really exists and prevent releasing a nil object?
Here's how I'm doing it:
- (void)dealloc{
if(account_)
[account_ release];
account_ = nil;
[super dealloc];
}
|
I have lots of classes that inherit from abstract base class, which has abstract method
public class BaseClass<T>
{
protected abstract void GetItems();
}
each subclass have almost the same implementation
protected override void GetItems()
{
// some preparation code here which is the same for all sublcasses
... |
This code implements a data structure for representing a Sudoku board, a very simple algorithm for setting up the board, and a GUI written in tkinter(requires tkinter and tkinter.tix).
#!/usr/bin/python
# Sudoku board code, and Sudoku board generation code.
# TODO:
# - Sudoku Solver
# - GUI Load/Save game (DONE)
# - GU... |
This is my first useful bash script. It's meant to make it easy to switch between a "work" hosts file (that blocks sites like reddit.com, youtube.com, etc.) and my normal hosts file, and also to allow me to easily add/remove sites I want to block.
I'm not sure if I'm doing everything right or securely, so please feel f... |
I'm trying to put lots of buttons inside a div with a bunch of little windows that make content change in a neighbor div, but I’m quite new to jQuery and I'm sure that this code can be much simpler.
It works, but it's just that I can see it's too long and repetitive I'm sure that it can be downsized.
jQuery(function(... |
I just know there's a simpler, better way to do this. Will eventually append <select> options with these values (e.g. 01:30, 02:45, 10:15, etc.)
var arrHours=[]
var i=0, j=0, k=0;
for (i=0;i<=23;i++)
{
for(j=0;j<=45;j=j+15)
{
var m,n;
m=i.toString();
n=j.toString();
if(m=="0")
... |
I've searched plenty on this topic and have gotten a lot of good (but different) results. Some of the results weren't quite related and it does seem to be a matter of preference in the end, but I'm interested in if I'm following good design principles or not.
If this is too vague of a question, feel free to delete it, ... |
I've written some code to group a list of items into arbitrarily sized buckets. If the items are all the same and the and the count is a multiple of the bucket size a single bucket is returned, if the items are different then they are grouped into buckets of a given size.
For example, with a bucket size of 3:
1,2 ... |
$(document).ready(function() {
$('#state-list, #major-list').hide();
$('#state').bind('click', function() {
$('#state-list').toggle();
});
$('#major').bind('click', function() {
$('#major-list').toggle();
});
});
All links and lists will follow the naming convention of:
link, link-list, like seen... |
I've written a quick little helper for event & call debounce/throttling. Since I'm at home and none of my regular code review friends are on-line I figured I'd turn to the great folks here! Would love any feedback you might have.
/**
* debounce
* @param {integer} milliseconds This param indicates the number of millis... |
I have an HTML form being populated by a table of customer requests. The user reviews each request, sets an operation, and submits. The operation gets set into a post arg as follow
$postArray = array_keys($_POST);
[1]=>Keep [2]=>Reject [3]=>Reject [4]=>Ignore ["item id"]=>"operation"
This is how I am parsing my Post... |
I'm just writing my first PHP-Mysqli sample (think about a Wiki 0.0.1) and I would like to ask you if this example is secure or not or if there are any other problems/suggestions you might recommend?
I would like to use prepared statements and not care about sanitizing the input from $_GET, but I don't know if this cod... |
I wrote this program for the Google Code Jam problem, "Recycled numbers."
It took around 2 and half minutes to solve the small input set on my dual core, 1GB RAM system. But for the large input set it took around 25 minutes(processor usage was 100% for those 25 mins) to solve the problem.
Problem
Let's say a pair of d... |
Here are two ways for writing this sample code (one using multi-threading, one without using multi-threading) - The original code (friend wrote it) uses multi-threading. I would like to know which method is better, and was there a motivation for using multi-threading in this situation?
1) First way (multi-threading):
m... |
To learn and practice coding in C++, I wrote an implementation of Kosaraju's two-pass algorithm for computing the strongly connected components in a directed graph, using depth-first search.
This was my first time touching any C++ code in a while (I mainly program in Python or C#). As such, any critique or advice on st... |
The following code detects if the system is idling. It approaches the problem by using the Robot class to take a screenshot, waits for a while, and then takes another screenshot. It then compares screenshot 1 with screenshot 2. If a certain amount of change is detected, it presumes the system is idling, else the syste... |
I have an abstract class implementing some concrete functionality for its child classes:
abstract class Function {
def eval: Double = some_concrete_functionality_which_calls_fEval
def simplify: Funcion = more_concrete_calling_fSimplify
protected def fEval: Double
protected def fSimplify: Funcion
}
The child c... |
I'm an experienced developer myself but for a current project I am working on I have decided to hire some developers to develop a mobile app which requires some supporting web services (developed in PHP).
I know myself that the code I have pasted below is worse than what I would expect a 5 year old to produce after spe... |
I'm a big fan of David Allen's Getting Things Done, but the myriad software tools and sites I've tried haven't impressed me that much. That's why I've decided to write my own.
The concept
This app (I don't have a name for it yet.) pulls in your twitter stream, Facebook news feeds, email, RSS feeds, and more and treats ... |
I've been building a coloring book for kids: http://coloringbook.core.ba.lightburncloud.com/
It's got to work on an iPad, so I decided to try out Raphaël JS. I want to try and make this as efficient as possible, and was wondering if anybody had any suggestions on how to tighten things up.
I'm just kind of flying by th... |
I've been working on a lightweight XML schema parser, and have what I think is a moderately clean solution (some parts helped out by previous questions I posted here) so far for obtaining all schema details, but would like any criticism at all that could help further improve this code.
Below I have supplied the schema ... |
I've built this two classes for a Poker game on Android and I would appreciate some feedback on my code.
Have no mercy. The harsher you are, the better.
Feel free to add your number of WTFs/minute.
PokerHand.java
package com.poker.util;
import java.util.Arrays;
import java.util.Collections;
public class PokerHand im... |
I supplied the following code as an answer to this question on SO, but I was wondering if there was a better way to write out all those array loops (i.e. perhaps using a Collection/Dictionary?) It seems clunky/cumbersome as-is.
Function ContainedInMonth(OriginalStartDate As String, _
OriginalEndDate As String) As B... |
I'm having trouble accessing variables throughout multiple functions. For example, I need to use userinput throughout many other functions, but do not have access to it with my current code. I am pretty sure that I need to change the parameters of my functions, so that I can pass the value of those functions by referen... |
I want to know why Java is accepted over Python when it comes to runtime. On performing the following Euler problem, Python takes up less lines and runs faster (Python ~0.05s, Java ~0.3s on my machine).
Could I optimize this Java code in any way? The problem is here (http://projecteuler.net/problem=22)
Python:
def main... |
I made a stack monad that lets one manipulate and control values on a stack.
I want to know if it's correct (it seems correct), how to make it faster, and how I could detect stack overflows without carrying around the stack size and checking against it (I've heard about guard pages but I have no idea how I'd use them w... |
This is my rspec integration test for user, it always breaks when my teammate change something, how do i improve this?
describe "Users" do
before(:each) do
populate_role
end
describe "GET /users/sign_in" do
#it "should redirect to redirect to user sign in page for user that is not sign in" do
# ge... |
Explained what I'm doing in the comments:
class User {
public $id;
public $email;
public $username;
public $password;
public $rep;
public function __constructor($id, $email, $username, $password, $rep) { // Assign all 'required' fields for our object upon instantiation
$this->id = $id... |
I have the following query which works as it should, but I'd like to know how I can make it run faster.
For info, tables cl, jo and mi all have column ref as the auto_inc primary key and ID as the main identification number. Therefore, I use the refs to keep a history of changes for ID. So, I use SELECT MAX(ref) FROM... |
I am implementing Dijkstra's Algorithm using Min Heap to speed up the code.
For a small number of nodes, the code is really running very fast. But for a large number of nodes, my code is throwing java.lang.OutOfMemoryError: Java heap space exception. My Min heap implementation is based on the code, given here in C++. I... |
I'm using VS 2008. I pass a List<T> a using ref, along with another List<T> b.
I need to cycle thru List<T> b, which contains around 200,000 items, and for each item in b, it it matches criteria in a, which contains 100,000 or more items, and update it.
public static void UpdateList(ref List<ExampleT> a, List<ExampleT>... |
Any improvements are welcome.
a.bat
sed -r "s/private (.*) (.*);(.*)/&\npublic \1 get\u\2(){return \2;}\npublic void set\u\2(\u\2){this.\2=\u\2;}\n/" "%~1">"%~2"
in:
private String firstName;// Stores firstName
private String lastName;
private String address;
using a.bat in out
out:
private String firstName;// Stores... |
I've a bunch of sequential activities. These are long running. Once an activity is complete, it can't be rolled back. Now something deep down the line fails. Now I've few options
Report this to end user and ask him to fix something. And then Retry same thing.
End user has no clue on what to do. He can choose to ignore... |
I basically check for required input fields and if they fail to validate, I need to go to another level of output, check for other required fields, and so on...
I can't get my head around this easy step-by-step validation. I already had it in a while-loop, but found it even more horrible than with beginner-like if-case... |
In Framework Design guideline book there is a chapter about Exception and they talk about return-value-based error reporting and exception based error reporting and the fact that we in a O.O language like C# we should avoid return-value-based error reporting and use exceptions. With that in mind I was looking at our co... |
I have an application that has multiple functions. Two in particular will query a remote computer using WMI, and return the installed printers in a datagridview. The other is a new method that will query the remote computer using WMI, and return information about the RAM.
I don't want to repeat the code that populates ... |
I have a class with some properties that I need to reflect over. One of the things I need, is a instance of a complex type returned for each of my properties, which means I can't just instantiate it directly in the attribute.
Now, I have so far two ways to do this. Either I can write method-names, in strings, in each ... |
I just completed Project Euler problem 18 which is a dynamic programming question through a graph of a triangle of numbers. The goal is to find the path from top to bottom of the triangle that has the largest sum.
In the example below the path is 3->7->4->9.
Say the numbers in the triangle are:
3
7 4
2 4 6
8 5 9 ... |
Working in C++ and I have some code which I'm refactoring. I have some code that needs to work with times of day but not dates. I do some juggling with time_t and struct tm but it's a pain and not intuitive to use. So I decided to make a basic time class with no date component. Let me know if you see any issues or ... |
So I have a little XML (Sub)language,
it has 3 elements of interest: para, point, and code
If a code occurs inside a para, point element I want to handle it for inline use,
if not, i want to set it up as it's own display section
Currently I'm doing it like so:
<xsl:template match="code">
<xsl:choose>
<xsl:w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.