instruction stringlengths 71 71.9k |
|---|
For some time, JavaScript string concatenation could be optimised by join()ing an array of strings, instead of +ing them together.
Recently, browsers have been optimised to handle strings better, and +ing is back in favour.
The various posts I've read on the subject have cited many jsperf.com tests, which are invariabl... |
This is a class called Board which handles the tracking and checking of the state of the game. self.board is a dict of coordinate: state pairs, for e.g. (0,1): 'x'.
I could have hardcoded the checking lists in but decided to be adventurous and learn a bit of itertools.
The complete program is about 130 lines of code an... |
I had to create this program, and I did it fine, all is working and stuff but I was wondering, what is better way of doing such thing? I want more efficient method.
Problem assignment:
In the file is unknown amount of numbers. Create a program, which
output is amount of numbers, the lowest number and the highest num... |
This is a plugin for hangoutsbot/hangoutsbot that listens for words people say and then gives them an ETA and a link with directions.
Happy to hear about any optimisations that could be made.
import logging
import hangups
import plugins
import asyncio
import googlemaps
logger = logging.getLogger(__name__)
from textb... |
I have a little project where i am implementing an immutable linked-list (not only...) based on a pair-structure like the LISP cons-cell.
The linked list works well and is basically wrapping two variables in a closure in an object, the variables are "head" and "rest" (think LISP´s car and cdr). I have also added some u... |
I wrote simple online users tracking for my ASP.NET MVC project.
In Global.asax I added:
protected void Session_Start(Object sender, EventArgs e)
{
// get current context
HttpContext currentContext = HttpContext.Current;
if (currentContext != null)
{
if (!currentContext.Request.Browser.Crawler... |
This is the Hash-Matrix that I used in order to process the matrix for my quadratic sieve algorithm. You can find the full code at here(it's java 7), but I only want you to review this class.
My prime focus is performance and any feedback will be welcome. The entry point is the solve method, you can skip the init part ... |
I made a simple comparison window in WPF that has two RichTextBoxes highlighting the differences (in red) of two StringCollections.
I knocked the code up in about 5 minutes and having gone back to look at it it appears pretty shoddy. I've included comments to show my intentions.
private static void DifferentiateText(R... |
I am writing a class which can log the activity of an application during run time. The plan is that the SupportMI string will be sent to a DB, from where I can use some other code to format it properly for readability. I need this class to be usable with .Net-3.5 due to system limitations.
What I need is the method nam... |
The goal is to create an activity or update its counter if it's already present. And to be super accurate, the code avoids race conditions with a custom insert_on_duplicate_key_update MySQL query.
All user activities are already preloaded, so in case the service knows that there was an existing activity it will just do... |
I have made a connect 4 console application in C++ and would love some feedback. In this project I have learned about inheritance and using virtual functions.
Main.cpp
// ConsoleApplication2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Player.h"
#include "humanPlayer.h"
#... |
I previously posted a question on finding the maximum value of an InputIterator range. For completeness, I thought it would be useful to post an implementation that finds the minimum & maximum values, in a similar way to std::minmax_element.
#include <iterator>
#include <algorithm>
#include <functional>
#include <utili... |
I've written a small implementation for doubly linked lists. While actually intended to be only used by me in subsequent projects, I wrote it as generically as possible. Maybe this'll be advantageous.
I tested the implementation and resolved as many bugs as possible but maybe there are more lurking somewhere in the cod... |
I wrote a program to solve a problem, I am not so good in python so want help to find areas where this program can be improved or simplified and readable too:-
I got this problem in a code challenge
Problem
Professor Hatim is researching the sexual behavior of a rare
species of lizard. He assumes that they feature t... |
This is how I posted a method from C to Swift. I tested it well, it seems to work. It's there a way to write this better, following good practices of Swift? The original is in C and the target must be in Swift.
Original C Code:
inline float mac(const float *a, const float *b, unsigned int size)
{
float sum = 0;
... |
This Excel VBA function was originally the subject of a previous question on Code Review. This function (Namify()) takes a string as input, modifies it to make it valid for use as a range name, and then returns the valid string. I've revised the function based on some excellent input from Mat's Mug and RubberDuck and I... |
I have a table of patients that has a field for which hospitals they visited. I want to retrieve a list of patients that have visited Green Hospital and have also visited other hospitals. Is this query accurate?
SELECT COUNT (DISTINCT PatientID) FROM Patients
WHERE PatientID IN (
SELECT PatientID FROM Patients... |
I've started Python some days ago and wrote a small Telnet implementation according to RFC 854 and RFC 5198. It is pretty low-level and sending messages directly isn't even supported. The highest abstractions are commands and user data where commands include negotiation (like "Do") and "general-purpose" commands (like ... |
The following Pascal script needs a bit of context for its purpose to be understood. For those who don't give about purpose, feel free to skip ahead.
Background
A game I'm terribly fond of has a couple of levels which have nothing to do with the rest of the game. One of those is a puzzle: Alpha Sector::virgilw::Brain
W... |
I recently wrote a BMP writer in C:
bmpWriter.h
#ifndef BMPWRITER_
#define BMPWRITER_
#include <stdint.h>
int write24BitBMP(const char *outputFileName, uint32_t width, uint32_t height, uint8_t *rgbData);
#endif /* ifndef BMPWRITER_ */
bmpWriter.c
#include <stdlib.h>
#include <stdio.h>
#include "bmpWriter.h"
type... |
I recently started getting into machine learning and I wanted to write a "beginner program" which would learn to play Tic Tac Toe. This code was inspired by a different program I saw, meaning some ideas (like saving the valid moves in a String) are not from me.
You can either play against the AI or let it play against ... |
After asking Randomly choose a game executable from a folder, I applied the recommended changes. I also redesigned the program to make use of the MVVM (Model-View-Viewmodel) paradigm, using Prism 6.0. This was such a large change that I bumped the version number to 2.0.
The project can be found at https://github.com/nz... |
My application relies on an unknown number of DLLs that each produce a report. The only thing that is known in advance is the location of the files and the classes that each will contain, including the base types. When the user needs to define a new report for use in the application, a list of every available report ... |
I have a Python script that generates a dictionary of all possible 3 digit password combinations. It essentially works by just nesting for loops. This is fine, but say I wanted to change it so it could generate 4, 5, 6, ... digit combinations. This would require me to keep adding more nested loops and changing the prin... |
I'm writing a small checkers game in python (international rules) and I need some pointers here and there. For the moment, I am only drawing the board and checking the syntax of moves with a regex.
For review:
Usage of a value package for passing around game state (grid, turn_count, and current player), is there a bet... |
Following-up on my last question where I wrapped the Sage API with a familiar IRepository interface, I decided to push the abstraction a step further, and... implement an actual LINQ provider.
So my client code looks like this:
class Program
{
static void Main(string[] args)
{
using (var context = new S... |
I wrote a pretty simple bash script. It takes a directory with subdirectories with incremental prefixes in their names (01test, 02test, 03test), creates a new directory with the next highest prefix and creates a couple of files and fills them with some default text.
I'd like to do this in fewer lines of code and elimin... |
Purpose
This problem comes from this dailyProgrammer subreddit challenge.
The task is to take an input of C / cs and V / vs and to replace Cs with random consonants and Vs with random vowels (English alphabet) while keeping the case the same. Y is not considered a vowel in this case.
Example:
CcVvv => BgAoi
ccVVV => z... |
It works, just feel that my solution is too complicated.
# Write a method that takes a string in and returns true if the letter
# "z" appears within three letters **after** an "a". You may assume
# that the string contains only lowercase letters.
#
# Difficulty: medium.
def nearby_az(string)
i = 0
while i < st... |
I am in my first year of formally learning computer programming in high school (we are using Java). One of the tools we used was Karel J. Robot, which can be downloaded here. Although we finished using Karel after a semester, I felt that there was a lot more I could do with it. I decided to use some of what we are now ... |
As the title states, this is a compiler written in C with a ruby build script that translates a minimal LISP dialect and spits out an executable jar file. I designed this LISP dialect and named it mjLisp. It has some missing features (that requires some extra parsing effort, thus more code) as you can see in the list b... |
I have 4 booleans and all must be met to determine the value of a String:
String message = (!isNameBlank && !isDestinationBlank
&& isDestinationValid && isAmountValid)
? "Have a safe trip!" : "Please try again!";
If I do this, it doesn't look elegant either:
String message = "";
if(!isNameBlank && !isDestinati... |
Here is my lock-free queue implementation for single producer with some preallocated memory. T is a simple type with no need for move operations. I don't use bool pop(T& result) in order to avoid double checking. I would love to see your feedback!
template <typename T>
class LockFreeQueue {
public:
void setup(U8* b... |
I'm having some issues coming up with a sensible solution for using shared state in a C-style function pointer. I am using GLFW to handle my OpenGL context and have created a thin wrapper around all of the setup code. I want to provide a way of registering callbacks for key presses, however the glfwSetKeyCallback takes... |
I have this C implementation of the natural merge sort:
#include "stable_sort.h"
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef struct run_length_queue {
int* storage;
size_t capacity;
size_t head;
size_t tail;
size_t size;
size_t mask;
} run_length_qu... |
I have this really long httppost action results that I add and update 3 db tables I think it's too long and can get shorter and smarter.
public class AllVm
{
public AllVm()
{
this.wri = new Writer();
this.sub = new Subject();
this.rev = new Review();
}
public Writer wri { get;... |
I am working on a JavaFX application where the user through a series of textfields and dropdown menus has to create some sort of report. The data from the user are written in an .xml file, I also convert the .xml file to HTML and display it with the Webview class.
The following code is the save method I use to help th... |
I am pretty new to Python and I would like some tips and criticism on my formatting style/code and what can be better organized. I am a bit shaky on how classes work, but I think that it can be used here to make it more simple.
from tkinter import *
from tkinter import ttk
import random
#frame setup
main = Tk()
frame ... |
I have a ton of jQuery onClick events. onClick I hide/show different UI elements. I was wondering, how can I tidy the code up and make multiple onClick events more readable?
$('.info_2').on('click', function() {
$('#nav-wrapper').toggleClass('hidden_nav');
$('#card-wrapper').toggleClass('centre_share');
$('.E_inf... |
I am trying to solve a string matching question mentioned here. I recently learned the Knuth–Morris–Pratt algorithm and tried to implement it to solve this question. But I am getting a TLE for this code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Go... |
I wrote a program that manipulated data from VLA observations and created FITS files to be used in creating spectral energy distributions of high redshift radio galaxies. I really tried to be as efficient as possible. I made lists of the variables and lists I had to use. I looped everything where I could, but it still ... |
It is well known that 0 dependence implies 0 correlation, while 0 correlation does not imply 0 dependence. I have a paper here illustrating nonlinear correlation coefficients from relationship subsets of the joint distribution. I have another paper here demonstrating that dependence is the average absolute value of the... |
How can I achieve a more performant tick code keeping my minimum frame rate high?
installLoops() {
window.requestAnimationFrame(this.loop.bind(this));
}
loop() {
this.now = Date.now();
var delta = this.now - this.last;
this.last = this.now;
this.dt = this.dt + delta;
... |
I'm using some simple files for caching and some basic user data. I was first just using file_put_contents() and file_get_contents(), but realized this could quickly go wrong when traffic starts increasing.
I've been trying to figure out how to do it properly with flock(), correct file modes, etc, and come up with the ... |
I'm writing tutorials for new programmers. The tutorials show programmers how to structure events.
I've attached the code for one of the tutorials. Can someone take a look at my code and let me know if you see any bugs or gotchas? The goal of the code is to
be extremely easy to read and short
show a clear separation ... |
I'm looking for your opinions about ways to improve the access to data in my application. I develop web applications, using Entity Framework 6 code first, and Autofac for dependency injection.
Before you dive in the code, keep in mind that all components in my application (except for the problematic RepositoriesFactory... |
I'm working on a Clojure implementation for Project Euler #14, which asks for the initial element, under 106, that produces the longest collatz-sequence chain. I'm trying to make use of every optimization I know of, including transients and loop/recur. My code is based on a Lua implementation I wrote which runs in a ... |
I would like to write simple application where I'm going to make a few views:
Login
Register
Main app
I think that my method is not the best way to do this. Can someone give me a tip?
Main.java
package application;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import ja... |
My code asks the user for the type of conversion, the degrees and spits the result back. It will prompt the user to ask for the type of conversion again if it's invalid. It will also prompt the user to see if he wants to quit or rerun the program again.
I was wondering if there is a more efficient way of doing this. I ... |
I need help with a question my teacher wants us to do by tomorrow. I would love for you to try to help me out with this.
The following functions must be implemented:
A function that initializes all variables
Variables that keep track of which player is currently playing, and which player is next
Variables that keep co... |
Goal: make this code as efficient as possible.
Given a finite dataset (Colors - this isn't Crayola here :D) how do I know what colors are not assigned to a given user?
Additional requirement - the final result should output a single column of comma-delimited colors. Spaces do not matter, but it'd be nice.
This current... |
Note that this code is not going to be used for anything, it's more of a thought experiment. I've been seeing a lot of NumPy code lately and noticed that they use a custom indexing process, presumably by defining an object's __getitem__ method. I wrote the following class that allows for a multi-dimensional array to be... |
I currently have an HTML <Table> with all the socket.io-rooms. Client-side, the table gets fetched if you visit the page. If some room gets created or deleted, it get updated with the following code. There's also a button that gets updated to show if the room is full or not.
Now I want to know if there's any "better" w... |
This is a partially persistent data structure using a red black tree. It will copy \$O(lg(n))\$ items for each remove or add operation.
#pragma once
#include <functional>
#include <utility>
#include <iostream>
#include <stack>
#include <queue>
#include <memory>
#include <deque>
#include <iterator>
#include <type... |
I wanted to implement the cat function in Julia and I ran a few test cases but I am not sure if I am missing anything:
for line in eachline(STDIN)
write(line)
end
It's really simple code and I tested it with the following test cases:
$ cat hello.txt | julia cat.jl
first line
second line
third line
$ cat hello.jp... |
I recently have been working on moving from projects written in Java and C++ to C and realized that the lack of std::vector in C makes it a bit more difficult to create multi-dimensional arrays. Also, without the std::string in C, it's harder to store arrays of strings and keep track of their sizes. To automate the pro... |
Purpose
Validate whether the open brackets within a String have matching closed brackets, in the correct order.
The three types of valid brackets are
[ and ]
{ and }
( and )
Examples:
A[B]{C}(D) returns true
A[B{C}(D) returns false
Feedback
Creating a new Map of open brackets to closed brackets seems a bit expensi... |
Is there anything that I could have reworked here? I have a Java 7 mind but I'm working on getting my Java 8 ready, so if there are any improvements over readability of performance here I'd love to read
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
import java.util.regex.Patte... |
I have written code for generating all the permutations in C as explained here. How can the code be optimized? Are there any memory leaks?
int factorial(int n) {
int fact = 1;
for(int i = 2; i <= n; i++)
fact *= i;
return fact;
}
int main(){
int len = 4, i, j;
int **p;
int **q = (int**)... |
My context was basically to get my linked list implementation in C++ reviewed, since I wrote it from scratch and wanted to make it as simple as possible and learn from suggestions I get. I am trying to learn to create modular/re-usable, efficient (wrt time complexity), and yet simple code.
#include <iostream>
struct n... |
I'm currently working in the math library for a game framework that I'm writing and am working to improve some functionality that was affected during a refactor.
Formerly, my Matrix4.SwapColumns(int, int) function looked like this:
/// Documentation
public void SwapCols(int i, int j)
{
for(int k = 0; k < 4; k++)
... |
The idea is that I am getting the params from a GET request in the form of a Hash (symbol→str) and I want to transform them into dates and booleans. For that reason, I created two private methods to_date and to_b.
class Report
include ActiveModel::Model
attr_accessor :start_date, :end_date, :show_sales, :show_dail... |
The code is fetching records from a table called CSAT_SUMMARY_REPORTS[driver table] but due to the filters conditions applied which needs to be checked in another table called CSAT_REPORT_FIELDS.
In this table the filters are in different rows so a group_concat is needed to satisfy the ANDed filter condition.
Then it ... |
I created a program to get frequency of word in all files in a directory using Future API
import java.io.File
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
class GetWordCount{
def inFileCount(source: File):Future[Map[String,Int]]= {
val futureMap:Future[Map[String,In... |
I wrote a doge meme generator in racket some time ago, mainly as a joke, and I would like some criticism about the general style and what could be improved.
Here is how the program output looks :
plainDoge.jpg refers to a plain image for the doge meme (700 * 525)
#lang racket
(require racket/gui
racket/draw... |
I have been working on a simple calculator project in Java since November 2014 as hobby. Now I want to add complex number support and Matrices. I also wants to add support for symbolic computation in future. For this purpose I wrote a Literal class which is meant for to hold all types like Matrix class objects and Comp... |
I've just started with the basics of OOP. At first it looked complicated, but once I just started with it, it seemed so easy and everything seems to work like a charm, and that's why I'm unsure if I'm doing this right.
I'm creating a system to track actions:
This is the Timer class:
class Timer {
private $_db;
... |
There is this hackerrank question, where we need a rhombus of letters. As to my opinion it can be viewed as some fractal, or similar logic.
Well I solved the question, but I am obviously disappointed with the code I come up with. Actually when I started writing I knew how I would end-up and I was ready to ask a questio... |
I have the following code that converts a string that looks like aaa-bbb|ccc-ddd|eee-fff to two strings that look like aaa|ccc|eee and bbb|ddd|fff.
var id = "HEL-CAS|MAD-STO|XXX-YYY"
var splittedId = id.split('|');
var from = "", to = "";
$(splittedId).each(function(a,b) {
from = from + b.split("-")[0]+"|";
to... |
I'm a beginner in JavaScript and I want to improve my skills. I decided to write a simple application that adds a GUI to CanvasRenderingContext2D. I have just barely started and there are not many functionalities yet. I wonder however whether this is a proper way to write OOP in JavaScript? Will it be easy to maintain ... |
I've written a data type to represent a word
in the memory of a MIX computer.
A MIX word has a sign bit and five six-bit bytes.
So I created a data type and provided instances
for all the common numeric typeclasses
(that I could think of).
Some questions that came to mind:
A lot of my instantiations
use dependencies i... |
I am trying to grab the URL query of the URL which is in the browser's address bar, then append it at the end of the other URL and echo it to the browser.
So, if I visit my script at:
http://script.com/script.php?a=x&b=z
and the other URL is:
http://google.com/?c=v&d=u
then the browser will display:
http://google.... |
This is a for-loop which runs once for each step with i>1 and maybe for 0 <= i <= 1.
var i;
var prob_ = 3.5;
for ( i = prob_; i >= 0; i -= 1 ) {
if ( i > 1 || withProbability(i) ) {
loadHttp(randomUrl());
}
}
with
function withProbability(chance) {
return Math.random() < chance;
}
JsLint gave me a... |
I have a working code, but it has a lot of flaws.
The main project is to get a value from a website. I need to complete this action million of times, so i download the webpage returned from the class method, and parse it afterwards. In case the page is already downloaded i just open that one up.
This code is working, ... |
In my C# program I am using Regular expressions to:
Loop through a list of possible words in need of replacing.
For each word, to find out if a string I am given has any matches.
If it does, I perform some (slightly costly) logic to create the replacement.
I then perform the actual replacement.
My current code looks ... |
I wrote a todo app with JavaScript and want to have it reviewed to see if I can make it better.
I think my JavaScript is messy and can be improved a lot. Please share your thoughts and way to improve this (I think my JavaScript can be half of the code to do the exact same thing).
Here is my app.
var mainInput = docu... |
Task:
Create a class RPNStack which represents a stack of objects of type
Node. Class RPNStack contains only one private field top of type Node.
Objects of type Node represent data that are pushed on the stack: each
object contains in its field val a double and in field next a reference to
the next node (as in... |
Will the below code work for adding Weekdays in all possible scenarios?
eg, If I add 4 days to a "Thursday", the result should be next "Wednesday". Adding 1 day to a "Friday", "Saturday" or "Sunday" should be the next "Monday".
I am trying to get the nth working day (weekday) after a given day.
var addOneDay=function(d... |
I am working on a codebase that operates in the following manner:
/*=========================================
= Table of Contents =
=========================================*/
/*
00 - Initializer
01 - Summary
02 - Consumer Lead
03 - General Services
04 - Products
05 - Quote... |
I recently wrote the following code for a codewars.com kata for evaluating mathematical expressions. I've been writing ruby for years, but almost everything I do is for personal use and isn't shared, so I've gotten essentially zero feedback on my ruby style. The following block of code (with more comments than usual... |
HackerRank currently has '7 days of JavaScript' going, a quick intro into the JavaScript language. Every day a couple of challenges will be made available. One of the challenges of today was this:
Task
Write a JavaScript program to display the status (i.e. display book name, author name and reading status) of books. Y... |
What I'm ultimately trying to accomplish is a tool in which I pour some documents. Then I mark #x documents as desired and #y documents as undesired.
My tool now is to analyse and compare the documents and give me search strings that would find me many of the desired and few of the undesired.
What the code at hand is s... |
I have a method in which I am accepting a String clientid and that has below requirements:
clientid can be a positive number greater than zero. But if it is negative number or zero, then throw IllegalArgumentException with a message.
clientid cannot be a null or empty string. But if it is, then throw IllegalArgumentEx... |
I'm trying to reach good understanding of how to build scalable modular application structure. Recently I've been practicing with canvas and rewriting one of the popular snake game realizations. I've decided to try to split its code to modules. The codebase is not big and it seems to be a pretty nice exercise to me.
Th... |
Given is a list of pairs. I want to replace the second element of all pairs with the median of the second elements of all pairs with the same first element.
For example:
[("a",1.0),("b",3.0),("a",2.0),("a",4.0)]
->
[("a",2.0),("b",3.0),("a",2.0),("a",2.0)]
The order of the elements in the resulting list is not importa... |
This is the first time I've attempted writing something in bash, and would appreciate any feedback or criticism to make it better.
#! /bin/bash
macArr=( 0 0 0 0 0 0 )
for ((i=0; i < ${#macArr[@]}; ++i))
do
let "byte=$RANDOM%255"
# the first byte must have the least significant bits set to "10"
# in order t... |
VSDiagnostics has an analyzer that verifies whether or not a given identifier is following naming conventions. The following conventions are supported:
UpperCamelCase
lowerCamelCase
_lowerCamelCase
ICamelCase
On top of simply verifying this convention is followed it also suggests a new name that does follow conventio... |
Replace all c / C / v / V in stdin with lower case, upper case consonants / vowels respectively. All other input is passed through.
Anything that can be improved? Looking at maintainability first, performance second.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
static const char lower_c... |
I wrote a class to slightly customize the behavior of lxml.etree.ElementTree and I use it quite extensively. It works great, but there are a few methods that I'm not sure how I wrote, and there are a few other methods that seem awfully redundant. I'll elaborate on specific questions below, but first here's the code.
im... |
Below are a collection of classes that compose my buff/debuff system. The largest flaw in my design that I couldn't overcome is the base class Effect having an enum filled with the different types of buffs and debuffs. If there is a workaround that could clean up that part of the code I'd be really grateful. Otherwise,... |
I'm the proud owner of the Vitsy programming language, which I've been working on for some time (except recently, because high school). It's only been used in PPCG so far, but I hope to expand it to more useful things. It is a top-access-only 2-dimensional stack-based language that moves in multiple directions through ... |
To get a better understanding of objects/methods, I wrote a text-based, turn-based fighting game.
I want to expand by adding new characters with new moves (one of which can alter the way other moves works - I'm thinking of using Decorators for this).
Anyways, I'm open to suggestions, advice, constructive criticism, etc... |
Creating my first program in Swing and I was hoping to get some feedback. I'm looking for constructive criticism and tips for my swing code and my code in general. Don't really know what I'm doing so any advice would be helpful. The program is a simple text editor like notepad. Everything works the way I want it to so ... |
I have an array of nested objects:
[
{_id:1, parent:0, name:'Z'},
{_id:4, parent:0, name:'A'},
{_id:2, parent:1, name:'H'},
{_id:8, parent:2, name:'G'},
{_id:5, parent:4, name:'M'},
{_id:6, parent:4, name:'N'},
{_id:3, parent:1, name:'Z'},
{_id:7, parent:2, name:'L'}
]
I nee... |
This is revised code for the previous question: Object-oriented implementation of a real-world scenario of using a bathroom
Is there any object oriented way or design pattern I can use to make this code better? How can a User object access all private methods of Fitting instance?
This is inspired from HeadFirst Object ... |
I feel like there is a cleaner/simpler way of doing the following. Is there an existing software pattern that I should be using?
I have an Assembler class that I use to assemble/process content rules MS-Word documents.
There are many different types of Controls that are processed:
ClearCellIf
DeleteColumnIf
DeleteLine... |
I'm writing a function that returns all (nested) sequences reversed:
(defn my-reverse-v1 [input]
(let [head (first input)
tail (rest input)]
(if head
(conj (my-reverse-v1 (vec tail))
(if (sequential? head)
(my-reverse-v1 (vec head))
head))
[])))
(defn m... |
The question below came from C++ primer 5th edition.
Read a sequence of words from cin and store the values a
vector. After you’ve read all the words, process the vector and change
each word to uppercase. Print the transformed elements, eight words to a
line.
I was just wondering if there is any way to improve ... |
This question came from C++ Primer 5th edition:
Q: Read a set of integers into a vector. Print the sum of each pair of
adjacent elements. Change your program so that it prints the sum of
the first and last elements, followed by the sum of the second and
second-tolast, and so on.
I was just wondering if there is... |
I have an PHP endpoint used to mail me feedback or error logs from my sites here: https://github.com/kaihendry/vanilla-php-feedback-form/blob/master/feedback/feedback.php
<?php
switch ($_SERVER['HTTP_ORIGIN']) {
case "https://example.com":
header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.