instruction
stringlengths
71
71.9k
I'm learning Python and decided to rewrite my FTP tool from Perl to Python. The program is able to up/download files, change the directory and list the files of the current directory. Is there anything I can improve? #!/usr/bin/python import time import sys import os from ftplib import FTP import getpass def menue()...
I'd like to know if I translated a piece of code correctly from C++ to Delphi. It looks like it is working, but I have a feeling that I'm reading and writing into memory that I'm not supposed to using Delphi. Given C++ code: struct tile_map { int32 CountX; int32 CountY; uint32 *Tiles; }; inline uint32 Get...
I am a beginner trying to fetch a random line from a file and wondering if this code can be improved. Should I use try and catch in this case? Should I take a parameter for the function "quote"? How can I take several alternatives for searchText? (E.g. "hello", "hi" or "hey" but one is enough to return true.) def getI...
I recently made a little program that shouldparse a logic formula (given in conjunctive normal form). I do the parsing with reloaded operator>> but I am not very satisfied with the workaround I used to get those operators recognized from a file different from the file they are implemented in. When I need those operator...
I want to visually inspect all the characters that Java thinks are in any given UnicodeBlock. The following method, as far as I can tell, does the task. But, it sure feels like awful design. public static void displayUnicodeBlock(Character.UnicodeBlock block) { int maxCharVal = (int) Math.pow(2, 16); for(int cI...
I would like to search a String, and for a certain word, I would like to change only the first 3 letters For example: This is a java institute which insures that you are in that institute. ins! I want to change the first 3 letter of institute (ins) to JSE, so the result will be: This is a java JSEtitute which insure...
I decided to train myself in OOP with a simple perfect precision Fraction class. from __future__ import division import doctest class Fraction: """ Implements a Fraction Class with perfect precision operations and utility methods. The built-in operators are overwritten to provide a more natural interf...
I built a Tic-Tac-Toe game in Python. The board is made of ASCII characters and it is the user versus an AI. The user chooses a number (1-9) and if the corresponding spot is open then either an 'X' or an 'O' will be placed there. I wrote it in Python 2.7, then upgraded to Python 3.4, so I made it compatible with that. ...
I'm learning about immutability and uniqueness in Java, particularly the use of defensive programming and object factories. I have been asked to create a class containing an object factory that when called creates a unique registration number comprised of a single letter and 4 digits. I think my solution ticks all box...
I'm kinda new at this jQuery stuff and I've gathered up this much to make my code functional, but I would really want to shorten it. I've already tried $('#Monday','#Tuesday'....) to group them, but with no success. $('#Monday').click(function() { if ($(this).hasClass("active")){ $(this).switchClass( "activ...
I am a newbie trying to insert elements after the n:th element in the list. Any shorter/smarter ways? def InsertElements(listName, var1, var2, n): listName.insert(n, var1) listName.insert(n+1, var2) return listName myList = ["banana", "orange", "apple", "cherry", "grape"] result = InsertElements(myList, ...
I needed a way to update a parameter in the URL, or add it if it doesn't exist, but keep any other variables the same value. I built this function to do the task, and while it works, I feel like it's taking longer than it should. Does anyone have any suggestion on what I could change or a faster method? function chan...
I'm in a little bit of a pickle on my Tic Tac Toe program because I can't see how to simplify the code without breaking it. Do I need to make my code modular? public partial class dglassAssign4 : Form { string[] asImArr; const int ciArrSize = 9; int[] aiOrdArr; int turn = 1; ...
I am sorting an array (filtered) containing JS-Objects by their attribute sortdist: filtered.sort(function (a, b) { if (!a.sortdist) { return 1;} else if (!b.sortdist) { return -1;} else if (a.sortdist > b.sortdist) { return 1;} else { return -1; } }); However, I am sorting 9000 datasets, which takes a really ...
Spurred by this question: Project Euler #8 I decided to try to solve it with as clean code as possible. Here is the problem formulation: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326...
Is there a better way than this to copy the values from source to destination when the blocks of memory you want to copy to and from are different sizes? Also considering you have no control over making sure the sizes match to begin with. while (count--) { memcpy(dst, src, dst_stride); src += src_stride; dst +...
This cache is like a list where new elements are inserted in the middle, cache hits are put to head of the list and replaced elements are taken from the end. Would I just use a list the lookup would take O(n). With a dictionary it is O(log(n)) but I lose the order of elements, so I use both. .Net but only has Concurren...
I have to read a int8_t from a buffer, read a uint8_t from the camera's current settings, add them together, keep new value within the bounds 0 to 100 and write the new value to the camera's current settings. This seems quite easy to me, and yet here I have a rather large bit of code. The brace style is company-mandat...
I have several classes for payment handling, I separate these classes into directories like below. Actually I'm going to use it for Laravel project but to make it simple, maybe we can talk as if it's native PHP code. \Payment PaymentServiceAdapterInterface.php -> an interface for service adapter PaymentService...
I'm making a matchmaking system using PHP and MySQL which allows users to search through a list of musicians so that they can find people with the right skills and interests who are near them. It works but it's extremely messy, and I'd like to learn how I can clean it up and eliminate as many bad habits as possible. I'...
I follow this definition of "object":An object is a value exporting a procedural interface to data or behavior. Objects use procedural abstraction for information hiding, not type abstraction. Object and and their types are often recursive. Objects provide a simple and powerful form of data abstraction. They can be und...
Below is the given exercise: Exercise 5: Segments Consider the problem of representing line segments in a plane. Each segment is represented as a pair of points: a starting point and an ending point. Define a constructor make-segment and selectors start-segment and end-segment that define the representation of segment...
I have a function that returns some preferences, but first I have to do some checks to see whether the user is authorised to read them. I'm still not happy with the result (the match is a bit ugly). Note: Result is a framework class, it just means some kind of response. // implementations are not relevant. def canAcces...
Sample files: ./data/foo/file1.xml ./data/foo/bar/file2.xml ./data/baz/file3.xml Corresponding output: ./out/foo/file1.xml.xml2 ./out/foo/bar/file2.xml.xml2 ./out/baz/file3.xml.xml2 The subproblems are: Find all xml files in data/ Construct the output path: replace data/ with out/ and add an additional extension Cr...
Please have a look into this problem: Little Dipu is a small kid and like all the other kids, he likes to play, but he plays with numbers (he is extraordinary you know). Nowadays Dipu has some extra interest in odd numbers. So, he says that a number N is interesting if it has odd number of divisors. Now Dipu t...
I have a sort function that needed to sort in a certain way. That position was sorted by mobile-top first, then empty position followed by mobile-bottom. Then on these I needed to sort by their priority, with priority 1, 2 and then blank. widgetInfo = [ ['box1','mobile-bottom',''], ['box2','mobile-top','priority-1'],...
I think there must be a more pythonic way to achieve the lowercase-forcing that I need to do here. The keys in my lookup (self.adjustments) are all lc, params sent in to function can be any case (data coming from third party). Also, is it objectionable to have self.adjustments used here but not passed in? def getReve...
I have a very large number (millions) of messages, each labeled with the unixtime it was sent in a SQLite database. Each message has its own userid, for the user that have sent it. I want to know what's the max number of messages that is sent within an 24hr timeslot for each user. The 24hr timeslot is defined as the ti...
I am building a form with multiple select option fields. I am trying to only show the next field if it exists as a combination in the CSV file I am reading in. It's working fine right now and I am using onchange for each select field to call the next function. Is there a way to reduce to the code and make it more e...
I'm porting some Obj-C code to Swift, and I've written the following code to allow me to deal with "static local variables" which do not exist in Swift. A static local variable has these requirements: it is shared between all instances that access it it has one assignment method which only sets the value when it is f...
Sometimes you want to add/remove items from a collection inside of a foreach loop. Since this isn't possible, a common pattern is to add the items to a separate collection, then add/remove those items to the original collection after the foreach is finished. I'm wondering if this can be automated. Here's one attempt. I...
I have a base and derived class since I need to have different kinds of concrete classes. I cannot use the getInstance() function in the base class since I cannot make it both static and virtual. class ITrafficEventsReturner { public: virtual ~ITrafficEventsReturner() {} ; protected: ITrafficEven...
I've done a script that will write things as images, which can then be read elsewhere (eg. you could share an mp3 through imgur). This is the first one I've done where I've been trying to improve my writing style and make stuff run as efficient as possible, so if there is anything you see here that I can improve it'd b...
I'm working on a JavaScript plugin that makes font-sizes flexible (for a responsive layout). The code works well so far, but I'm sure that it's capable of improvement (especially if you look at the global variable). (function () { var extend = function (obj, ext) { for (var key in ext) { if (ext...
Using parse.com's javascript API, I would like to get a variable number or images from img tags on a page and save those images in the currently logged in user's user object. To my knowledge, parse cannot store image files directly from a url so I am using ajax to send each url to a php page that converts it and return...
my url is like page.php?path=content/x/y/z/aaa.md. Is the following php code secure? include "Parsedown.php"; function path_purifier($path) { if(substr($path, 0, 8) !== "content/") return null; if (strpos($path,'..') !== false) return null; return "./" . $path; } $parsedown = new Parsedown(); $path = $_...
I have a piece code which retries 3 more times to open a file (see below). Are there potential problems or side effects with the way it is written? How can it be improved? Also, why would one use Thread.currentThread().sleep(x) instead of simply Thread.sleep(x)? Any other code smell exists here? import java.io.*; publi...
The challenge in CodeEval is to take a number of days and iterate over the gains and losses and determine which lengths will yield the highest possible profit. I'm wondering if I could write this any better? It seems like sort of clunky code to me. file = ARGV[0] File.open(file).each do |line| duration, days = ...
I am trying to find the longest repeated string in text with python, both quickly and space efficiently. I created an implementation of a suffix tree in order to make the processing fast, but the code fails on large files due to memory problems. I am purposely not using any advanced libraries for this particular code....
This code is intended to take input from a form and append it to a database table. The same data is sent to a separate function for subsequent mailing to the respondent. I'm self-taught and it works so overall I'm quite happy. It just starts to seem a little flabby around the binding and creation of the $mail_params. I...
I am re-inventing the wheel and would like to lay down a comprehensive filesizes function. The only issue is that I guess bit-wise operators are more efficient but I'll be darned if I can understand them. What would you do to optimize this function? function humanFileSize($bytes = 0, $f = 1024) { $f = (int)$f; ...
For setters that set a member collection, I write template functions so as to accept any collection type as input: class HasItems { public: template <typename C> void items(const C& items) { // Copy-and-swap omitted m_items.assign(std::begin(items), std::end(items)); } private: std::vec...
I'm trying to use Moq to mock a rather large set of interfaces in an object. I'm trying to capture the behavior of retaining a dirty flag when properties are set and I'm hoping there is a cleaner way to do this because I have many properties that need this setup. public static void SetupDirtyProperty<T, TProp>(this...
I created a simple program that allows you to create and play MIDI sounds. I've used the MVC approach and I’d like to know if there are any improvements to be made regarding the design and structure of the classes? Have I used a constants class correctly? I also feel that the checkBoxArrayin the Midi class should be in...
I was going through my Java book's exercise solutions and comparing and incorporating the author's techniques into my repertoire. Most of the time, my approach is identical to the author's. When it is different, it is painfully obvious that his code is better and so I learn from it and rewrite it. This is the first ins...
My current code is kinda atrocious to switch fragments and everything, but I don't know a better way to check to see if the fragment I'm trying to switch to. private void FragmentChange(Bundle Data) { SetActionBarButtons(new String[] { "SearchButtonOff", "SearchExtraButtonOff" }); String[] data = Data.getString...
I posted a question on Stack Overflow regarding this program. I ended up pretty much rewriting everything to get what is posted here. This turned into a two-day long project. I've been using Python for so long; I've been spoiled. Anyhow, here is a BrainF*** interpreter. It takes in a file or reads from stdin. I've test...
To practice writing code in the functional programming style, I wrote a program to plot two-dimensional lattice random walks. I'd appreciate any feedback about how to improve its "functionaliness". possibleSteps <- list(c(-1,0), c(0,-1), c(1,0), c(0,1)) step <- function(x) { return(unlist(sample(possibleSteps...
My problem is in writing a function reverse(s) that reverses the character string s, a line at a time. My code here works, I write the line and it reverses the line. Is it a good solution? #include <stdio.h> #include <stdlib.h> #define MAX 1000 void reverse(char cad[] ,char cadenita[],int i); int main() { int a ...
I have to solve this equation: \$ x + y + xy = n \$ #include <iostream> #include <cstring> using namespace std; long c; int main() { long x = 0; cin >> c; if(c == 0) { cout << 1 << endl; return 0; } for(long i = 1; i <= c / 2; i ++) { for(long j = 1; j <= c; j ++) ...
I am trying to learn OOP in PHP. My PHP knowledge is pretty good, but haven't tried OOP before. I'm currently building a formbuilder class. Can you take a look and tell me if this is the right way? <?php class Forms { protected $_inputs; private $_method, $_action; public function __construct($method,$act...
I am creating my first HTML5 game using JavaScript and Phaser framework. I have a class (or more accurately a prototype) called MajorPoint that represents the starting point and the end point of the game. I initially put those two together, as they only differed from each other by the visible frame. Now as the game is ...
I've been learning JavaFX and wanted to recreate Simple calculator implemented with lambdas. It's also my first time using CSS, whose capability has convinced me of the wonders and appeal of JavaFX over swing. Hitherto, I've only somewhat used swing and jumping into JavaFX this program is now my most complex, I like ho...
I have been playing with Async/parallel execution in entity framework for while. I'm not sure if I'm doing it right. I have two entity contexts: one for reading and one for writing. The reading context has more than 200000 rows in table Customer. It took 9 minutes on my PC (i7+8GB). let FindGender(skip : int, take : in...
I'm trying to wrap my head around OOP, and am fairly new to PHP in general, so please forgive me if the following makes you cringe. I've decided to try and create a basic database wrapper using PDO. Here's what I've done so far. class DB { protected $db_user = 'root'; protected $db_pass = ''; protected $db_...
I was interested in experimenting with some intrusive versions of common data structures, so I've written this simple chained hash-table using the approach: #ifndef INTRUSIVE_HASH_TABLE_HPP #define INTRUSIVE_HASH_TABLE_HPP #include <cassert> #include <cstddef> #include <functional> #include <type_traits> // Types tha...
I have a program which generates a number between 0 and 4 for both the player and the computer. If the number is positive the player wins, and if it is negative the computer wins. if dif == 1 or dif == 2 or dif == 3 or dif == 4: print 'Player wins!' elif dif == -1 or dif == -2 or dif == -3 or dif == -4: print ...
I have been reading this great book and I decided to do the Project in Chapter 5: Writing an Assembler for the Hack Assembly Language. You can find the specification for the Hack Machine Language and the Hack Assembly Language here. Here is my implementation: package biz.tugay.hack.assembler; /* User: koray.asm@tugay.b...
I have small class which interprets TV show filenames to extract the show title and episode number. Due to the nature of the filenames, I have chosen for a cleaning approach: I clean the filename first as much as possible and then extract the necessary data (instead of matching the data right away with regexp). I'm kin...
I'm trying to learn C++ (with experience in C and Java, inter alia). I wrote a program to output a waveform of multiple (superimposed) tones, each varying in pitch. To execute: Compilation: g++ -W -Wall -pedantic -std=c++11 main.cpp Tone.cpp Running: ./a.out Playing: aplay out -r 44100 -f S16_LE (or S16_BE if you're o...
is being first and unique. Challenge: Write a program which finds the first non-repeated character in a string. Specifications: The first argument is a path to a file. The file contains strings, one per line. Print out the first non-repeated character of each string. Solution: import java.io.File; import java.i...
This is my second iteration of a simple Java MIDI player. I've made several amendments and would like to see if the code is now correctly implemented and readable. This follows on from the first review. With regards to the GUI class, is it a good idea to have musicInfo = midi.musicInfo in the GUI constructor? Or should...
I wrote this code that's supposed to correct quizzes on a webpage, but it feels bloated and I'm sure there's tons of ways to improve it. Any thoughts? $ -> #When submit_quiz div is clicked, do the following $(document).on "click", "#submit_quiz", (e) -> #Gets the quiz id for later use qid = getQuestions(thi...
As my first Java homework, I wrote a class to handle fractions. This Fraction class implements basic operations for the fractions (addition, subtraction, multiplication and division) and follows this interface*: interface FractionInterface { public int getNumerator(); public int getDenominator(); public Fr...
I was bored this evening and decided to create a program which calculates all the solutions for a given scenario of the game "24". The goal of this game is that you try to be the first one to find the answer to a certain card. On the card are four numbers ranging from 1 to 9. The player is allowed to use subtract, add,...
I am building a web app in Ruby but without Rails. So far I just have a very basic web server. What improvements can I make to it? require 'socket' require 'uri' # Files will be served from this directory WEB_ROOT = './public' # Map extensions to their content type CONTENT_TYPE_MAPPING = { 'html' => 'text/html', ...
I want to sort "movie search results" to get most probable movie that match "search". Input example: CARS.2.2011.720P.AC3.mkv I have a NameMatcher class which extract "title" and "year" from file name. Search string: cars 2 Search year : 2011 Results come from many websites like TMDB, Rotten Tomatoes, ... and much...
I am writing some Java code and am coming across a try/catch block in which I decided to verify the value is not null before parsing it: String parsedValue = DEFAULT_VALUE; try { if (myValue != null) { parsedValue = parse(myValue); } } catch (ParseException e) { log(e); } Regarding the code above, my questio...
The goal here is to only save (to file) the most recent Objects created if Object::maxMemoryOfObjects is exceeded. #include <iostream> #include <list> #include <algorithm> #include <fstream> #include <map> struct Object { const int ID; Object() : ID(++lastObjectID) {} static const int maxMemoryOfObjects =...
I'm designing a Tokenizer / Parser / AST. I'm wondering if this basic idea of an expression is good and if this way of implementing Simplification is good, or should I use something like the Visitor pattern? Is implementing it in the class itself a good idea? public abstract class Expr { public Expr Left; publi...
I am a complete noob to C and I've shied away from using such a powerful language due to it's large learning curve and other complicated mechanisms. For my first minor project I plan to create a small HTTP client that requests for a webpage. Before I start, I need to create a function that can correctly parse a URL usi...
Suppose I want to find the index of the maximal value of a given sequence. In Matlab, this is: [value, index] = max(x) In Python, I would abstract the following pattern: def find_best_element_index(elements, is_better): best_so_far = elements[0] best_so_far_index = 0 for (index, element) in enumerate(eleme...
I have implemented a Mammal class hierarchy in Java. Is it an intelligent approach, with respect to decomposition, locality and procedural abstraction? package Hierarchies; public class Mammals { public Mammals(){ } public void giveMilk(){ //REQUIRES: nothing //MODIFIES: nothin...
Because the ambient transaction isn't supported with informix, I pass the transaction and the connection through my methods. I want to ask about three things: Is the following code written well? I mean, no redundant steps and no logical errors. Is calling this transaction method with many null parameters in a specific...
I wrote a program for this problem, but it stopped because it took too much time. Any tips? The Problem: Bubble sort is the simplest algorithm for elements sorting. At each iteration we sequentially compare values of subsequent elements and swap them if necessary. Your job is to write a program which finds a state of a...
I'm using HapiJS to create a little backend for my side-project. In grabbing RSS feeds, I want to loop through my list of website URLs, grab the correct RSS links in the <head>, then loop through the RSS feeds, pulling out the articles, to return an aggregated JSON response (via the reply() call in HapiJS), to have all...
The function remove_odd is to remove odd valued nodes (surprise!!) from the linked list head. The code is very long and cryptic but it seems to work. Please help me reduce the lines of code and are there any cases that I might have missed. void rem_odd(struct Node** head) { struct Node* curr=*head; struct Node*...
Following is a Python program I wrote to find the common ancestor in a binary tree (not BST) with no link to parent node. Please review. def common_ancestor(N1, N2, head): if not head: return [None, 0, 0] left_status = common_ancestor(N1, N2, head.left) if left_status[0]: return left_status...
This macro is made to randomly draw specific number of civilization choices for a specific number of Civ V players. It is based on a list of 43 possibilities and the for loop in the while loop checks for already picked civilizations. Constant cell references point to values obtained with scroll-bars in the worksheet. T...
I'm working on a screen where I sent a request and I get response in two types. One is success and contains the below format: { "searchNames": [ { "CustomerName": "John", "CustomerType": "Business", "Profession": "Businessman", "address": { "ad...
Challenge: Implement a stack interface. Specifications: The interface should have ‘push’ and ‘pop’ functions. Your task is to ‘push’ a series of integers and then ‘pop’ and print every alternate integer. Your program should accept a file as its first argument. The file contains a series of space delimited in...
I'm trying to do Project Euler Problem 12, which reads as: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first sev...
I have the follow code to change between different CSS theme files, I would like some reviews on it because I am sure it can be improved to be safer. <head> <?php $theme = $_GET['theme']; $choice = preg_replace('/[^A-Za-z0-9\-]/', '', $theme); if (empty($choice)){ echo '<link rel"stylesheet" type="text...
I have been solving the following problem: Input array: \$[7,4,2,5,1,9,6]\$ Output array: \$[1,4,6,9,7,5,2]\$ I tried to do it in the following way: Sort the array. So, Input array becomes \$[1,2,4,5,6,7,9]\$ run time \$O(n \log n)\$ Numbers in even indices are \$[1,4,6,9]\$ an in odd indices are \$[2,5,7]\$. Move al...
I've posted and gotten help to optimize my code before here and here. Now I have implemented the following changes, after very helpful advice: I have implemented a Dictionary instead of using list when looking into the extracted messages. I have implemented index on the userid and unixtime tables in my database. Bo...
I found a lot of working codes to include page in page on Internet but I could not find a safe code. So I decided to create one myself. The pages will be only stored in folder /pages/ and whitelist seems to be a good option. Is the follow code safe? <?php $unsafe = $_GET['pagename']; $page = preg_replace('/[^A-Za-z0-9\...
First program I've written in Rust (besides the demos in the tutorial site). I decided to start by converting my C++ command line tool to Rust. This is not necessarily a 1 to 1 conversion, but I've tried to maintain the overall structure the same: // Currently (rustc 1.0.0-nightly), these modules are all unstable // an...
I wrote the following code as part of a larger application. This code takes a string that defines a mathematical function on such as r,y x[0], x[1] etc. or any other variable that additionally can be subscripted (indicated by the x[0] notation) and returns valid python function that accepts the the arguments and comput...
I'm trying to write a fully generic Stack in C++. I'm not sure if this is the best way to do this. Right now I know that the Pop method needs improvement since if T is a value type, returning a nullptr will cause a compiler error. Also, I'm pretty sure that this can be optimized in a few ways, but I don't see any o...
I needed to find whether any image's width at or higher than a certain directory folder exceeds a limit. Is this code a good way of doing this, or is there a way in which it can be improved? I ran it over at least a couple hundred images and several hundred other files contained in the main directory (not C:\Users, b...
-ish because I removed the input functionality from the compiler. And, the compiler does not support nested loops I've been recently reading up on compilers and how they work. Although this doesn't use most of the things I've learned about (the lexical and parser things), I thought it would be fun to try create a brain...
Challenge: Write a program which determines the Mth to last element in a list. Specifications: The first argument is a path to a file. The file contains series of space delimited characters followed by an integer. The integer represents an index in the list (1-based), one per line. Print out the Mth element fr...
I've very new to C++ and have been working through a tutorial and got as far as std::rand(). I was immediately horrified and rushed out to see if I could implement this as a service. This is my (pretty basic) non-cryptographically-secure implementation in the style of .Net's System.Random. There are a number of things ...
There is this type of puzzle that can easily be solved with a depth-first backtracking solver. I wrote one in python 3.4 and like to get some feedback. I'm especially interested in the following points: deepcopy. The usage of deepcopy in DepthFirstBacktrackingSolver.findsolutions is somewhat ugly. As Python simply bi...
I recently have been working on a Trie in Java. I have looked at the related posts here on Code Review to try and enhance my code, but I do have some methods and constraints not present on other posts. Objective To efficiently implement a Trie data structure in Java that is fast, with low memory consumption. Constrain...
Given a method isSubstring, two strings s1 and s2, check whether s1 is a rotation of s2 using only one call to isSubstring. Any comments on the code below? I would like to check the complexities as well: For isSubstring: runtime: \$O(n^2)\$ memory: in place For isRotation: runtime: \$O(n^2)\$ memory: \$O(n)\$ i...
Most of my experience is with Objective-C, so I am relatively new to Java inheritance. I understand that there are concepts such as abstract classes and interfaces, but I am still not totally sure when to use them. I would really like feedback on the structure of my inheritance in the following code. I am most concer...
This is a very basic PHP class that I am working on which will allow me to provide an HTML template in the form of a string saved to a variable or into an actual template file. I can then pass into my PHP class an array where the array KEYS will be used to find and replace variables in the template HTML. The template ...
For the below given exercise: Exercise 7: Abstracting Rectangles Implement a representation for rectangles in a plane. (Hint: You may want to make use of your procedures from exercise 5). Then, in terms of your constructors and selectors, create procedures that compute the perimeter and the area of a given rectangle. ...
Here's my test question for C++ programmer job: Servers only static content, no cgi Single process, multithreaded 1000 concurrent request at least Valid http status codes and headers No external libraries, just STL, POSIX and glibc Here's my code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <s...