instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I have a use-case where I want to iterate from the middle of an array outwards, so I generate a list of indices as follows:
import itertools
def array_indices_from_middle(array_len: int, num_indices: int = 16) -> list[int]:
"""
Create indices for an array starting from the middle and then appending indices al... | stackexchange/codereview |
I have a vector of ints that represents a point on a N-dimensional grid. I need to find all grid points that are within a given radius. I wrote the following, but it is rather inefficient, because it iterates through all points in a cube and checks the radius for each point:
typedef std::vector<int> VectI;
bool getNex... | stackexchange/codereview |
The design of my application consists of multiple viewControllers which all have different styling applied to them. The following code is used in every viewController to style the viewController:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.title = "PROFILE"
... | stackexchange/codereview |
I've written a piece of code, where a pair of checkboxes and a textbox are generated N amount of times. Depending on what's in the DB, the checkbox/textbox may have a default value or are left empty.
I've pasted the code below, could anyone take a look to see if I haven't created an abomination?
<td>
@if (singleIt... | stackexchange/codereview |
I solve this problem in Swift. I am looking for a code review, thanks!
Given a non negative integer number num. For every numbers i in the
range 0 ≤ i ≤ num calculate the number of 1's in their binary
representation and return them as an array.
class Solution {
func countBits(num: Int) -> [Int] {
var ... | stackexchange/codereview |
I'm trying to solve the N-Puzzle problem using IDA* algorithm with a Manhattan heuristic. I already implemented the algorithm from the pseudocode in this Wikipedia page (link).
Here's my code so far :
class Node():
def __init__(self, state, manhattan):
self.state = state
self.heuristic = manhattan
... | stackexchange/codereview |
I'm trying to create an observer pattern that the subject notifies the observers with different notifications.
Normally in observer pattern implementations you can see only one method called notify where it notifies the observers that something happened and has a kind of inversion where the observer holds the pointer o... | stackexchange/codereview |
I was working on the problem to check if the parenthesis are balanced using Scala.
Examples:
balance("(Hello (my) name is (StackOverflow))") -> True
balance("(Hello (my) name is StackOverflow))(((((((") -> False
The following implementation is working, however I'm wondering: What would you suggest to change in this i... | stackexchange/codereview |
As per the title, I'm making a webapp that is intended to use as a JS exercise platform. Problems are shown to users, they submit code, that code is run against a few test cases, and a report of the outcome is given back to the user.
I'm using Django for my backend, but to run the code I have also set up a node script,... | stackexchange/codereview |
I've posted the code for the following question. What could be improved?
Q: Write a program that allows the user to type in a phrase and then
outputs the acronym for that phrase.
Note: The acronym should be all uppercase, even if the words in the
phrase are not capitalized.
def main():
## input the phrase
... | stackexchange/codereview |
As part of my training, I implemented a n-body class in C++ to simulate gravitational interaction of bodies and to get more familiar with features that C++ offers such as object oriented programming.
This implementation uses a direct integration (Verlet integration) of the differential equations which results in a time... | stackexchange/codereview |
My goal was to write a factory that the code did not have to be edited. Thus I am registering my factory functions into a singleton factory. I am going to be using this code in Apache thrift server RPC system. I want to make the factory thread-safe.
#include <string>
#include <iostream>
#include <stdexcept>
#include <... | stackexchange/codereview |
Here's an example script I wrote for Instagram (Facebook)'s Basic Display API. I did this for myself because I haven't used Instagram's API since their Legacy API was disabled, and I needed to familiarize myself for upcoming projects. It's super easy to understand and is meant for learning purposes. It covers every fun... | stackexchange/codereview |
I am new to Java and I am trying to learn about optimizing code to make it production ready. I have the following code below. I would like to know how I could optimize it. I thought by using a small snippet of could, it would be a good way to learn.
Some points:
The function would be run many times to it needs to be f... | stackexchange/codereview |
Here is the task:
Create several classes of flowers that extend abstract flower. all fields -- random.
make a bunch of 20 different flowers
calculate the price of the bunch
sort bunch by freshness of flowers
find flowers with stalks in a certain range
find average level of freshness of the bunch
Solution:
publi... | stackexchange/codereview |
I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below,
def cumulativeTokenise(string: String): Array[String] = {
val array = string.split(" +")
var result: Array[String] = Array()
array.map { i => (
result = result :+ (
... | stackexchange/codereview |
Based on Node.js in Action (Manning Publications) chapter 2 "Building a Multi-room Chat Application", I've taken the model they presented (which is all typical ES5 and jQuery) and completely rewrote it using ES6 and adding a bit of functionality, as well as JSDoc throughout.
While the functionality is mostly identical ... | stackexchange/codereview |
This question is about reducing the size of files saved to disk in an infinite world 2D mining game.
I finally added code to my game to save and load distant chunks instead of keeping all of them in memory. Up to this point, I had only used the default NSCoding Apple library to save and load files from disk. In my ... | stackexchange/codereview |
Below is a problem from Sedgewick's Algorithms and my solution. Any thoughts or suggestions for improvement would be much appreciated.
Develop a class that implements the queue abstraction with
a fixed-sized array, and then extend your implementation to use array
resizing.
package chapter_1_3_bagsQueuesStacks;
i... | stackexchange/codereview |
This code was tested on IBM's 5-Qubit processor as an implementation of Grover's search algorithm, but for an unknown number of solutions. This code is based on Arthur Pittenger's book, "An Introduction to Quantum Computing Algorithms" and the mathematical structure was posted as a proof-verification question here.
h ... | stackexchange/codereview |
Code to find conflicts in a list of meetings given as input.
Meetings are defined as {startTime, endTime}. I am using a Greedy Algorithm to find the conflicts. Wanted to know if there is a more efficient way of solving this problem.
Example:
Input: `meetings[] = { {1, 5} {3, 7}, {2, 6}, {10, 15}, {5, 6}, {4, 100}}` ... | stackexchange/codereview |
Which of these three methods is better?
import java.util.* ;
public class anycode{
public static void print_digits3(int num){
//this method converts integer to string and parses it
int digit = 0 ;
String num_str = new Integer(num).toString() ;
int counter = 0 ;
while(counter != num_str.lengt... | stackexchange/codereview |
The Gilded Rose Kata is a refactoring challenge, in which some frankly disgusting code is thrown at the developer, and they're told to make a small change to it. For reference, the (truncated) requirements and the original code are given here:
All items have a SellIn value which denotes the number of days we have to ... | stackexchange/codereview |
Generate new password and send to user, if user is registered.
Two TextBox on page, txtUserName & txtEamil.
User can provide either UserName or Email to get new password.
If UserName is provided then find User on username, if exists then
generate new password and Email.
If user provided email then check if any user ex... | stackexchange/codereview |
Purpose:
Given a 2-Dimensional Array, return a copy of the Array. In VBA, if I just
Set newArray = oldArray
then newArray is simply a pointer to oldArray rather than an independent copy, hence this function.
Method:
Assign Array bounds. Create identically-sized Array. Iterate over Array and copy each element value.... | stackexchange/codereview |
I am not an expert in shell scripting,
I need help optimizing the shell script I wrote, This shell script I wrote is run by users on the client side who connect to our vpn server from the setting passed in the config.tar.
I check if pip or or tar or other packaches are installed if not isntalled than install it, I am d... | stackexchange/codereview |
I am creating a performant C# socket server. I'd like it to be able to accept as many simultaneous connections as possible. I've tested with 100 clients and all clients are fine. With 1000 however, clients begin to stop connecting. Is it possible to improve something to increase the number of simultaneous connections? ... | stackexchange/codereview |
Here is the part of working code:
function SelectPoints(lat,lon){
var dist = document.getElementById("miles").value;
xy = [lat,lon]; //center point of circle
var theRadius = parseInt(dist) * 1609.34 //1609.34 meters in a mile
//dist is a string so it's convered to an Interger.
selPts.length =0; //Reset the arr... | stackexchange/codereview |
I've been working around a solution to easily manage LTR and RTL on the same interface.
The different solutions I knew at first:
Override CSS according to direction.
Use a program to transform your CSS in LTR to a new RTL file.
Start from a body { transform: rotateY(180deg) }.
1. Override CSS according to direction
... | stackexchange/codereview |
Notes:
I know \ are against PEP8; they are for readibility
I created this working through a tutorial
I forgot to add blank lines, so it may be a little squished
''' Tic-Tac-Toe Minimax Program by Peter'''
#Tutorial found at: http://giocc.com/concise-implementation-of-minimax-through-higher-order-functions.html'''
... | stackexchange/codereview |
This is a "Help me make a choice" script where the user can input two options and then, based on the (3) reasons why they are good options, and the reasons weight the script will tell you which option you should choose.
This is my first Python script based on an idea I had and I'd like to know how I could make it bette... | stackexchange/codereview |
I have the following method that only checks if a Sqlite database has data, but I don't like how the code looks
private void comprobarColorActual() {
try {
if (cantidadRegistrosBodega() > 1) {
colorBodega.setBackgroundColor(Color.parseColor("#D5F5E3"));
}
if ... | stackexchange/codereview |
Here is the code I have written for a HackerRank challenge which takes multiple arrays, and attempts to determine if there exists an element in an array such that the sum of the elements on its left is equal to the sum of the elements on its right. If there are no elements to the left/right, then the sum is considered ... | stackexchange/codereview |
I have made two quite basic algorithms used for lossless data compression.
This is my RLE:
#include <string>
std::string rle(const std::string& input) // encode (aaaaeecd -> 4a2e1c1d)
{
std::string output;
int n = input.size();
int i = 0;
while(i < n)
{
int run_count = 1;
int max_r... | stackexchange/codereview |
Hi I'm implementing a few leetcode examples in Rust. https://leetcode.com/problems/flood-fill/
(looks to be same question as LeetCode: FloodFill C#)
The input is one matrix, a position and its new colour. The output is the modified matrix
// Input:
// image = [[1,1,1],[1,1,0],[1,0,1]]
// sr = 1, sc = 1, newColor = 2
/... | stackexchange/codereview |
I need to have some thread-safe event handler (like C#'s EventHandler), so I made one. Here is my event handler class and sample code (compiled with VS2013). Is this code OK to be operated in multithreaded environment?
#include <functional>
#include <memory>
#include <atomic>
#include <list>
#include <conio.h>
///////... | stackexchange/codereview |
I've written two functions:
is_integer(), which tries to get a positive or a negative integer as input and returns the same value.
square(), which takes this returned value as parameter and returns square of the same.
The code in square() uses a for-loop that squares the integer by 'repetitive addition.' Finally, the... | stackexchange/codereview |
I have started reading clean code and want to improve my coding practices. Here is my attempt at solving an online puzzle. Please review the code and let me know how could I have written it better in terms of logic, coding practices or any other advice you might have.
Problem Statement
Sherlock is given an array of N ... | stackexchange/codereview |
Learn You a Haskell shows the delete function.
delete: deletes first occurrence of item
ghci> delete 'h' "hey there ghang!"
"ey there ghang!"
Please critique my implementation.
delete' :: (Eq a) => a -> [a] -> [a]
delete' y xs = delete'' y xs []
where delete'' _ [] _ = []
de... | stackexchange/codereview |
Can you help me to optimize my code for the following problem:
An array of hashes named expected_tasks has tasks. Each task has a user that has to execute an action and contains fields.
The expected_tasks are related to the actual_tasks.
We want to execute the expected_task[action] on the actual_task["id]".
Therefo... | stackexchange/codereview |
I suspect that this can be done in a much neater way using list comprehension in python:
poses = []
for x,y in get_points(spline):
pose = Pose2D()
pose.theta = 0
pose.x=x
pose.y=y
poses.append(pose)
return poses
Is there a way to create a nice one liner for the above? (I do not have a constructor t... | stackexchange/codereview |
hackerearth.com practice problem Can you solve it?:
Given an array 'A' consisting of 'n' integers, find the maximum value of the following expression:
\$\lvert A_i - A_j\rvert + \lvert i - j\rvert\$
where \$A_i\$ is the element of the array at the i-th position (0-indexed array)
My solution:
def solve(n,l):
ans... | stackexchange/codereview |
I'm beginning to learn WPF and wanted to do a quick exercise. The code is as simple as it gets but I tried to evaluate each and every possible edge case. Any improvement is welcome, thanks.
C#:
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
namespace Calculator
{
///... | stackexchange/codereview |
Is this the most efficient way to write this piece of code? Is there a better way of handling errors inside of a while/for loop, instead of calling back to the original function? I have tried using break or continue, but it breaks the functionality of my program. Any help would be awesome, thanks.
## calculate binary t... | stackexchange/codereview |
I'm learning Lua. I decided to make a simple plain PPM decoder/encoder without error checks to familiarize myself with the language. I would appreciate any feedback on how could I make the following code simpler, shorter, more elegant and readable.
-- Load/save plain PPMs without error checking; img[img.w][img.h].r=img... | stackexchange/codereview |
I've been developing a simple CMS both for practical use and learning about Laravel, and I decided to implement a simple service that makes it possible for the administrators to send messages to one another. However, the finished JavaScript code, while completely functional, ended up being a bit sketchy so I'm looking ... | stackexchange/codereview |
My code works, but it looks very bad.
I need to move .xlsx files from the previous days from one folder to another, but I should'nt move the files with today's date, just the files from previous days.
In my current code, I am moving the files by specifying each one of them with a Minus X days, but I think the code is n... | stackexchange/codereview |
I'm wondering if there is a way to make my code more efficient? Perhaps by using loops or something similar?
I have posted the code below. Please tell me how I can make it more efficient.
P.S.: I'm new to Java programming so no hate please :)
final TextView textview = (TextView) findViewById(R.id.textView);
final Text... | stackexchange/codereview |
I am new to "modern" Javascript, and I am reviewing some code from a frontend contractor. I'd like to make the sequential code more descriptive/procedural.
The following code is a from a file called build.js, which is used to start a new project build (via Webpack). I guess we could call that a "build script" of sorts:... | stackexchange/codereview |
My latest inspection for Rubberduck determines whether a procedure should be a function by checking whether it has a single ByRef parameter (either explicit or implicit). The quick fix takes this procedure, changes it into a function, and updates all calls.
This inspection starts deep down, involving the parser:
priva... | stackexchange/codereview |
I have created a DSL for AutoMapper using an F# Computation Expression Builder. The Computation Builder itself is fairly simple, and effectively defines 5 basic operations: map to map from a field in the source to a field in the destination, value to use a specific value for a field in the destination, ignore to igno... | stackexchange/codereview |
I am relatively new to Python. I've so far mostly worked with PHP and C#, so most of it is relatively familiar.
I'm making a simple console application that will store a few API calls in a local database through a cronjob. It will have a timeout, so if the program is run too often it won't spam the API and use up all ... | stackexchange/codereview |
I implemented a binary search algorithm using recursion in Java
package com.soloworld.binarysearch;
/**
*
* @author soloworld
*/
public class BinarySearch {
private int[] array;
public BinarySearch(int[] array) {
this.array = array;
}
public int recursivesearch(int[] array,int startindex,in... | stackexchange/codereview |
I made a small script to read text file that contain hexadecimal and convert to another file in decimal by using command-line as a filename input.
#this is content from hex.txt
0x5B03FA01
0x42018360
0x9FF943B3
and this is what I expected my python to deliver output
#this is content from hex_1.txt
1526987265
1107395424... | stackexchange/codereview |
I have several tabbed views with a Unity scene in them. What I do between scene is hide the elements in that scene, then render them if the right view is shown.
The method below is the method that renders all the lines previously drawn in my view. The lines can be lines, angles, points, etc..
private void RenderLine... | stackexchange/codereview |
I thought of a simple way to hash a string. By taking the ASCII decimal value of each character, multiplying it by 10, and adding all of the values computed together for each character in a string. Is there a name for this algorithm? I highly doubt I was the first one to think of this.
Compiled with gcc -Wall -Wextra -... | stackexchange/codereview |
I'm only two weeks into learning Java and just finished creating my first program. I have a feeling I've added unnecessary things, but not sure. I'd like someone to take a look at it and let me know if there are ways to simplify or approach the code. Basically, I'm just trying to create a simple GPA calculator.
impor... | stackexchange/codereview |
To execute tasks sequentially with a timeout I use ExecutorService.submit() and Future.get(). As I don't want to block calling clients, I implement producer–consumer pattern with a queue into a Thread while(true) loop:
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import j... | stackexchange/codereview |
I've written a script which parses name and price of different items from craigslist. Usually a script throws error when it finds the name or the price is None. I've fixed it and it fetches results successfully now. I hope I did it flawlessly.
import requests
from lxml import html
page = requests.get('http://bangalore... | stackexchange/codereview |
The code is self-contained and self-explaining. I want to improve the goal function. You can change everything below the -- My solution line as long as behaviour of goal :: Goal function is preserved and there is no explicit recursion. Basically I need to rearrange Strings from Graph in a Definition tree using children... | stackexchange/codereview |
I recently had a need to convert a TrueType font to a Game Boy tileset, so I wrote a program to do it.
This correctly aligns the characters on an 8x8 plane and outputs in the form of RGBDS-style GBZ80 assembly.
Needs the FreeType library installed; use the Makefile (or copy the commands) to compile it.
drawtile.c:
/*
... | stackexchange/codereview |
I have two functions to find the number of factors of a given number.
I was wondering which one will be more efficient to use?
def nu_of_factors2(n):
return len(set(reduce(list.__add__,
([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def nu_of_factors1(n):
result_set = set()
... | stackexchange/codereview |
I am currently developing a framework to facilitate writing controller programs for scientific instruments. I use attrs extensively in the internal parts of the code. I have some parts of the code which exposes classes to be derived from, but I don't want to call @attr.s in the beginning whenever I derive a class. I... | stackexchange/codereview |
The scenario is as follows. The API of my program will allow the user to perform some method on a particular element (let's say a tuple from a database). If this parameter is not passed to the function, then the "default" behavior is to look for a list of elements (from a database query, for example) and to act on all ... | stackexchange/codereview |
This is a project that grew out of the React Tutorial
and is one of my first efforts at solving React problems on my own. There is a lot of code
here and I am sure that there are more concise ways to have completed aspects of this project.
Any suggestions, insights or positive comments would be greatly appreciated.
... | stackexchange/codereview |
I have a list of dictionaries x and a list of random numbers x_randoms. I want to update each of the dictionaries with the values from the list of random numbers. I've done the following and it works, but it feels a bit strange:
import random
x = [{'key1': '123', 'key2': {'key2.1': 500, 'key2.2': True}},
{'key1':... | stackexchange/codereview |
I need to build something that is not very complicated, but efficient. I don't have much time to debug.
I don't know if this method is strong enough to encrypt a data to be displayed in a Qr code.
It will be compiled in Qt.
#include <botan/botan.h>
#include <botan/aes.h>
#include <botan/kdf.h>
#include ... | stackexchange/codereview |
I'm new to akka and would like to get some feedback on my first attempt. The code takes text from stdin and finds the top 10 most frequently occurring words.
Specifically, I would like to know
Is passing the wordFrequencyAccumulator to the tokenizer a reasonable thing to do? Are there better alternatives?
Is the use... | stackexchange/codereview |
I have built Python objects to simulate a one-to-many relationship and then store the object in a MongoDB instance. I am using lots of composition to achieve what I want. The code works perfectly fine but I get the feeling that the overall design can be improved a lot.
The problem statement
Each Portfolio can have zer... | stackexchange/codereview |
I have the following simple program which calculates and returns the nearest power of 2 of a given number. Because I use increments and decrements to find the closest power, this takes a very long time when working with higher numbers. Is there any way to reduce the run time of the program when working with larger numb... | stackexchange/codereview |
Here we trying to fix logs that have overlaps with each other. Am I doing it right? Is there any way to improve/refactor it?
DROP TYPE IF EXISTS logs_with_error;
CREATE TYPE logs_with_error AS (
model_id INT,
model_type TEXT,
initiator_id INT,
initiator_type TEXT,
error_type_id INT,
... | stackexchange/codereview |
Not really an issue I am stuck on (the code works) but I just really don't like some code I wrote, if you're bored in lockdown maybe you might like to help.
Context:
I am import some data from a spreadsheet, it contains data about retail stores (grocery stores). As the data comes in from the spreadsheet, each row is st... | stackexchange/codereview |
I have written a small plugin for nagios to check a WebDAV server. It is supposed to connect using a username and password and upload & delete a test file
This is my code:
#!/bin/bash
#Exit codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
FILENAME=/tmp/test_monitor
FILE=test_monitor
HOSTNAME=$1
USERNA... | stackexchange/codereview |
I had the need to prefix the price for certain product categories on only the shop page (because the price can be higher depending on extras that the customer might want).
These were my requirements for this code:
Add the prefix only on the shop page, not on the product page;
Only add the prefix to certain (hardcoded)... | stackexchange/codereview |
This code is used to toggle some dropdowns. I've added the click event on the document to close the dropdown on click outside, but I'm not sure if I'm doing it the right way. I want it to be optimized for better performance.
Let me know if you have a better way to bind/unbind the events.
$('.header-top-bar .toggle').ea... | stackexchange/codereview |
The following function calculates temperature based off of a given suction pressure, where different regression coefficients are assigned depending on the value of the pressure.
The regression equation is fairly standard, of the form:
$$ax^2 + bx + c$$
where \$x\$ is the pressure, and \$a\$, \$b\$, and \$c\$ are the co... | stackexchange/codereview |
I frequently use MathJax, and often I need to write matrices. Since writing matrices using MathJax is very tiresome task, I decided to automate it.
Code:
import numpy as np
import pyperclip
class Conversion():
def __init__(self, matrix, n = None, m = None):
if matrix == None:
self.matrix = n... | stackexchange/codereview |
I am specifically looking for input on naming ModifierCalculator and Modifiers. I would also appreciate input on whether ModifierCalculator should extend EnumMap instead of having it as a field.
These classes are for modifying the status of units. The StatType enum contains different types of ..stats, such as "life", "... | stackexchange/codereview |
Previous review of this project:
Card Deck class for a Poker game - version 2
This time, I considered combining both classes into one header file so that I can reduce my use of #include and to keep them together. I also did this so that I can define my const std::string variables only once for both classes. However, ... | stackexchange/codereview |
Task description:
Implement a generate_unique_phone_numbers function.
The function shall parse the given text-file.
Content-example:
Trinidad Kemp,(838) 352-2212
Noel Bush,(647) 477-7093
Claudette Davila,(686) 868-8153
Shaun Mcbride,(433) 380-7556
Katy Blanchard,(792) 460-2468
...
Then return a Set with unique phone-n... | stackexchange/codereview |
I wrote a piece of code to generate a list of \$n\$ Happy Numbers, would love to see how I can write it better. More information below.
#a happy number is defined is found by taking a number, and adding the sum of its digits, and repeating the steps to add the sum of square
#of the resultant digits until we reach 1, if... | stackexchange/codereview |
I have the following htaccess and I want it to be the perfect htaccess for my website so that it uses less bandwidth and meets the requirements of a good SEO.
I am on an apache server and my files are html, php, js(minified and normal), css, ttf fonts, images.
How can I improve this htaccess file?
RewriteBase /
Rewrite... | stackexchange/codereview |
I recently studied SkipList and thought I would create one on my own. This implementation uses a 2 layer `SkipList where the size of the support list is roughly square root of the size of the original list.
package skiplists.skiplist;
public class SkipList<T extends Comparable<T>> {
private SkipNode<T> start;
private ... | stackexchange/codereview |
This is the script I need to speed up.
Things that I have already done to speed up are:
Using single quotes instead of double quotes wherever possible.
Created Database Index
Replaced queries containing 'select' * with 'select column_names'
It takes around 1.7 seconds per URL on average. I want to know if this can be... | stackexchange/codereview |
I was trying to write an iterative search function for my Ternary Search Tree class based on a pseudo-code, and now it seems to work, but I think it can definitely be improved.
def search(self, key: str):
return TST._search(self.root, key)
@staticmethod
def _search(node: TSTNode, key: str):
"""Note that node.k... | stackexchange/codereview |
I have a HTML5 range slider. i.e. <input class="range-slider" type="range" id="points" name="points" min="0" max="220">
I am showing, hiding, and changing some content based on the selected range slide values.. with Vanilla JS, I have all my functionality logic done, but I hate how much code it is. Is there a better, l... | stackexchange/codereview |
I'm trying to implement an Hmac in T-SQL using this question as an guide. Please critique this:
create function dbo.Hmac (
@key varbinary(8000)
, @message varbinary(7936)
)
returns table
with schemabinding as
return (
select HashBytes('SHA2_256', Pads.o + HashBytes('SHA2_256', Pads.i + @message)) as [Hash]... | stackexchange/codereview |
This is a student module marks calculator that I was asked to write for a uni revision session in year 2.
Is this a good example of modern C++ code? Is there anything I can improve on or need to change to become a better programmer?
#include <iostream>
#include <cstdlib>
float student_results[5][2];
unsigned int inpu... | stackexchange/codereview |
Feeder is in charge of returning an array of items rated by users (feed). If there is a watching user (current_user), the Ratings should be from all users being influencers except for a watching user.
Scroll is given by a gem. It gives a cursor for each rating so that infinite scrolls will work.
I see this pattern quit... | stackexchange/codereview |
This fairly clunky looking VBA script successfully pulls names of countries from an Array, but could it be made shorter?
Mass of text from Column C onward in each row may contain the names of countries, which I want to pull into the corresponding cell in row A. What I have so far is not pretty...
Sub PullCountries()
Di... | stackexchange/codereview |
I'm trying to implement a simple name search using elasticsearch and a java app as the client.
Schema:
{
"firstname": {
"type": "string",
"analyzer": "standard"
},
"lastname": {
"type": "string",
"analyzer": "standard"
},
"fullname": {
"type": "string",
... | stackexchange/codereview |
I'm developing a C# Poker app and I currently use the modulus and the divide operator % , / and dividing by 4 because there are 4 cards of the same type but with different colors. The deck of cards for playing Poker consists of 52 cards. I start counting them from 0. If we take the cards starting from Ace up to King, w... | stackexchange/codereview |
function scramble(str1,str2) {
let result;
for(let i = 0; i < str2.length; i++){
let found = str1.match(new RegExp(str2.charAt(i)));
if(found === null){
result = false;
break;
} else {
str1 = str1.replace(found, "");
result = true;
}
}
return result;
}
The purpose of ... | stackexchange/codereview |
I am making a to-do tree application (Earlybird) in Python that will show checkable tasks/subtasks in a tree view. It includes higher-level groups of tasks grouped into blocks (e.g., Work block, Home block) that do not have checkboxes.
It looks like this:
This is is my first application using Python, and object-orien... | stackexchange/codereview |
I have written a basic PHP upload script a few years ago and recently I discovered some phishing html pages in the website's root.
This website is located in /www/sitename, while I upload the files to /gstorage/sitename, which can't be accessed from the web.
I have found a lot of html files in /www/sitename and it see... | stackexchange/codereview |
This code checks if string has correct format for passing to struct. Correct format needs to be [123456789'\t'First Name'\t'Last Name'\t'City]. I didn't know how to enter tabs, so I used '\t'. I use them to separate different word blocks so e.g. first and middle name can be read to a first name in struct.
I wrote alter... | stackexchange/codereview |
I have a list of categories (in this example I used String but in my project I have a model) which must be sorted like this:
on top we should have 2 categories which have a fixed position in the list (in this example (C, F))
at the bottom of the list we should have 3 categories which have a fixed position in the list ... | stackexchange/codereview |
While answering this question on SO I came up with a very simple solution and I wanted to know if there were improvements that could be made to it.
The function takes an array of participants as inputs, generates a list of pairs using the array of participants with an associated score (to be generated by a function com... | stackexchange/codereview |
I am trying to improve my Rust coding skills. One thing which I find hard to tackle is how to shift from a polymorphism you can observe in e.g. Python to sth. similar in Rust?
Let me give you a specific example. I would like to implement a very simple Graph (undirected graph) and DiGraph (directed graph) structures in ... | stackexchange/codereview |
I have turned a "classic" Bootstrap form into a "floating labels" form.
For this purpose, I had to move the labels below the form controls.
.form-control:focus {
box-shadow: none !important;
border-color: #c4c4c4 !important;
}
.with-floating-label {
position: relative;
}
.with-floating-label label {
positio... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.