instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
Given multiple sorted integer vectors, the goal is to merge them into a single vector and eliminate duplicate values. We've already achieved some improvements over the most simple approaches, but overall the operation is still very expensive and we're not sure if we're missing something, there must be a way to perform ... | stackexchange/codereview |
I've been toying with Haskell again and implementing a simple text replacement program that replaces all consonants c in a text by coc, i.e., inserting an 'o' in between:
> robber_simple "abcdef"
"abobcocdodefof"
This is rather simple to implement:
robber_simple :: [Char] -> [Char]
robber_simple [] = []
robber_simple ... | stackexchange/codereview |
I've used the UK Plug -> US Socket and US Plug -> UK Socket analogy. I've also made it possible for UK plug to use a UK socket and a US plug to use a US socket. The output of the SSCCE below is
UKPlug -> UKSocket
USPlug -> USSocket
UKPlug -> UKUSAdapter -> USSocket
USPlug -> USUKAdapter -> UKSocket
And the code
packag... | stackexchange/codereview |
I want to collect my users' data as an array:
h = {}
a = [["user_3", 765], ["user_1", 2], ["user_1", 1], ["user_2", 124],["user_1", 3], ["user_2", 223], ["user_2", 334]]
# Expected output :: {"user_3"=>[765], "user_1"=>[2, 1, 3], "user_2"=>[124, 223, 334]}
a.each do |x|
if h.keys.include?(x.first)
h[x.first] = (... | stackexchange/codereview |
Write a function named maxOccurDigit that returns the digit that
occur the most. If there is no such digit, it will return -1. For
example maxOccurDigit(327277) would return 7 because 7 occurs three
times in the number and all other digits occur less than three times.
Other examples:
maxOccurDigit(33331) retur... | stackexchange/codereview |
I'm developing backend for my mobile app by using gin-gonic and gorm ORM (mysql). But I'm not sure api and db handle huge amount requests if clients increased. for example I'm using my db struct as parameter, is this a problem for concurrency ?
Here is my implementation:
main.go:
var i Impl
func main() {
// #GIN... | stackexchange/codereview |
For studying Scala, I wrote some code to solve the Equal problem on HackerRank. But I am stuck on test case #15 due to timeout.
Christy is interning at HackerRank. One day she has to distribute some
chocolates to her colleagues. She is biased towards her friends and
may have distributed the chocolates unequally. O... | stackexchange/codereview |
I'm writing a script that deals reads UTF-8-encoded XML files and writes parts of those files into a tempfile for further processing.
Sometimes, the input files will have a few malformed characters. If it's just "a few" occurrences, I want those glossed over, but if the file is majorly corrupted, I want to see an error... | stackexchange/codereview |
I'm relatively new at programming in general including Python. But I've tried to create a program in Python that alerts users through a pop up window to perform an action every 2 hours.
import time
import ctypes
count = 0
print "This break message was sent on "+time.ctime()
messageBox = ctypes.windll.user32.MessageBo... | stackexchange/codereview |
I would like to create a grammar for the Conventional Commits spec and I would love to hear any feedback for what I wrote.
The spec has some ambiguities, I think, hence my usage of "island grammars" to avoid writing predicates and such, which would limit the parser to a certain language target.
An example of a conventi... | stackexchange/codereview |
I have two worksheets in my workbook. The first worksheet ("home"), the user will enter information in cells B7-B14, not all of the fields are required in order for the macro to proceed.
I need each of the aforementioned fields to be copied over (in addition to B18-B28 & B31-B34) onto the second worksheet ("tracking")... | stackexchange/codereview |
The PHP manual states that the regular shuffle() function isn't cryptographically secure, but that random_int() is. I thought, then, that I'd make something to leverage the latter for the former purpose. (PHP 8.2 includes Random\Engine, which includes a shuffler, but I wasn't aware of that when I started thinking about... | stackexchange/codereview |
I just converted procedural code to OOP code. Is there any performance or security issue with this code or what should I consider further?
interface
interface IContactform {
public function validate();
public function addcontact();
public function getcontact();
}
Implementing class
class customercon... | stackexchange/codereview |
This function takes a list, deletes every occurrence of the number 13 and deletes the number present after 13 in every instance and then prints the sum of the list.
How can I shorten it?
def average(nums):
thirteen_idx = []
bad_idx = []
final_list = []
num_length = len(nums)-1
#list of indexes where 13 res... | stackexchange/codereview |
I've written this whole code to extract cell numbers from a website. It is extracting numbers perfectly but very slowly, and it's also hanging my Form while Extracting.
Imports HtmlAgilityPack
Imports System.Text.RegularExpressions
Public Class Extractor
Shared doc As New HtmlAgilityPack.HtmlDocument()
Public Shared ... | stackexchange/codereview |
create or replace procedure upsertTrackingItemMetric(
p_template_id number,
p_jobDef varchar2,
p_metric_type varchar2,
p_metric_value varchar2
)
is
PRAGMA AUTONOMOUS_TRANSACTION;
sig_att_id number := null;
sig_grp_id number := null;
tims_id number := null;
const_error_metric_id NUMBE... | stackexchange/codereview |
So I have this function that lets one traverse through a tree without having to get the root node of the tree. The user basically sends a parameter that is either Movement.LEFT or Movement.RIGHT that specifies where to move to. It then returns the current node it is on. If the current node is a leaf, the tree traversal... | stackexchange/codereview |
After sticking with the same handful of languages for years, I decided to learn C.
I've written a guess the number game, where it generates a random number based on the difficulty level, and then you have 5 attempts of guessing the number.
If you guess incorrect, it will give you a clue by telling you if the answer is... | stackexchange/codereview |
The function tests whether or not the provided string is a palindrome, and the main function just times how quick it is (after all, C's supposed to be quick, right?).
header.h
bool palindrome(char *text);
main.c
#include <stdio.h>
#include <time.h>
#include <stdbool.h>
#include <string.h>
#include "header.h"
int main... | stackexchange/codereview |
I just completed BNR's bronze challenge for disallowing alphabetic characters, and would love some feedback on what I did right and wrong, and how I can improve my code for reusability and maintainability.
Here's a snippet of instruction from their book, iOS Programming: The Big Nerd Ranch Guide (5th Edition) (Big Nerd... | stackexchange/codereview |
I wrote a program that uses a pipe to send messages from a parent to a child.
Question: Is this the correct way I sent the messages? Could I have done otherwise? What can I improve?
my code:
//Parent/child processes communicating via a pipe
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(int argc, c... | stackexchange/codereview |
The mission:
Zero Trim
Write a function which trims multiple zero's sequences to a single zero digit. The
return value is the updated array. You are not allowed to use another array,
and you need to implement it with one pass over the array. In other words, each
element in the array should change its index only once du... | stackexchange/codereview |
I'm doing a prototype of server API calls in my Ionic (Angular) application. I'm considering this use case:
@IonicPage({/* */})
@Component({/* */})
export class SomePage {
constructor(private api: Api) { }
ngOnInit() {
this.api.user.getList();
}
}
To achieve this I have something like this:
@Injectable()
ex... | stackexchange/codereview |
Follow up to Selection sort with reduced comparison count - semi-final Iteration?
My goal (and excuse not to tag reinventing…) is to have presentable code to argue the viability of reducing the number of comparisons used by selection sort (for readers not necessarily versed in the implementation language chosen).
In th... | stackexchange/codereview |
Building linked list abstraction using class 'list' data model.
##################
# Linked List #
##################
#Representation - start
empty = 'empty'
def is_link(s):
""" s is a linked list if it is empty or a (first, rest) pair."""
return s == empty or (isinstance(s, list) and len(s) == 2 and is_l... | stackexchange/codereview |
I'm new to both GTK and Haskell, so I'd appreciate any in both. I'm making an application which for the purposes of this question is just drawing a window that shows a red circle getting larger until it touches the edges of the window.
I have a CircleGUI.hs module which defines the following functions:
module CircleGUI... | stackexchange/codereview |
To Collect or Hash
The VBA.Collection has a number of limitations, but it is enumerable and you can refer to items by index or key. But the VBA implementation of a Collection is 1-based, and they don't have any way of confirming membership, and the Item method returns a Variant, so they're loosely typed. Did I say Item... | stackexchange/codereview |
To avoid the overridable method call in constructor dilemma this approache delegate the variables initialization and calls to overridable methods to a member method that return reference to the instance its self and exception to be thrown if trying to use instance without invoking the initialization method/s so that th... | stackexchange/codereview |
I decided to resume my (limited) Python skills after not coding for a long time.
Here's a very simple self-contained program to convert the characters of an email address into their HTML entities (the purpose is to make the email invisible to spamrobots).
Any comment for improvement? (e.g. args parsing, code style, ... | stackexchange/codereview |
This is a Yahoo Finance wrapper to get income/balance statement for a stock ticker. What I have tried to do is make an abstract implementation so more features can be added easily in the future. The base-class YahooFin
contains methods to get and beat the data into shape so it easily can be put into a pandas DataFrame.... | stackexchange/codereview |
I have written a script that sits on the admin portion on my website.
Here I assume the user is valid as I have code that checks that already.
The below code is checks if the user is Admin. If they are Admin they will be flagged with a "Y" on the database (this will be a "1" for optimization later but for sanity's sak... | stackexchange/codereview |
About Data: 3D data (100x100x20).
Computation/Formula and Method: I am trying to compute the sum of squared differences along rows, columns and angles for various time differences.
%% Grid and time paramters
%# Grid parameters
nRows=100;
nCol=100;
InitLag_Row=0;
InitLag_Col=0;
InitLag_Ang=0;
LessLags=20;
nLags_Row=nR... | stackexchange/codereview |
I am new to using interfaces and abstract classes. The team I am working with came up with an implementation of what they call a base class that will be implemented by all view model classes. This is what they came up with:
public interface IBaseViewModel<T>
{
#region public properties
string Message { get;... | stackexchange/codereview |
I currently have a module with Class / Methods I want to use in other scripts. Recently chess.com released a read-only REST API for beta-testing. The methods in my class build a URL for the API endpoints I am interested in and get the JSON data for me to work with in other scripts.
It is worth noting that I am fairly ... | stackexchange/codereview |
Exponential Search is an optimization over binary search.
Conceptually, when searching for a number target in a list of numbers nums, exponential search first finds into which power-of-two sized bucket nums[2**p: 2**(p+1)] the target falls into. E.g., if nums has a size of 30, then the buckets are nums[0:1], nums[1:2],... | stackexchange/codereview |
I'd like to get a general review on the following code, and I'll highlight an extra point below:
public interface PlayerAction {
boolean isActionAllowed(final Player player);
void performAction(final Player player) throws PlayerActionNotAllowedException;
}
public class PlayerActionNotAllowedException extends... | stackexchange/codereview |
This is my 2nd program I wrote on my own, a pretty simple program consisting of two functions (those functions are not combined in any way yet though). The first function moves the display times of subtitles saved in .srt files by a specified amount of time.
The second function "warps" the display times by a specified... | stackexchange/codereview |
The below code is working correctly, however, I am not sure if the combination of while, foreach and implode is really necessary here or if the same can be achieved much simpler.
What I do here is fetching some data (text) from a db and the only thing I need is the results as a comma separated string.
Now even though t... | stackexchange/codereview |
My code is attempting to implement FP in an efficient / readable manner into some of my video games. I realize this may be a bit subjective, but I feel there is enough merit / objectivity to be of benefit to the community.
Why I'm asking for a review:
I'm not sure that my code is executing FP / procedural principles in... | stackexchange/codereview |
I have completed this assignment from Stanford CS108 on MySQL and Swing (it's part B). It would be wonderful if someone could point out my weak spots in the code and overall design.
I have uploaded code on GitHub.
Task:
In this part of the assignment you will create a GUI-based (Graphical
User Interface) applicati... | stackexchange/codereview |
The point of my code is to:
Read in the observed data from the a catalog of stars (whitespace separated table).
Do some unit conversions on the observed data (math stuff).
Apply an interstellar correction factor to the observed data (more math).
Compare the scaled observed data to the DUSTY model data using the BC tab... | stackexchange/codereview |
The purpose of the data-structure is to manage person-objects.
Persons can be added at any time. But the order can't be changed afterward.
Only the deletion of a person is possible. Represents the case of cancellation.
The whole thing is intended to be as simple as possible.
Nevertheless: I'm thinking about an additi... | stackexchange/codereview |
The Task:
The user enters a path to a dictionary file (one word per line) and a phrase as system arguments. My code must then find phrases containing only valid English words, generated by removing one consonant from the user's phrase.
I wrote this as part of an effort to learn Rust, the task is copied from a piece o... | stackexchange/codereview |
I'm the the process of adding change auditing to my existing DB class which encapsulates database calls.
Previously I would just pass in a String and a SqlParameter array but now I've added the class 'DBData' to contain the values required for the auditing.
I'm not sure whether passing in this DBData object and then ca... | stackexchange/codereview |
Take a look at the following function:
std::vector<double> get_data(
std::vector<double> const &data,
double const t,
double const x)
{
std::vector<double> result(data.size(), 0.0);
double const
A = func(t, x),
B = func2(t, x);
std::transform(std::begin(data) + 1, std::end(data... | stackexchange/codereview |
I have had a hard time understanding all the documentation on the logger module and forking processes.
My goal is to have each child process that's worked to write to their own separate log file.
This seems to work but I just want to try and verify that this is the correct way.
import os
import logging
def generate_p... | stackexchange/codereview |
I've created a UserScript for adding follow-up reminders to any post (question or answer) here on the Stack Exchange network. I did this in response to a stackoverflow meta post feature request which sparked my interest.
It adds a calendar icon into the vote cell which displays a datepicker where you can select a remin... | stackexchange/codereview |
I studied segment tree recently and I made this code of segment tree and its queries. Is my code correct in terms of time complexity?
class segmentTree{
private:
vector<int> mini;
vector<int> tree;
vector<int> maxi;
int n;
Here in the constructor I passed the dynamic array.
public:
segmentTree(vec... | stackexchange/codereview |
I have an assignment to create a method to retrieve the proper day of the week for any given date, without using the Java calendar. After countless hours of trying to implement the algorithm in the outline, I've finally finished it and it appears to work! I feel like it's really sloppy. Any tips on how to clean it up ... | stackexchange/codereview |
I just started learning programming in the past two or three months. I started with Python, and now I'm learning lua. I started game programming this week and this is a game I made with the Love2D engine for lua. If you don't know how it works, there are these three main functions:
love.load() -- Runs at game startup... | stackexchange/codereview |
I received feedback that my code was convoluted and written with very bad practices.
Our tutor said explicitly that I should never write the code like that.
I'm just trying to wrap my head around the general concepts of object oriented programming.
I would be very thankful for pointing out what I did wrong, so I can be... | stackexchange/codereview |
Background
I'm writing code for an 8-bit MCU with very limited RAM (1KiB) and program flash space (64KiB). I have a C++14 capable compiler with no standard library implementation available. This is a good enough excuse for me to do some recreational template programming. :)
In the project where I intend to use this I n... | stackexchange/codereview |
Here is a namespace for wrapping boost accumulators for use in a broader code base. I love these accumulators but re-typedefing them everywhere is ugly and a pain.
I am not interested in C++11 alternatives. My code base does not put the starting bracket on a new line. My code base uses doxygen. Most of the style choice... | stackexchange/codereview |
I am using NodeJS and MongoDB for a weather app that takes the weather info from a logger, saves it to a database, and relays the data to the browser in real-time. It is hosted here with code here which has project details and explanation.
I am saving the weather data to the mongolab cloud-db like so:
// Save to cloud... | stackexchange/codereview |
I'm trying to learn x86 assembly and hopefully move on to projects of the scope that more than one person would be involved.
This is a (relatively) simple subroutine written in Intel x86 assembly using MASM that copies one string onto the end of another. I named it strglue to avoid conflict with the C library function ... | stackexchange/codereview |
I recently came across this problem that asks you to print the number of leaves not eaten by the caterpillars:
As we all know caterpillars love to eat leaves. Usually, a caterpillar
sits on leaf, eats as much of it as it can (or wants), then stretches
out to its full length to reach a new leaf with its front end, ... | stackexchange/codereview |
I need to create an structure to control dynamically locks. For example, I have 100 threads running, and each thread will "process" a "key". Sometimes two threads could be processing the same "key", and if it occurs, a dynamic lock needs to be created and used by both, to process one at a time.
I create the following s... | stackexchange/codereview |
I have a durations as such:
[{'duration': 3600}, {'duration': 3600}]
And I want the output to be {3600: 2}, where 2 is the number of occurrences of 3600.
My first attempt is use a loop, as such:
var count = {};
for (var d of durations) {
var length = d.duration;
if (length in count) {
... | stackexchange/codereview |
I have a model section with a column parent_id - the only thing identifying a parent/child relationship. I wrote a helper method to output all sections, all their possible subsections and include their "depth".
This is the helper method:
# Calls itself for each section recursively to fetch all possible children
def fet... | stackexchange/codereview |
Just saw this at work in a code review and was wondering if this style of coding - for loop, doing && like that, seems fine to you or is there a better way of doing the same?
for (int j = 1; j <= ETtop; j++)
{
// Check everything.
int k = ET[j].PriIdx;
for (int z = 1; z <= ET[k].ArgTop; z++ )
{
... | stackexchange/codereview |
I've coded a function which uses a map and creates a random way between two points. Startpoint is always 0/0 and the goal is somewhere else everytime on the map.
Now I'd like to know if I could change anything to make that function more efficient or use another function.
But I need to create random ways and not the fa... | stackexchange/codereview |
I'm trying to determine I missed something here since python isn't my native language.
Python app starts
Python creates a cert.pem and key.pem running this command pem openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
Python sets the flask secret key to a per instance generated uuid
Fla... | stackexchange/codereview |
Application context
I am working on a game I call "Apes and Snakes". So far the code only allows players to connect to a host using a room code and WebRTC. Players and the host send messages back and forth to each other over WebRTC. When a player receives a message, it is passed to a "handler". This kind of pattern is ... | stackexchange/codereview |
I tried to solve the simple problem of generating all permutations of length n with m distinct elements where repetition is allowed. Doing this recursively took me like 10 minutes:
void genAllPermsRec(vector<int>& perm, vector<vector<int>>& perms, int n, int m) {
if (perm.size() == n) {
perms.push_back(perm... | stackexchange/codereview |
This is my code which implements Nd vectors. I chose valarray as a base of the class. Is this a good idea or I simply need to make a typedef std::valarray gvector instead of writing a class?
Please review this code.
//gvector.h
#ifndef GVECTOR_H_
#define GVECTOR_H_
#include <cmath>
#include <fstream>
#include <iostrea... | stackexchange/codereview |
I have a task connected with reinforcement learning. The state of my environment is described with the class below:
from dataclasses import dataclass
from typing import Tuple
@dataclass
class LearningState:
pre_cross_densities: Tuple[int]
global_aggregated_densities: Tuple[int]
phase_no: int
phase_dura... | stackexchange/codereview |
How do I make these line of codes more scala-ish (shorter?). I still get the Java feeling in it (which I want to stay away from).
import scala.collection.mutable
val outstandingUserIds: mutable.LinkedHashSet[String] = mutable.LinkedHashSet[String]()
val tweetJson = JacksMapper.readValue[Map[String, AnyRef]](body) ... | stackexchange/codereview |
This is something that I am proud of and would like to have people dissect and tell me where my faults are in. I feel that if I open my best for criticism then maybe it will reveal the deep seeded bad habits in my coding.
I know about the null format for the frame in the main class is not kosher. So, please skip over t... | stackexchange/codereview |
This is a simple real state based markov chain (I'm using real states instead of a markov matrix to enable making an animated version later).
My goal was to make the markov chain as generic and reusable as possible, while practicing using smart pointers.
What general coding style, performance, semantic, or functional i... | stackexchange/codereview |
I wrote my implementation to Queue Linked List based. And I need a review for it to improve it and improve my coding skill. I also will put this implementation on my GitHub account.
//======================================================
// Author : Omar_Hafez
// Created : 30 July 2022 (Saturday) 8:02:31 AM
... | stackexchange/codereview |
I started writing a script to handle my file downloads in osx because they quickly pile up and it gets time consuming to do this manually by drag and drop. I am looking forward to get some feedback.
require 'filewatcher'
require 'pathname'
require 'fileutils'
class FileAction
def initialize(filename, event)
@fi... | stackexchange/codereview |
In order to keep the fragmentation ratio of indices low, you should re-organize the indices from time to time on MSSQL. Microsoft describes in the link below how you can check the fragmentation of indices on tables in MSSQL and then how you can re-organize (re-build) the indices to reduce the fragmentation percentage:
... | stackexchange/codereview |
Is it right to put this code, inside this class, like this?
playlist = QMediaPlaylist()
url = QUrl.fromLocalFile("music.mp3")
playlist.addMedia(QMediaContent(url))
playlist.setPlaybackMode(QMediaPlaylist.Loop)
player = QMediaPlayer()
player.setPlaylist(playlist)
player.play()
from PyQt5 im... | stackexchange/codereview |
We record software builds from our build machine into a database and for practice purposes I'm building a little web dashboard for it.
The API is REST (WebApi) and provides access to query for Products, Branches, Profiles and specific Builds.
The controller queries all products (each product contains a list of branches... | stackexchange/codereview |
I'm looking for some general tips on code practices, doing things properly in idiomatic pythonic way. But mostly I want to know if this was build correctly. I tried making neural nets in the past, but failed horrible, but this one seems to be working fine.
The backpropagation method is still not developed because I sti... | stackexchange/codereview |
This exercise is called PDF Paranoia and it comes from CH 15 of the book Automate the Boring Stuff With Python - second edition. There are two parts to the exercise, which I've separated into two Python files. The code I've provided uses Python 3.10 and PyPDF2 v. 2.10.0.
The instructions are as follows:
Using the os.w... | stackexchange/codereview |
In my method I have something like this:
returnValue = null;
if (!string.IsNullOrEmpty(pa.Phone))
{
if (pa.Length != 10 && member == Schema.Phone.Name)
{
returnValue = new stuff;
}
}
if (!string.IsNullOrEmpty(pa.OtherPhone))
{
if (pa.OtherPhone.Length != 10 && member == Schema.OtherPhone.Name)... | stackexchange/codereview |
Solved one of the easiest problems from acm.timus.ru.
1001. Reverse Root
The input stream contains a set of integer numbers Aᵢ (0 ≤ Aᵢ ≤ 10¹⁸).
The numbers are separated by any number of spaces and line breaks.
A size of the input stream does not exceed 256 KB.
For each number Aᵢ from the last one till the first one y... | stackexchange/codereview |
I wrote this snippet:
template <typename ContainerT>
class ReverseIterator
{
public:
ReverseIterator(ContainerT& iContainer) : m_container{iContainer}
{
}
typename ContainerT::reverse_iterator begin()
{
return m_container.rbegin();
}
typename ContainerT::reverse_iterator end()
... | stackexchange/codereview |
What do you suggest to make this code faster? This code gets all possible combinations of actions for a certain number of stocks in pairs in the format [action, volume]. One action element would be something like [[action1,volume1],[action2,volume2],[action3,volume3]] where the actions are either 0 (i.e. Sell) or 1 (i.... | stackexchange/codereview |
I have a set of functions to run according to combined options. Options are easier/harder, add/multiply, wait/nowait, 1/-1.
You can see the whole module here.
For now I have put all functions in an object to be able to access them according to the options. For instance:
var stair = {
down: 3,
sameStairCount: 0,
s... | stackexchange/codereview |
So currently I have this basic little chat bot that can read commands and can timeout users if their message contains a banned word or phrase. I was wondering how I can improve on this bot to be able to !add "word" to the set of banned words and overall general flaw improvements.
import string
from Read import getUser... | stackexchange/codereview |
I am working on an MVC solution. My DAL layer I could solve with Repository classes, everything is working great.
But in my BLL layer I have repetitive code:
My CRUD is the same, my fields and consructor are different.
I can also have some extra methods.
Is there a way to solve this properly?
Class 1
public class JobT... | stackexchange/codereview |
How does the following look for a json lexer? Are there any things that can be improved upon? Does the pattern look general-purpose enough to be able to generalize it to make it into a useful program, beyond just my personal tokenization of json?
import re
TOKENS = [
# (name, regex)
('OPEN_BRACE', r'{'),
(... | stackexchange/codereview |
I've implemented selection sort, heap sort, insertion sort, and iterative quicksort using C++11. Am I using the correct STL data structures/algorithms? Am I using move semantics correctly in my code?
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <iterator>
#include <utility>
#in... | stackexchange/codereview |
I want to arrange async server-client communication with websockets and vanilla flux architecture. There is an excellent article about "Async Server-Side Communication with the Flux Architecture". I gonna implement it analogue with SockJS and ES6 promises:
ActionCreator.js - it's the same but moved to ES6
import * as c... | stackexchange/codereview |
I've recently helped fellow SOFer to answer his question here: Routing in my PHP MVC framework
Then I thought
Hey, why not improve this code and put in my snippets library.
This is what I came up with:
/**
* @author Gajus Kuizinas <g.kuizinas@anuary.com>
* @copyright Anuary Ltd, http://anuary.com
* @version 1.0.3... | stackexchange/codereview |
I made very simple interpreter in C and now, I want to make my code better.
Here is my code:
#define size_t unsigned long long
int printf(const char *format, ...);
int scanf(const char *format, ...);
void *memmove(void *str1, const void *str2, size_t n);
size_t strlen(const char *str);
int main()
{
char ch[50];
... | stackexchange/codereview |
I've just created my first set of related classes in React and would like to get feedback from more experienced React developers.
I've used ES and completely vanilla React. The application is a shopping cart where the cart item quantities update the totals.
The one file situation is because it didn't seem to like multi... | stackexchange/codereview |
I have created a contact form that originally did not have any mechanism for sending out the email with whatever the user inputted in the fields. I have added it in here along with ReCaptcha check. I would like to get some feedback on the code, and I am especially looking at upgrading the email body to send out emails ... | stackexchange/codereview |
I have a C# application and a CakePHP website. These communicate between them using GET and (WebRequest) POST method.
My problem is that it's happening too fast. I have made a diagram that shows some statistics. I retrieve the data from the website using GET method (XML file), such as:
https://www.my-website-link.com... | stackexchange/codereview |
Why after declaring a variable for String array, it can be passed to a method that accepts object array? Now, String is a class by itself so I assumed a long time ago that all variable is object at a sense. But many argued with me about it. But here it shows the same kind of behaviour.
Below is given the code where the... | stackexchange/codereview |
I have written this piece of code that implements the double factorial in Python both iteratively and recursively; the code works without problems, but I'm interested in improving my overall programming style. Here's the code:
def semif_r(n): #recursive implementation
if n == 0 or n == 1:
z ... | stackexchange/codereview |
I am working on an application in which I have to parse an XML file. Nodes of the XML file corresponds to an object. I have to populate the properties of the objects at run time. The code below queries the metadata of property and sets its value. Is there a better way to do it or is there a better way to map the elemen... | stackexchange/codereview |
I just finished implementing a Java 2 player CLI chess game, it involves player putting in commands (i.e "move e2 e4" to move or "attack d1 d5" to capture.).
I am trying to follow OOP, SOLID and clean code principles as much as possible.
Initially I designed this with the idea of MVC with the current implementation try... | stackexchange/codereview |
I have created a script to generate 5 random codes, check if any one of them exists in the database, and if not, insert the record. The script will throw an exception if a single code could not be generated.
The rationale is that of an arbitrary 5 random codes, at least one should be unique. If not, throw an exceptio... | stackexchange/codereview |
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... | stackexchange/codereview |
So I'm trying to implement the following problem in a couple of different languages to get a rough idea of how different languages work & feel. I'm completely new to C, and this is the first code I've cobbled together using the C reference and Google/SO.
The problem is this:
Generate a list of n random doubles in (0, ... | stackexchange/codereview |
Is this a smart method?
public static ArrayList<Integer> getWordLengths( String s )
{
String str = " " + s + " ";
ArrayList<Integer> list = new ArrayList<Integer>();
for ( int i = 0; i < str.length(); i++ )
{
if ( str.charAt(i) == ' ' )
{
for ( int j = i+1; j < str.length(... | stackexchange/codereview |
Relatively new to C++. Please help me understand the potential issues with the following blocking object pool.
#pragma once
#include <vector>
#include <queue>
#include <memory>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <future>
#include <functional>
#include <stdexcept>
template <typena... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.