instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I have written two Perl subroutines to flatten and unflatten a complex hash or array key. This can be useful in situation when you are traversing/parsing a complex data structure like JSON and want to store a given complex key to be later used as an index into a modified data structure. The reason for writing this, is ... | stackexchange/codereview |
Puzzle Question :
Giving 2 bottle of water. The capacity of the first one was 3 liter
and the second one is 4 liter. They are all empty at first : (0,0).
Each move only allow to do only one action at time.
Find out the move to get the second bottle have 2 liter of water and
the first one can be anything (not ove... | stackexchange/codereview |
I know there are countless questions on SO, and several articles on the web regarding this subject, but after looking at all the options, I was moved to write my own code to address my own requirements. However, this has raised a couple of questions for me that I would appreciate your valued input on.
First, the code:
... | stackexchange/codereview |
I'm creating a Django project where users can decide to delete their account and everything we know about them (solved riddles, votes ...).
I think you can compress this code but I don't know how.
I have a User related to Comment, Report, Vote, .... And I've got a Userprofile with a user relation:
class UserProfile(mod... | stackexchange/codereview |
I'm learning Rust, and I have a simple program that I hope to use as a learning exercise. My goal here is to get a better idea of the proper way of doing things.
I'm trying to use the fastq crate to do some manipulation of fastq files - these are simple text files that are standard for storing high throughput [DNA/RNA]... | stackexchange/codereview |
Working on the problem Find Winner on a Tic Tac Toe Game, I took several hours longer than an artificial time constraint the site had for mock interview purposes. This leads me to wonder if my solution is needlessly complex or unclear. Curious to hear from others. The only part that would have to stay the same upon rev... | stackexchange/codereview |
I am making a poker application in JavaFX. When I try to display the cards on the screen it is working perfectly fine. Yet I have a method with a lot of duplicated code in it.
I have tried to compress the code into 1 function with a for loop but I couldn't get it to work. Anyone has an idea how to get rid of the dupli... | stackexchange/codereview |
In perl, is there a canonical practice or idiom for assigning value to an argument which, if "empty", is assigned a default value?
Here, "empty" is defined as an argument value which is either undef or the null string (''). Notably, 0 (or perl false) is a valid, non-"empty" value, which rules out the construction $min_... | stackexchange/codereview |
I am sure this is not ideal code, basically I am checking a condition at a time and exiting if any of them are true. This will then disable refund functionality.
public bool ShouldChangeBookingBeDisabled(bool isLoggedIn, bool hasRefundedBookingsAtCinema, VistaBooking booking, SitecoreCinema cinema, ODataAttribute exper... | stackexchange/codereview |
I'm training my coding and wish you guys to see how my code is. I made a cat clicker based on the MVC pattern.
Basically it shows a list of cats and when you click a cat name it shows an image, and if you click the cat image it increments the number of clicks you made in the image and shows it. By the image there is an... | stackexchange/codereview |
I have some vanilla JavaScript for a website menu which works perfectly (thanks mainly to Titus on Stack Overflow), opening and closing a sub-menu (toggling <ul class="hidden"> ) if the UL's sibling button is clicked or closing the sub-menu if another button on the same level as the sibling is clicked, adjusting other ... | stackexchange/codereview |
I have a program that allows me to check (in a nicer way than using command prompt) what my ping will be when playing League Of Legends. I've implemented all of the elements that I had hoped, however now I'm simply looking for ways that my code can be improved.
I do have some gripes with my current code that I'm not ... | stackexchange/codereview |
I'm trying to write a function that given a TSV file will get the maximum line length found in a column. I currently have this (working) function. However, I feel that I am missing something as this solution feels poor compared to solutions I have seen to find the maximum length of a file:
max(open(filename), key=len)
... | stackexchange/codereview |
Inspired by this question, but hopefully not a duplicate.
I understand that the Law of Demeter is very useful in case of services interacting with other services, for example it's much easier to mock the other services in unit tests.
What about services interacting with data models, though?
Let's say I have a hierarchy... | stackexchange/codereview |
This is my first attempt at multithreading in C#. This entire program does several things with prime numbers, but the part I'm going to post is mainly focused with printing out all prime numbers starting at a high number all the way until it reaches 1. This was not originally intended to be a multi-threaded program, bu... | stackexchange/codereview |
Can this code be improved from an OOP paradigm perspective?
package JavaCollections;
import java.util.Iterator;
/**
* Dlist using sentinel node
*
* @author mohet01
*
* @param <T>
*/
public class DblyLinkList<T> implements Iterable<T>{
/*
* Representation - starts
*
*
*/
/**
... | stackexchange/codereview |
I was working on a code challenge with the following description:
Given an array of positive or negative integers
I= [i1,..,in]
you have to produce a sorted array P of the form
[ [p, sum of all ij of I for which p is a prime factor (p positive) of ij] ...]
Example: I = [12, 15]; //result = [[2, 12], [3, 27], [5, 15]]
... | stackexchange/codereview |
I have two functions, a collection of possible error codes, and a unit-testing framework.
The parsing of a character into its unary prefix and payload is handled by a few named functions and macros nlz, nlo, lsb and msb for counting leading zeros or ones and generating masks of ones on the right or left. The nlz functi... | stackexchange/codereview |
I have implemented a dynamic array based stack. Can someone point out any pitfalls or things that can be done better?
MyStack.h
#ifndef MYSTACK_H
#define MYSTACK_H
#include <iostream>
#include <stdexcept>
template<class T>
class MyStack
{
private:
T* m_array;
int m_count;
int m_max_size;
static ... | stackexchange/codereview |
I just finished working through Exercise 16 of Learn Python The Hard Way.
To further study, I wanted to create a script that will read and display a file's contents on screen, and then have the user re-write the file with three lines.
Can my code be written in a much cleaner, pythonic way?
from sys import argv
script,... | stackexchange/codereview |
I was trying to review state design pattern, and tried to create flexible implementation of it so it could reuse it in future.
So I came out with this:
public interface FsmState<S extends Enum<?>,INPUT> {
Result<S> action(INPUT input);
}
and this:
public class Result<S extends Enum<?>> {
public boolean isComp... | stackexchange/codereview |
I have a button that will validate the textbox for the service provider and the dropdown list for the locations. I have 3 tables: Locations, Service_Providers, and Service_Providers_Locations with a many-to-many relationship. But the tables that are affected are mainly Service_Providers and Service_Providers_Locations.... | stackexchange/codereview |
I have designed a basic interface for a smart mirror I made. I coded it to include the time, date, and several phrases that refresh every 24 hours. The phrases are just some random quotes as examples.
I was wondering if there were anyways I could streamline this code or even improve the layout of the interface.
import... | stackexchange/codereview |
I've written the following simple filter in Racket as my first Racket program and am wondering if I am writing it in an "idiomatic Racket style".
#! /usr/bin/env racket
#lang racket
(require racket/cmdline)
(define a-prolog-mode? (make-parameter #f))
;; parses the options passed on the command-line
(command-line
#:... | stackexchange/codereview |
I've created a project on Khan Academy as part of the Natural Simulations course on random walks.
This project is in JavaScript, using the Processing.JS library, slightly modified by Khan Academy.
(In the main, the inclusion of the Processing.JS library offers a few functions for drawing on a canvas. The majority of my... | stackexchange/codereview |
I am new to Python (and coding in general) and after about a week of reading "Thinking Like a Computer Scientist: Learning with Python" I decided to try and build a version the classic "guessing game". I added some extra features such as counting the number of guesses the user takes, and playing against a simulated "co... | stackexchange/codereview |
There are x distribution centers each with y number of products. Each day only an equal amount from all x distribution centers with remaining product can be shipped. Calculate how many days it would take to ship all product So, for an array [3, 2, 6] it would go:
[3, 2, 6]
[1, 0, 4]
[0, 0, 3]
[0, 0, 0]
== 3 days to s... | stackexchange/codereview |
I made a program that lets the user input text into a text box.
The user can choose a number to rotate each alphabetical character by that number,
and the output box will diplay the converted text.
Here is how it runs:
Among the code is
# if event.key == pygame.K_RETURN:
# print('\n'.join([''... | stackexchange/codereview |
I started implementing a graph drawing application in javascript and < canvas > element, and i just wanted to hear your thought on the progress so far. I'm very open to suggestions and i'm very interested to hear what you have to say.
So you can see the progress so far in the present code, if you have any questions abo... | stackexchange/codereview |
I made a rock climbing simulator game for fun. Below is a function from the program, which works. But I can't help but think it could be refactored or more pythonic.
Namely, I open the data with csv.DictReader and read through the data, which add to a blank dictionary called route_info. Is this step necessary?
The f... | stackexchange/codereview |
In the following answer, @Incomputable basically dared me to implement a generalization of std::minmax_element.
Have you thought about creating a search function that finds N elements based on N predicates, and return an std::array with the iterators to found elements? I just believe that std::minmax_element can be ge... | stackexchange/codereview |
I am a beginner so please keep it in mind while answering!
For player vs CPU is there any more effective way to make CPU better ??
import numpy as np
board=['-','-','-',
'-','-','-',
'-','-','-']
def check_win():
global winner
global game_over
if board[0]=='X' and board[1]=='X' and board[2... | stackexchange/codereview |
I am developing a web crawler application. When I run the program for more than 3 hours, the program runs out of memory. I should run the program for more that 2-3 days non-stop to get the results I need. How is this program using memory inefficiently?
seeds.txt
http://www.stanford.edu
http://www.archive.org
WebCra... | stackexchange/codereview |
The following code creates a list of questions and options from a multiline string.
import json
import re
text_string = '''
Question 1
### Consider the following figure:
Select one:
* **a. The optimal solution**
* b. An infeasible solution
* c. An Alternate vertex
* d. None of these answers
***The correct answer is: ... | stackexchange/codereview |
The following short program is a collection of routines for detecting the dependencies among a project’s component files. Dependencies serve as a rough measure of the complexity of a program. Minimizing inter-file dependencies is a worthy goal, since understanding and refactoring a complex program is often challengin... | stackexchange/codereview |
I'm trying to print out a list of files in a specific order, with files closer to the root directory sorted first. For example these files:
c:\users\steve\foo.txt
c:\users\bar.txt
c:\users\steve\desktop\file.txt
c:\users\john\bing.txt
Should be sorted as:
c:\users\bar.txt
c:\users\john\bing.txt
c:\users\steve\foo... | stackexchange/codereview |
I wrote a template class for a 2D vector that is intended to provide 2D vector arithmetic to be used in a Physics simulation program. Note that x and y are public or ease of use since encapsulation here would just decrease the readability of code that uses the class.
Is the general style of my code good and does it co... | stackexchange/codereview |
I am learning programming, and I am thinking how to improve this code in a more pythonic way.
I have a function with number of arguments. However, any caller of the function can specify the arguments, and depending on the arguments given, I will return the dictionary. The given arguments must be only from the listed ar... | stackexchange/codereview |
the Encoding scheme is given below:
Don't replace the characters in the even places. Replace the characters in the odd places by their place numbers . and if they exceed 'z', then again they will start from 'a'.
example: for a message "hello" would be "ieolt" and for message "maya" would be "naba"
how many lines of co... | stackexchange/codereview |
Given a sentence in 'bird language', where there are two rules:
After each consonant there is a random vowel added. For example if the consonant is "l" it will end as "la" or "le"...
After each vowel there are two extra vowels which are the same as the first. For example if there is a "u" it will end as "uuu"
Vowels ... | stackexchange/codereview |
I have this code, which counts only adjacent letters in a string and returns the count of each letter.
const inputData = [
'aabbc',
'xxxxvvhjh',
'PPPOM'
];
let output = [];
inputData.forEach(str => {
let strObj = {};
for (let i = 0; i < str.length; i++) {
if (strObj[str[i]] && str[i] === str[i - 1]) {
... | stackexchange/codereview |
I'm mostly concerned about edge cases, although I think I dealt with them all. Improvements on code quality would also be much appreciated.
/*
printRadian(90) -> π/2
printRadian(-90) -> -π/2
printRadian(180) -> π
printRadian(-180) -> -π
printRadian(270) -> 3π/2
*/
function printRadian(degrees) {
... | stackexchange/codereview |
I am writing code for the challenge given here . Below the text:
Each time Sunny and Johnny take a trip to the Ice Cream Parlor, they
pool their money to buy ice cream. On any given day, the parlor offers
a line of flavors. Each flavor has a cost associated with it. Given the value of and the of each flavor for tr... | stackexchange/codereview |
In the world of Binary Search Tree (BST) enthusiasts, where collecting and trading BSTs is a craze, you have a beloved BST with n nodes. In this scenario:
(a) Identifying Swapped Nodes and Common Ancestors (10 points):
Recently, a rival group attempted to steal your prized BST. Although you thwarted their attempt, they... | stackexchange/codereview |
Just finished an assignment in Python where one part was to write a function to find the correct rotation in a encryption similar to a Caesar Cipher..
As mentioned it's already finished and works as intended. The course is an introduction to Python, but I do have experience with other languages since previously.
I was ... | stackexchange/codereview |
I have a method which extracts the logged-in user details from a SpringSecurityContext object.
I have read that only utility methods (which does certain calculations) should be static.
Here is my method; it doesn't seem to be a utility method but I don't find any reason why I shouldn't make it static as I am using it i... | stackexchange/codereview |
I'm writing wrapper functions for some of the functions in <algorithm>.
While the following works perfectly, I'm not sure if this is the best way to approach it:
template<class ContainerType, class Predicate>
ContainerType filter(
const ContainerType& container,
Predicate predicate
) {
ContainerType filtere... | stackexchange/codereview |
I wrote a static method for an enum that returns the corresponding enum instance based on the source string, trimming any whitespaces and ignoring case as:
/**
* Convert the passed {@code source} string value to respective {@link SomeEnum} instance.
* Ignore any white-spaces present in the beginning/end of the passed... | stackexchange/codereview |
The third post in the Code Explorer series is about the UI and main VM.
This is the XAML, except a few hundred lines of styling:
<UserControl x:Class="Rubberduck.UI.CodeExplorer.CodeExplorerControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.micro... | stackexchange/codereview |
For my website needs I made a custom procedural MySQL function in PHP which can INSERT, UPDATE, SELECT or DELETE data from database. I would like a review and any suggestions for improvement or addition of new features.
function mysqli_database_query($sql, $values, $param = NULL, $result_param = NULL) {
require "db... | stackexchange/codereview |
I'm just beginning web design, and I've come up with this code to scroll to a place in the same page.
I don't know if this can or should be improved much longer, so I'm asking for any tips that can make this code better.
I know it's messy, but I will clean it later. I just want to know if there's a better method.
... | stackexchange/codereview |
This may seem like a lot of stuff? I just need help with 2 small parts the code works, however I have provided the rest of the info in case some one can help. USING PYTHON 3.4
Code below is responsible for comparing multiple CSV files against a
cross-reference file and creating a metadata file, information files, also ... | stackexchange/codereview |
We are using spring-batch to extract data from a SAP system, during processing we pass the extracted full texts to a tagging service, in the end the enriched documents are stored in Solr to be served to the user.
The problem during this ETL chain is that the tagging service is slow. Unfortunately we cannot improve its ... | stackexchange/codereview |
I'm learning PHP and I know too many ways to configure the application.
I use this method:
Folder:
app
config
app.php
db.php
src
class.php
index.php
File:
// app.php
return [
'environment' => 'development',
'meta' => [
'description' => 'Description',
'title' => 'Title'... | stackexchange/codereview |
I am trying to show the 6 most popular products on my homepage from left to right, in two rows. My code actually works... but I have the feeling I am making things way too complicated. Is there a simpler way to do this?
Here is my code:
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY popularity D... | stackexchange/codereview |
This is a python game that I am working on. It is a grid based treasure hunt game in which you collect coins from specific tiles (some tiles ask you questions in which you need to answer correctly in order to get coins), and after a number of moves the coins that you end up with are recorded and put in a file. At the m... | stackexchange/codereview |
I'm working on a new command line application in GO and was hoping I could get feedback on my design pattern, or suggestions on a better one to use. I'm still new to GO, only having used it for a handful of projects, and would value any suggestions to take better advantage of the "GO" way of doing things.
The intent of... | stackexchange/codereview |
Here is a code snippet of a class that I be interested to refactor. I was in doubt on how to proceed with the process of instantiation. The original ask was here. After think about it and heard some opinions I end up refactoring and splitting the instantiation in several constructors, one public and all others private.... | stackexchange/codereview |
I've designed a userform in Excel and it has many comboboxes and textbox inputs, once the user is done it puts ticks in appropriate columns depending on the ComboBox selection and also writes the value of the TextBox to the sheet.
At the moment I feel as though the sub could be refined but am unsure how to proceed as t... | stackexchange/codereview |
I am implementing a DP-based range minimum query data structure and algorithm in Python 2.7. Any advice on algorithm time complexity improvements, code bugs or code style issues are appreciated.
More information about range minimum query.
from collections import defaultdict
import random
def build_rmq(numbers):
rmq... | stackexchange/codereview |
I have written a simple application to monitor whether a couple of Java EE 6 web applications deployed to Glassfish 3.1.2.2 are accessible. My intent is to demonstrate to our operations team that the applications are intermittently inaccessible.
package monitoring;
import java.io.BufferedReader;
import java.io.IOExcep... | stackexchange/codereview |
As part of an assignment for my intro Java class (please bear with my beginner skill set), I'm working on a program for which a Die object class is used to play a Yahtzee game. An overview of the directions are as follows:
The program should give an introduction of what it is going to do, ask
the user how many dice ... | stackexchange/codereview |
I wrote the following hexdump generator function. How can I improve it?
FMT = '{} {} |{}|'
def hexdump_gen(byte_string, _len=16, n=0, sep='-'):
while byte_string[n:]:
col0, col1, col2 = format(n, '08x'), [], ''
for i in bytearray(byte_string[n:n + _len]):
col1 += [format(i, '02x')]
... | stackexchange/codereview |
Basically I need to order a list, so that an element is not the same as the element that comes after or before it. I searched for a solution but couldn't find one so I wrote this function myself.
For example, [1,2,2,3,1,3,3] should come out as [3,1,2,3,1,2,3], [3,2,3,1,2,3,1] or [2,1,3,1,3,2,3] and so on.
def unorder(a... | stackexchange/codereview |
I gave an attempt at reinventing the wheel and recreate list methods using my own Array Class to broaden my understanding about lists. I would like advice regarding efficiency, and in implementing negative indexes, since my code only works for positive ones.
class Array:
def __init__(self, List=[]):
self.a... | stackexchange/codereview |
For deleting a node in linked list I used 3 steps:
1)Finding the previous node of the node to be deleted.
2)Changing the next of the previous node.(to know what is next see my code it's fully explained).
3)Freeing up memory of deleted node.
But in place of data to be deleted ,0 is coming.I don't know what the problem i... | stackexchange/codereview |
I always read questions about a Windows solution to find a file in a directory structure like find and grep.
I created this working c++ program, where you give the program a path and a file name to find.
#include <iostream>
#include <string>
#include <sys/stat.h>
#include <windows.h>
#ifndef INVALID_FILE_ATTRIBUTES
co... | stackexchange/codereview |
I want to know is it possible to re factor my code in such a way to remove duplication of almost identical statements, bar the variable name and what it is initialized to by using methods. Here is the code in question:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridL... | stackexchange/codereview |
I am creating a template function with variardic arguments, to handle a specific classes that have some interface, method, member or whatever is specialized in a specialization area. However I came to a solution to handle even types that are not supported, thus avoid exceptions, polymorphism, virtual functions, RTTI, e... | stackexchange/codereview |
This code works by taking my user input and correctly pulling the information I'm giving it.
I'm having difficulty understanding the implementation of methods in classes. I'm pretty sure I'm not doing this the correct way. Can anyone show me the way it should be done?
class prog_setup:
def __init__(self):
"""Initi... | stackexchange/codereview |
In my app I have 3 components:
MovieSearchComponent to "house" the other 2 components
MovieSearch to search an API and retrieve the data
MovieResultList to display the data in the browser
Both components are wrapped in a parent container MovieSearchComponent.
My MovieSearchComponent looks like this:
interface Movie {... | stackexchange/codereview |
I want to use an std::array, but am operating on sufficiently large arrays that stack allocation is not reasonable (and fails using default stack size). I also needed a function that performed much like std::transform, but always in-place. The issue is that many of these transformations change the "type". All of these ... | stackexchange/codereview |
I have built a Blackjack simulator in Python. I need to decrease the execution time. I have used a profiler to identify key bottlenecks in the execution.
The following function is responsible for about 15% of the total run time.
def value(self):
value = 0
has_ace = False
for card in self.cards:
val... | stackexchange/codereview |
The problem statement:
Implement a stack which has push and pop method and also min method whereas min method has \$O(1)\$ complexity.
From an interview standpoint, what mistakes would you point out in terms of algorithmic design and other things?
#include <iostream>
#include <string>
template<typename T>
class sta... | stackexchange/codereview |
I have been reading about SQL injection and I want to secure my code.
I am not asking anyone to write me a code, but I just want to learn it in simple terms. The best way for me to learn is to edit my code so I can compare them.
<?php
if (isset ($_POST['email'])) {
//Connect to the database through our include
... | stackexchange/codereview |
The method is fully functional and creates an excel as expected.
What I would like to know, is if can be made more functional and better written for maintainability.
For example, how can I put the headers of the columns in that way to be separated to allow better readability and in this case be able to manipulate singl... | stackexchange/codereview |
I was writing some JavaScript that depended on several global variables being present.
I read about the "guard pattern" from a StackOverflow answer but since I need to check for multiple objects it quickly becomes quite tedious to have lines like this everywhere:
if (foo && foo.bar && foo.bar.baz) {
// access foo.b... | stackexchange/codereview |
I'd like to improve this code.
DoublyLinkList.java
public class DoublyLinkList<T> {
private static class Node<T> {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
}
public void displayNode() {
Sy... | stackexchange/codereview |
I had always had the necessity to display long text outputs on the console screen. The size of the text displayed usually exceeds the amount of text that can be accessed by scrolling up through he console output. Also, there had been times when I wanted to look at the output history, to spot out abnormalities or bugs. ... | stackexchange/codereview |
I made a simple C# library which detects incoming data from 1 or 2 scales plugged into a computer's usb.
My main concerns:
I feel like I should potentially be using events/delegates to process the data, but I'm not sure how to approach this so would appreciate any advice
My error-handling can probably be improved
The ... | stackexchange/codereview |
I have implemented few functions in C language that manipulate strings. These functions are not present in the standard C library.
string_library.c
#include <stdio.h>
#include <stdlib.h>
#include "string_library.h"
/*
* get_input_from_stdin_and_discard_extra_characters(char *str, long size):
*
* Function get_in... | stackexchange/codereview |
I have the following code, written in Python:
if id:
fields = r.table(cls._tablename)
.get(id)
.run(cls.connection())
else:
try:
fields = list(r.table(cls._tablename)
.filter(**kwargs)
.limit(1)
.run(cls.con... | stackexchange/codereview |
I wanted your opinion on the first RPG game I made in C#. What things can I improve on with the code?
Events:
static class Events
{
public static void SpawnWeapon(string weapon_name)
{
Console.WriteLine("\nAfter that fight you looted a weapon from the enemy party: {0}", weapon_name);
Player.Equi... | stackexchange/codereview |
I've an AbstractMessage object (a hierarchy, actually). It represents a small text message and can be sent using different transport methods: HTTP, REST and a "mailer" transport. Each transport relies on an external library for executing the transport itself, injected using a DI container.
Message itself may have diffe... | stackexchange/codereview |
Problem
Write a function to check whether two given strings are anagram of each other or not. An anagram of a string is a string that contains same characters ([A-Za-z0-9]) and the order of characters can be different.
Code
I've solved the anagram problem using a few methods with Python and JavaScript. If you'd like t... | stackexchange/codereview |
Original question: Node.JS Automatic Poem Generator
This is a followup to the question from above. I am only reposting, as my new code was written from the ground up, and is only slightly similar.
This code generates (sentences of) random poems.
// Node.JS/JavaScript Poem Generator
// This only generates simple senten... | stackexchange/codereview |
I have an ObservableCollection<MyType> ItemList, and I need to know the index of a specific MyType in the collection. However, when I hard-code the values like this:
ItemList.IndexOf(new MyType(val1, val2, val3));
it can't find the value because it is a different instance of MyType, even if all the values are the sam... | stackexchange/codereview |
Where I currently work I'm tasked with writing a good encryption and decryption code which will have DEK as well as KEK. Haven't started on KEK yet. I have already told them, that we need expert help, but I don't think I am going to get any. Any tips on KEK how to generate them and where to store them? (HSM ?) would be... | stackexchange/codereview |
My intention is to create an API as generic and DRY as possible using Go. To achieve this, I have made some more or less common decisions:
To use AJAX call to avoid reloading page when updating the web page. Instead of using Go.
To exclude hard coded queries from the API to reduce the endpoints (routes). As a bonus th... | stackexchange/codereview |
This code takes a YouTube video and download it. It supports only non-copyrighted videos due to YouTube's new algorithms.
Any thoughts about the structure and the logic? I would like to learn from my mistakes, I've just started coding with python.
#!/usr/bin/env python3.5.2
import urllib.request, urllib.parse
import ... | stackexchange/codereview |
Scenario: I (together with great help from SO) finished this piece of code which downloads attachments from an e-mail account (outlook) with VBA.
Issue: Given the internal functioning of the code, and the sheer amount of e-mails to check (more than 800k) the code cannot function in available time. Last time I tried to... | stackexchange/codereview |
Follow up to my question here: Constexpr circular queue
. I've taken the time to fix the many problems pointed out there and am asking for any tips/corrections for the new version below.
The queue will work with non-trivial types in non-constexpr contexts. For types that are trivially copy assignable and destructible, ... | stackexchange/codereview |
Problem
Currently my project utilises local caching wherever possible. There is a lot of similar looking code throughout that takes the form:
private static readonly ConcurrentDictionary<int, object> GetPMLocks = new ConcurrentDictionary<int, object>();
/// <summary>
/// Retrieve a PM by it's unique ID
/// </summary>
... | stackexchange/codereview |
I wrote a method that calculates the average and standard deviation of sell currency exchange-course (ASK). But I think that it isn't the easiest way to define such behavior.
In my opinion there is too much creating of BigDecimal values.
I have also doubts about using an ArrayList to get values in order to count stan... | stackexchange/codereview |
In connection with a job application I have to progress the following task:
Create a dynamic growing pyramid. The structure has to be sorted
alphabetically (concerning the inserted values).
It has to have the following controls:
Textbox for inserting texts (used by the blocks of the pyramid).
Button which ad... | stackexchange/codereview |
I like to unlist my old NuGet packages to keep my catalog clean. However, after a couple of uploads it's always a pain to remove each single package manually so I thought I write a utility for it in python.
It works like that:
query the service index for the search url
find my packages by author
extract package id and... | stackexchange/codereview |
I am trying to make logger class with debug, info, warn and error methods that "extends" basic log method.
However it is not written using DRY principle, how can I make it DRY, not WET?
Code snippet
const logLevels = {
0: 'debug',
1: 'info',
2: 'warn',
3: 'error',
'debug': 0,
'info': 1,
'warn': 2,
'er... | stackexchange/codereview |
Assume my users can subscribe to several plan_types. I want to define those plans as classes, and be able to keep, for each user, a reference to a subscription_plan and also a presubscription_plan. This is like a State pattern :
class Payment::SubscriptionPlan
def self.max_subscription_quantity
120
end
end
cl... | stackexchange/codereview |
I've been into trying to have an as simple as possible dependency container in Python and with your help managed to conceive TinyDIC, many thanks.
Now, I use Flask for my apps, and from by background with other languages I'm used to the idea of injecting dependencies into my controllers with the typical MVC frameworks.... | stackexchange/codereview |
Got this idea from the php.net website on extending exceptions. The main thing I wanted with this was to have the exception name auto imprinted on the exception message, so I wouldn't have to write it in each message. So far its working, just wondering if this is efficient or not?
Thanks
class DataException extends Exc... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.