instruction stringlengths 71 71.9k |
|---|
Here is a fast recursive Fibonacci-like for loop. How can it be more readable, and is it possible remove TArgs?
public static class Fibonacci
{
public static BigInteger Calculate(BigInteger number)
{
var fibo = AnonRecursiveFiboFunc<BigInteger>(
func => (step, fibo1, fibo2) => step == numb... |
I have written an age calculator that takes a birthDate as input.
I'd like a general review of this. I'm especially concerned about the message variable and the lines after the try/catch statement.
namespace Age
{
class Program
{
static void Main(string[] args)
{
while (true)
... |
I am creating a TicTacToe game for my college project, and when I finished the code for computer AI, I ended up with a big chunk of code.
It allows the computer to make the winning move, stopping the player from winning and making a random move if the computer can't make any winning move or stop the player from winning... |
I'm looking to improve my code to make it more efficient, such as shortening it but continuing to gain the same output, or to add some more complex functions into the code.
restart ='Y'
while restart not in ('N', 'n', 'NO', 'no'):
print ("Making A Cup Of Tea")
num_orders = int(input("How many for Tea? "))
p... |
My code below is for a sort of onscreen keyboard. I was just wondering if it could be written shorter with a lot of ifs and elses.
function input(key) {
fieldName = currentSide+'_scratchfield';
field = document.getElementById(fieldName);
del = "DELETE";
if(key == 'sp') key = ' ';
... |
I am just coding some classic brute force password cracking program, just to improve myself.
I've explained how my program works at the start of the code. Check some of those screenshots to understand easier.
My program works really well but it's a bit dirty and it can be faster if I solve these two problems:
The main... |
I wrote a little function which formats a ms timestamp in a human readable way. I know there are lots of scripts out there, but I needed a very simple one, which only outputs minutes and hours.
I was wondering if there is any way to shorten or improve this code snippet, because to me it seems to be very long for the f... |
I'm currently trying to develop some code that will handle parsing and building of a custom binary protocol. The protocol itself
is still fairly fluid but the basic core features are decided. These include
It has a start and end deliminator
It contains a header and payload set of data. The header is standard and c... |
Should I have made a line break convert_to_quick_mode( and from_exported_cdf,
convert_to_quick_mode(
from_exported_cdf,
code:
class QuickModeConverter(object):
def run(self,
from_exported_cdf,
from_exported_msword,
to_export_quick_mode_cdf,
to_exp... |
I am a beginner and I have made a Reservation Form in HTML. I'm pretty sure it will look horrible to any developer out there, but hey, that's why I've posted it.
I'd like a general review of this. I'm especially concerned about the quality and enhancements of this form. What should I do to add attractive looks and to u... |
Preamble
So, as most of you have likely also noticed, chat components, at least at a basic level, are becoming very common with lots of apps. I found myself tweaking and redesigning the interface from my last project all the time, so I decided to just create an easy to drop in solution. I'd love to get some second ... |
Based on some code on internet, I implemented a dynamic array of structures in C.
I am really interested in some feedback on this. Maybe there are some places where it can cause memory leaks or other pitfalls? (I am also concerned if there can be situation that I free a pointer twice in my case, and how to avoid that)... |
I'm building a virtualised grid in JS/HTML and finding browser performance with large grids fairly slow, particularly in IE10/11. The following jsfiddle roughly represents my worst case scenario, approx 1000 cells:
http://jsfiddle.net/FGr7g/1/
function test(count) {
var self = window;
var limit = 25;
if (count < limi... |
To check a win in my TicTacToe game, I have created a 2D array that contains all the combination that a game can be won in, like so:
private int[][] winningCombinations = new int[][] {
{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, //horizontal wins
{0, 3, 6}, {1, 4, 7}, {2, 5, 8}, //virticle wins
... |
Recently I have been making an MVC application with a fluid, responsive design in mind. One of the views has been to implement a fast responsive active directory details page. This is the first time I've really gone head-first into using jQuery/JavaScript with JSON results. Usually I stick to backend coding and someo... |
I have to apply window leveling on Canvas Medical Image (CR). I have to get a pixel array from C# Component.lutArr, which is a lookup table array coming as a C# component and which I use in JavaScript. On click of the button, I have to call the function ApplyWLCust(). In this function, all process done getting result... |
I have a list of opened nodes, with each step about 3000 nodes are opened and I want to put to the opened list only those nodes that are not already there. For now I'm just comparing each new one to all of the ones already in the opened list and only add it if it's not there. But that is around n*3000^2 comparisons for... |
I have a type that models the Arithmetic concept and use it as an opaque typedef (AKA strong typedef, see Note below) in some projects.
I've put the code into its own repository along with some tests and would like some eyes taking a look into it.
Note: for opaque typedef I understand the definition given in N3515.
P... |
I have some doubt when I should create an object in an Unit Test when the object needs to be stopped cleanly.
Usecase:
I have a class ComplexClass which has 3 functions:
Start(): starts a Thread
Stop(): stops the thread
GetX(): which gets a value
When I test this class I want to check if GetX() returns 42, but first ... |
I'm not that experienced with PHP and I'm trying to make it so when I load a page, instead of directly browsing to the file, it will be "included" instead.
I have the code finished and it works. I just wanted to get an opinion of if it's safe (will people be able to exploit it in anyway?) and if I'm going about this t... |
I have the following code, which works as I need it to, however, it repeats itself over and over.
I'm relatively new to PHP and haven't grasped recursive functions yet. Which I've been told I'll need to understand as this function could potentially have many levels.
if ($_POST['parent'] == "None") {
$parent = "... |
I am learning algorithms in graphs. I have implemented topological sort using Java. Kindly review my code and provide me with feedback.
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
public class TopologicalSortGraph {
/**
* This Topological Sort implementation takes the ex... |
I have a program that has to initialize a few big things (connect to a few databases, parse some XML) and without the initialization being successful the program would not be able to continue.
Right now I have my main method throwing just a general Exception
public static void main(String[] args) throws Exception
{
... |
This code has a method that I call for in main.
I am given a list with temperatures. What I need to do is to write out the biggest absolute difference of 2 neighbour numbers. For example, if I have {1, 3, 4, 10, 7, 4}, the result is 6 (between 4 and 10) and also all other pairs that have the same difference.
I have t... |
I've implemented a simple linked list in C# using generic T for values. I did not inherit from any of .Net's fun and helpful classes like IEnumerable<T>, or IList<T> :D. This is just after an hours worth of work. I've tested everything and I believe it all works well enough, but before I go on to add more methods, or m... |
I'm writing a small text-based game in Java to learn the language. I'm concerned that I may be making some poor design decisions. I'll introduce 2 elements: A character and monsters. A singleton character should be able to fight a wide array of monsters.
Here is the monster class:
public abstract class Monster {
p... |
This is one of my first useful scripts. I run it on a highlighted text selection within Notepad++, but I've provided a sample formula and commented out the Scintilla-specific references.
I'm a rank amateur: Am I using good idiom? Is my approach to a state machine sensible?
# input_text = editor.getSelText()
input_text ... |
I have a DelayQueue in Java, which multiple threads will read from. They will then perform a task, and call a requeue method which performs some mathematical logic (no odd concurrent access), and then calls queue.put(this). I'm aware that both take and put are blocking methods on the queue, so will this risk any deadlo... |
I have quickly wrote a Perl script to convert a mediawiki to a dokuwiki. I know there's an existing script to make that, but I would have a simpler usage code and some use of the API from mediawiki. It was also a good occassion to use pQuery module. I know I can improve some things and I'm going to make a generic comma... |
I sometimes hear people say how they can distinguish between good and bad coders of a certain programming language or even programming in general simply by looking at the code they write.
I'm relearning C, and I was just wondering whether my program follows best practices in terms of my commenting, the way I set it up,... |
If the number is present, the output should show the numbers that are not present.
.model small
.Stack 100
.data
array db 5, 12, 23, 45, 60, 67, 96, 100
len equ $-array
key db 100
msg1 db "found$"
msg2 db "not found$"
.code
mov ax, @dat... |
Basically, I'm trying to make a Simplifier that can take inputs in the form of a String and print out the solution step-by-step. Now that I've got it working, I think it has some cleanliness issues.
public static void test(String eqn) {
char[] order = { '^', '*', '/', '+'}; //order of precendece
int found, i,... |
I am a beginner and I have made a Fare Chart in HTML. I'm pretty sure it will look horrible to any developer out there, but hey, that's why I've posted it.
I'd like a general review of this. I'm especially concerned about the quality and enhancements of this form. What should I do to add attractive looks and show that ... |
I want a review of this code.
<?php
$array = $_POST['array']; //array holding numbers
$array = array_reverse($array); // reversing the array
echo "<br> Credit card Before :- ";
for($i=0;$i<sizeof($array);$i++)
echo $array[$i];
echo "<br>";
echo "<br> Credit card after applaying mod 10 Algorthi... |
I'm using Kohana's routing with the route being defined as domain/controller/action. To demonstrate my question let's consider sign-in flow. Currently, if I want to sign-in user I need to return form first and then proceed with data sent by user. Do I need to have two actions, each for the corresponding flow (returning... |
My JavaScript is fairly new and want to learn new ways to create clean, fast code. Can you have a look at this code and guide me on how to optimise this code to improve my skills? I have provided the HTML even though I am not able to edit the actual html as its generated but lets pretend I could..
What I am doing is pu... |
I built this as a simple example of using raw JS to perform a simple GET request with a data callback.
Suggestions on how this could be improved in any way, while keeping it simple, would be much appreciated.
JS:
/*jslint unparam: true, white: true */
var app = (function() {
"use strict";
return {
aja... |
This is my first model RSpec test:
require 'spec_helper'
describe CashFlow do
context 'DB Fields' do
it { should have_db_column :amount_cents }
it { should have_db_column :amount_currency }
it { should have_db_column :user_id }
it { should have_db_column :target_date }
it { should have_db_column... |
My project is written in node JS + Express and has the following architecture:
routes (e.g controllers)
models (stateless functional modules)
app
Models objects only doing SQL queries like this:
exports.setPassword = function (id, password, callback) {
pg.connect(conString, function (err, client, done) {
if (er... |
I've written a function to call with the deferred library to generate a large task queue, and at first without the recursion it timed out (deadlineexceeded) so now I'm trying with a recursion but is it safe that the function will terminate? I actually ran it with GAE and it did the correct task - deleted all the empty ... |
I created a console program that tests report results from JasperReport. It retrieves the list of reports, splits it, and passes each sublist to a new thread. Each thread executes its own reports and compares the results with reference files.
My colleague says multithreading is wrong, but as usual he doesn't explain wh... |
I recently wrote code that would query a collection of objects and rank them according to a given criteria and then filter based on an object property. I attach the code below. I would like to know if my approach can be improved upon such as made more efficient and extensible. Is there a better approach or just another... |
I am getting list of badCatsNames from webservices, now I have two asp.net bulleted lists here,
Bulleted List 1 - Available Cats
Bulleted List 2 - Purchasing Cats
Now I need to check each bad cat name if bad cat is in available cats list, if bad cat name is then take her out of Available Cats and put in Purchasing Ca... |
I have written the following code to get ImageColorPicker child:
foreach (CustomTabItem customTabItem in SelectedWindowsTabControl.Items)
{
TabItem ti = tabControl.ItemContainerGenerator.ContainerFromItem(customTabItem) as TabItem;
Popup popup = (Helpers.FindVisualChild<Popup>(ti) as Popup);
ImageColorPicke... |
I'm new to PHP and web development in general. Is this a good coding style for me as a beginner? I don't care about password hashing. I use MD5 which is, as far as I know, not a good encryption method, and I'm trying to create just the login for now.
connection.php:
<?php
try {
$pdo = new PDO("mysql:host=loca... |
I created a linked server in SSMS so that I could run reports on a SpiceWorks SQLite database. there are a few quirks in the whole system.
These simple queries are becoming some of the most expensive queries on my reporting SQL Server, I kind of know why, is there a way that I can do this differently?
The Code
I have... |
I have two queries; one runs significantly faster than the other, but the faster one is the one that I would have bet money on to be less efficient. These are both being executed through a front end C# console based application and are stored as procedures in SQL Server 2008 R2.
Basically, I have the first one I wrote,... |
While writing this review, I saw a need for a Counter object similar to Python's. It seemed like it would be easy to write such a class, but it turned out to be surprisingly complicated.
Counter.java
import java.util.*;
public class Counter<T> implements Map<T, Integer>,
Iterable<Ma... |
I'm building a media viewer web app for a kiosk in node that uses data in mongo. To render the viewer, it gathers together all the Asset objects (representing video files), each of which belong to a Category, each of which belong to a Medium.
This is my first time using mongo and node together, so I decided to use asyn... |
In 8-puzzle I want to count the number of moves it would take to move a specific tile to it's goal place. The problem is my method for this is >100 lines long which is obviously way too much. I'll only include part of that method that counts steps to move the piece to the right row if the goal row is higher. It gives t... |
This is the first time that I have played around with AsyncTask in Android and I wanted to make sure I'm using it correctly. The idea is I'm grabbing all the rows from a table in the database using dao and putting them into an Arraylist based off my Item class. Once finished, I added it to a custom Adapter and add it t... |
I'm wondering if I am doing this in the most efficient way.
So I'm declaring my function el which is equal to a macro (Google Tag Manager), then I reassign or overwrite that previously-defined var which grabs the innerText/textContent of the element. It then converts the string to lowerCase and then capitalizes the f... |
I've written JavaScript for a while, but lately I've been writing a lot of C#. I wanted to write a method that could take the column name of a DataTable and return an average for those values. Having never written closures in C#, but being comfortable with them in JavaScript, I came up with this:
public static double... |
I have recently answered a question on Stack Overflow where OP wanted to programmatically determine if TreeView's node is checked or not, among other things. My answer got accepted since everything seems to work fine.
Still, after reading MSDN documentation for TVN_KEYDOWN, I found the part in the "Return value" sectio... |
This is my first "useful" Haskell program. It's invoked with filenames as arguments where the last filename is the destination to which the content of all other files will be concatenated. As far as I can tell it's working but I don't like the two returns in the main function and would like to know how I can get rid of... |
I have to implement a simple program in SSE, and I don't know if I have done it in the right way (it's my first program in SSE).
This is the C++ program:
double distance (int x1, int x2, int y1, int y2)
{
double x = abs(x2 - x1);
double y = abs(y2 - y1);
double dist = sqrt(x*x + y*y);
return dist;
}
... |
I have a class that I call "Icons"
Icons.h
#import <Foundation/Foundation.h>
@interface Icons : NSObject
+ (UIImage *) someIcon;
+ (UIImage *) someOtherIcon;
+ (NSString *)imageToNSString:(UIImage *)image;
+ (UIImage *)stringToUIImage:(NSString *)string;
@end
Icons.m
#import "Icons.h"
@implementation Icons
+ (UI... |
Task:
Create an interactive slider that allows the user to view a given image gallery.
Slider controls:
See previous slide
See next slide
Quick navigation through the images / Paging - transition to an arbitrary slide
Properties of the object slide:
image
title
description
link
Settings slider:
Container... |
I am parsing excel data and need to create object based on StartDate-EndDate difference.
Is there a better way to have only one linq perform this task and return two different result sets ? Only difference in both linq is just the variable on which its applied.
private Dictionary<string, Dictionary<DateTime, List<DataP... |
I am trying to learn C++ by myself. I looked up a sample question after going through some text. Though I would like someone to review my code. I'm basically asking you to break it to show some flaws or some thing I missed. As a beginner I tried exhaustively to improve it and now hit a wall to analyse robustness of t... |
I am a beginner and I have made Colorful Lights using check-boxes in HTML. I'm pretty sure it will look horrible to any developer out there, but hey, that's why I've posted it.
I'd like a general review of this. I'm especially concerned about the quality and enhancements of this form.
<html>
<head>
<title>
Javascrip... |
It's harder to do than criticize. Here's my attempt to implement a Celsius-to-Fahrenheit conversion table in C++.
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#define DEGREE_SIGN "\u00B0"
class Fahrenheit;
class Celsius {
public:
explicit Celsius(double c) : c(c) {
if (... |
I'm new with Angular promise and I would like to know how to improve my code.
I have a service which preload media or data by calling an API.
The media API return an array of urls to preload.
'use strict';
angular.module('myApp').service('PreloaderService', ['$http', '$q', 'localStorageService', function PreloaderServ... |
I have a small Coldfusion section of our site that all uses similar JavaScript and CSS files and page design. The code is currently repeated for each file, and I'd like to factor it out and set something up using a master page and templates.
Master.cfm page:
<!--- Master template, includes all necessary js and css file... |
Method:
Input: a string which represents an integer or a non-integer value.
Output: a string which represents the same value multiplied by 100.
Requirements:
No floating-point unless needed.
No leading 0s in the part left of the floating-point.
No trailing 0s in the part right of the floating-point.
I cannot use th... |
I want to have a continuous date sequence like ['2014-01-01','2014-01-02', ...]
Then I define a stream to do that.
def daySeq(start: Date): Stream[Date] = Stream.cons(start, daySeq(plusDays(start, 1)))
I get the sequence within range [start, end) by calling
daySeq(from).takeWhile(_.getTime < to.getTime)
Any better/... |
I'm writing a JavaScript library, and I am using this function for type detection:
function type(obj){
return Object.prototype.toString.call(obj).replace(/([\[\]]|object|\s)/gi, "");
}
Their works ok, but compared to jQuery and MooTools it stinks.
http://jsperf.com/code-type-test-a-test
How can I improve its per... |
Basically, I have two separate tables, Campaign and CampaignDetails. They relate via CampaignID. I want a service that can handle both at the same time, as they're closely related and when one gets updated- so will the other.
At the moment I'm combining the two but it's starting to get a bit hard to look at
public inte... |
Which unit testing approach and WHY do you prefer?
Inheritance-driven-testing
public class GivenSynchronizedDataLink : TestBase
{
internal SynchronizedDataLink Subject { get; private set; }
protected Mock<IDataLink> DataLinkFake { get; private set; }
protected Mock<IAutoReaderWriterLock> ReaderWriterFake {... |
Is there a way to write this better or more Clojure way? Especially the last part with with-open and the let. Should I put the -> form into a separate function? Is this function to overloaded (to much stuff) or is this still ok?
(defn scrape-book-cover [url image-filename]
(let [out-stream (io/output-stream image-f... |
I have the following two methods of completing the same task, however I'd like to know which is the preferred method and WHY? Or if there are any suggestions to complete the task in an even better, cleaner way.
The task
Find part 1 of $string in the example $string = '1/2/3/4'; so the first part would be '1'.
Match th... |
I have a multidimensional array as a result from a webservice called from PHP. I cannot edit the webservice, but the result is as
array (size=5)
'id' => int 0
'name' =>
array (size=7)
'it' => string 'Tutti' (length=5)
'ca' => string 'Tots' (length=4)
'es' => string 'Todos' (length=5)
'd... |
I wrote a cstring parser. It has to work with a relatively wide amount of arguments (usually 3 or 4, but maybe in future with a different amount), which are separated by an , or ;. My wish is to make at least Function 1 less static and save some code. However, I don't really want to use dynamic memory allocation (just ... |
In this comment the OP wrote,
I am a newbie so i would like to know how would i parse the negetive numbers/arguments ?
In this answer @200_success showed an implementation using the strtod function.
The following is my implementation of the strtod function:
A valid floating point number for strtod using the "C" loca... |
I use SonarQube to help me try and become a better programmer to program along with 'best-practice' standards.
There are business rules when a user is submitting data they enter in a datagridview that I encompass in a Try Catch block. I think the comments in the code describe fairly well what should be happening.
The p... |
Can anyone recommend improvements to the compress() method?
public class ArrayList<E> {
private Object[] array;
public static final int DEFAULT_SIZE = 20;
private int size = 0;
public ArrayList(){
this(DEFAULT_SIZE);
}
public ArrayList(int size){
array = new Object[size];
}
public void add(E element){
... |
I'm new to jQuery and trying to learn how to refactor my bloated code to make it nicer and better maintainable.
I have a tabbed navigation which I'm using jQuery to hide and show pages depending on the selector that is clicked.
$('#search_distributors').on 'click', (e) =>
e.preventDefault()
$('#distributor_lo... |
I've written a small library of objects for parsing of Valve Map Files (VMF). These files are always generated and exported from either the Hammer World Editor, or a Source engine built in map making program like the PTI in Portal 2. So I can trust them to always look roughly like the following, except of course that t... |
I wrote a lockless queue for sending small objects from a single thread to a random worker thread.
Assumptions:
x86/x86_64 compiled with GCC
one thread may Write(), multiple threads may Read()
notifying a thread that data is available is done elsewhere
T is copy assignable and sizeof(T) is small
N is a power of two
A... |
This is code I need to maintain. I'm trying to make this as an example for code gone bad, for C programmers going to C++.
Please provide any comment you can. The original code is about 40 pages long, so I just gave this "small example".
void Algo::compute( Image* pInImg, Image* pImg, Image* deBugImg)
{
int ind_r,... |
I would like review on the following dynamic memory allocation process and suggestions on whether there are any memory leaks. Following code is not real code in use, but I'm trying to understand concepts of memory allocations and de-allocation in different ways.
class ObjMapData
{
private:
//Header Info fields to descr... |
I have a controller with just a few actions, not the whole 7 RESTful actions situation. Here's what I have so far for routing:
Snip::Application.routes.draw do
get "appointment_reminder_responses/confirmation_thanks", to: "appointment_reminder_responses#confirmation_thanks"
get "appointment_reminder_responses/decli... |
I have a JavaScript function that takes in a user number (total amount placed on a betting table in denominations of 50) and returns an Array of the optimum chips (lowest # required) to form each stack.
My function works, the correct array for each value tested is output - but since this should be running on the client... |
I'm using NSInvocation as a choke point in my app to help manage threading and reduce the amount of redundant code. The purpose of this class is to pass arguments from the view controllers to the API project on a background thread and return success/error on the main thread. I also have a log callback that logs API e... |
I've just completed this binary search kata - which has some weird requirements - and I spent a little while "cleaning" up my code and making it more compact. I would appreciate some feedback on the readability of the BinarySearch class. I've packed a lot of logic into some of the lines and I'd like to know if that mak... |
I'm doing a programming practice problem and was wondering if someone can suggest a better to create/setup the call back for the comparison function. I have the following classes:
public class myTreeItem<T> {
private T item;
private myTreeItem<T> left;
private myTreeItem<T> right;
private myTreeItem<T> ... |
I just got into structs and I decided to create a list using them:
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
char counter;
struct list
{
int x;
struct list *pointer1;
};
struct list test;
struct list *pointer2;
pointer2=&test;
for(counter=0;counter<5;... |
I need to pull the version # out of a Vim script that might look something like:
" some header blah blah
" Version: 0.1
[a bunch of code]
" Version: fake--use only the first version
The expected output is 0.1. If a Version # doesn't exist, it should return the empty string or something like that.
I'm new to Powers... |
I am doing some programming on the side and would just like to know if I'm going in the right direction with my code.
public class FileTransfer
{
#region Variables
private const int MAX_CHUNK_SIZE = (1024 * 5000);
private static BinaryWriter fileWriter;
private static FileStream fileReader;
... |
I've created this socket class to use in my web server application. I have two classes: one for the socket and the other for the webserver.
//#define WIN32_LEAN_AND_MEAN
#include <iostream>
#include <string>
#include <Winsock2.h>
#include <Windows.h>
#include <Ws2tcpip.h>
#include <stdexcept>
#include <stdio.h>
#prag... |
A prime number util, which provides 3 APIs - find the nth prime, find the next prime, and find all primes up to n.
I must admit this code has been influenced a lot by discussions here. I'm looking for code review, optimizations and best practices.
public final class PrimeUtil {
private static final boolean COMP... |
Please let me know if I have over/under explained my question :)
HTML table row - the numerals from each id attribute, in this example "408" and "409", are the database tables primary ID numbers, one database table row per HTML table cell.
<tr>
<td id="FieldId408"><!-- input element --></td>
<td id="FieldId409"... |
I need to have an unique ID for any type in C++ for a variant type. Is this code reliable for getting the ID? I don't care to have same ID for same type between multiple runs. Sorry for typos/formatting, I wrote the code on my phone and tested on Ideone.
#include <iostream>
struct Counter
{
static size_t value;
};... |
I want some feedback on the program I developed in C for printing the permutations of a given string.
#include <stdio.h>
bool isUnique(char x[], int y)
{
int i, j;
for (i = 0; i < (y-1); i++)
for (j = i+1; j < y; j++)
if (x[i] == x[j])
return false;
return true;
}
void perm(char a[], char... |
Construct a matrix with the following property:
North-west to South East diagonals are squares.
Matrix[i][j] + 1 = Matrix[j][i] for each i less than j.
Example of such m a matrix is here. Also, since it appears this matrix does not have a name, I have named my class "Sqaure Diagonal, Transpose Increment".
Looking... |
I have settled with this type of structuring of unit tests.
Basic idea is that there is a base test class for the tested class, and a subclass for every tested method. They use the mocks and everything from the base test class, the point being that the test would remain small, and you don't have to create everything in... |
This is a simple load more plugin, built for teaching purposes. For this reason, it's not pretty in terms of output.
I'd like to know if this can be improved, or if anyone can spot any major problems with this. The one thing I'm concerned about is the 'templating', whereby it gets the template from the initial markup a... |
I want to get some best practices and code corrections.
JS
function clock(){
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
var seconds = currentTime.getSeconds()
var timeOfDay = ( hours < 12 ) ? "AM" : "PM";
hours = ( hours > 12 ) ? hours - 12 : hours... |
Is better to use $id_name ( Class A Method b() ) OR $id_name_2 ( Class A Method c())?
<?php
Class A {
function a(){
$params = array(
'id'=> 1,
'name' => 'b',
);
$id_name = $this->b($params);
$id_name_2 = $this->c($params);
}
function b($params){
... |
I have a PL/SQL stored procedure which searches for a row in 3 different tables (not all columns are the same).
The logic goes as follows:
Search for the item in the first table
If item was found
select the details of it from the first table
If item was not found
search for the item in the second table... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.