instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I recently finished a high school project of mine for a class revolving around creating my own multithreaded implementation of the "cp" terminal command in UNIX systems.
I am seeking for help by experienced people in C to help me make my code better, offering constructive criticism all while improving myself at the sam... | stackexchange/codereview |
I have two types that don't share any interface but have similar properties and that I need to compare for equality.
One of them is comming from a 3rd party library and one of them is mine. I obviously cannot add any interface to the foreign type and honestly I don't want to create any wrapper for both of them in order... | stackexchange/codereview |
I have just started trying to learn Haskell and tried to think of a practical, but simple problem to try and solve. I have a strong background in C, but am just beginning to dip my toes in the world of functional programming.
The idea came from my investing in notes on Prosper: given a list of note ratings, and a des... | stackexchange/codereview |
I inhereted an implementation of a singleton template. Althoug I read that singletons are bad, my program uses singletons throughout and I can not get rid of them at the moment.
This is the implementation I started with:
template <typename T>
class Singleton
{
public:
static T* ms_singleton;
Singleton()
... | stackexchange/codereview |
The code below copies large amount of data. It does so in 2 steps. I was wondering if both step1 and step2 can be done in parallel.
<#
The code below copies from a network fileshare to another share in the same location but to a different folder.
Robocopy is used to do the file move of all the old files tha... | stackexchange/codereview |
The following function is supposed to return the points p1 on line segment a, and p2 line segment b, such that |p1 - p2| is minimized.
point_pair get_closest_points(line_segment const& a, line_segment const& b)
{
auto const intersect = intersection(extension(a), extension(b));
if(line_segment::valid(intersect.a... | stackexchange/codereview |
Several people who work with Rust have said that if you find yourself using a lot of clones, you're probably doing something wrong. I'm trying to rewrite some code I wrote to find the maximum number in a 2D vector to use RefCells for the inner vector due to the fact that (as much as I hate it) I need interior mutabilit... | stackexchange/codereview |
I created this little JavaScript application which gets data from a post request and uses this data to show a line chart with the total income over a year and a bar chart for the daily income. The data comes as a JSON object.
For example:
dates:["01.01."],["02.01."],["03.01."],...
dailyBudgets:[3],[1],[2],[6],...
tot... | stackexchange/codereview |
I came up with 2 different solutions in Java.
First one is:
public static void main(String[] args) {
int[] array = new int[]{10,3,4,6,1,9,10,0};
int sum=0;
for (int i=0;i<array.length;i++)
{
for (int j=i ; j<array.length;j++){
sum = array[i] + array[j];
if (sum==10){
... | stackexchange/codereview |
For learning purposes I am trying to make a encrypted chat in Python using Websockets. I am using AES and RSA to make it safe.
The idea of the chat is that it's a group-chat. Users can join a chat by running python3 client.py --password=pass123.
This is how it works.
The server has already generated a RSA keypair.
The... | stackexchange/codereview |
Can I use #define fori(i,n) for(int i=0;i<=n;i++) in Java?
And of course, Java doesn't have precompiler so we cannot do that in java. So I thought we can do that fori method either using stream() or manually defining a method. But I thought instead of just traversing why can't I put the third parameter as lambda expres... | stackexchange/codereview |
How can I refactor this?
public static IQueryable<T_COMPANY> WhereTotalTransactionOrShowCaseAtLeast(this IQueryable<T_COMPANY> query, int minimum, DateTime? date = null)
{
if (date == null)
{
query = query.Where(company => (company.Products.Count + company.References.Count) >= minimum ||
... | stackexchange/codereview |
I know this is extremely trivial, but would you call the extension method below Remove or RemoveMany? Please provide justification.
public static void Remove<TEntity>(this DbSet<TEntity> set, IEnumerable<TEntity> entities)
where TEntity : class
{
foreach (var entity in entities)
set.Remove(entity);
}
-... | stackexchange/codereview |
I had this interview question like a year ago and was asked to code, on a piece of paper, how to reverse each word of a string. Since I am used to Java, I proposed the obvious answer of using split + reverse, which are native commands in Java. I was then told I couldn't use those, so I floundered and ended up with a ... | stackexchange/codereview |
I have an Android app with three different Activity classes. Each of the Activities uses and changes config and user-customization data stored in a wrapped SharedPreferences. The code could stand some refactoring, so I'm thinking that rather than have each Activity instantiate the SharedPreferences by calling Preferenc... | stackexchange/codereview |
Program description:
You are given a set of two functions: $$f=x^3-6x^2+x+5; g=(x-2)^2-6$$
Plot them using Matprolib on a user input segment [a; b].
My solution:
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interpolate # for smoothing
def func(x):
return [pow(x, 3) - 6 * pow(x... | stackexchange/codereview |
The following code is a Node-based Netlify plugin to generate Content-Security-Policy rules based on inline styles and scripts.
Inputs
buildDir - a string for setting the build directory.
exclude - an array of file paths to exclude from processing. (defaults [])
policies - an object of policies in camel case, for exam... | stackexchange/codereview |
This is a school project I've written. It works, but I feel it could be done better.
The program generate an array of 1'000 random numbers, and searches for a number typed into console, and displays the index if found.
int inp, zuf, i, num, trig=0;
const int amount = 1000;
int arr[amount];
cout << "Numbers" << endl <<... | stackexchange/codereview |
I'm following up on this question. I made a few decisions about my model and implemented recommendations accordingly.
TL;DR the link
Uses a loop algorithm to return a Fibonacci number \$Fn\$ of any given ordinal position \$n\$.
Changes
I'm now using a BigInteger type to avoid Integer Overflow. I can now return an ar... | stackexchange/codereview |
Recently, I perform re-factor on one of my frequent used custom enum, by removing its getter.
My rational for doing so it.
The enum's custom fields are immutable
Only use getters when it is necessary.
Less typing. Reduce verbosity.
This is a very stable class, with only 17 commits, since 2008. Its getters behavior ha... | stackexchange/codereview |
I had an exercise to solve, written in German. I try to translate it:
Write a program that takes an amount of seconds. The program than has to output the number of years, days, hours and seconds.
My Solution
public class Main {
public static void main(String[] args) {
final int HOUR_IN_SECONDS = 60 * 60;
fi... | stackexchange/codereview |
I am writing a function where I can take a string as input, and then find the even number of substrings. The final result is the first longest even length string is returned by the function.
For example:
Input -> It is a pleasant day today
Output -> pleasant
For example:
Input -> It is a day today
Output-> It
(Since th... | stackexchange/codereview |
I'm trying to reach good understanding of how to build scalable modular application structure. Recently I've been practicing with canvas and rewriting one of the popular snake game realizations. I've decided to try to split its code to modules. The codebase is not big and it seems to be a pretty nice exercise to me.
Th... | stackexchange/codereview |
The Application
I have an application in testing that runs off of an MS SQL Server database. The app allows users to authenticate using Windows authentication (that is, using the Windows username the user is currently logged in with), but the need was discovered for the app to a have a built-in, independent method of a... | stackexchange/codereview |
Binary Search Tree, with preorder traverse. What other methods should I add? How can I improve it?
class Bst
attr_accessor :data, :left, :right
def initialize(data)
self.data = data
end
def insert(data)
if self.data < data
if (self.right )
self.right.insert(data)
else
... | stackexchange/codereview |
I've created a simple application for mobile users, they can login using provided API but must have limitation on the devices, so the requirement is simple :
User cannot login using more than 2 devices
I'm building the API using laravel for mobile apps, so I've created the function and it works correctly and wrote t... | stackexchange/codereview |
I have the following file that is included in others. I realise I need to put in try/except but for the purposes of this question, the below should suffice
We're using MS SQL
Function
Already done in the example below. Except for try/except am I missing anything obvious?
Class
I was looking at https://stackoverflow.com... | stackexchange/codereview |
The program takes census data from a text file in the format age, gender, marital status, district. It then gives a list of residents by district (there are 22) and by 5 age groups. Any suggestions for improvement?
The only topics we have covered so far in class are methods, decisions, looping, and arrays.
static void... | stackexchange/codereview |
I'm working on making a matrix math object that's as generic as possible. I currently have done multiplication. I've run into a decision I have to make, but first, here's the code.
namespace MatrixMath
{
/// <summary>
/// Matrix is a class designed to do math on matrices for you.
/// Matrix methods assume t... | stackexchange/codereview |
I've been doing some parsing with regular expression named capture groups and decided it might make sense to write an extension to handle this.
The code below will create an instance of a specified type and attempt to match the property names to the capture group names and then set the values. It also attempts to ca... | stackexchange/codereview |
I have tried the below program to find (Kth element from tail) of a singly linked list. I have tried to utilize the length field which I am incrementing whenever an item is added into the list or vice versa.
public Node<T> findKthFromTail(int kthElem) {
// length has the size of the list
int kthPos = length - k... | stackexchange/codereview |
I'm solving this challenge:
Given a positive integer number, you have to find the smallest good number greater than or equal to the given number.
The positive integer is called good if it can be represented as a sum of distinct powers of 3 (i.e. no duplicates of powers of 3 are allowed).
The code passes all the test ... | stackexchange/codereview |
I am using Google Execution API to create an invoice and it's a small part of a bigger system. However, my boss is pretty displeased at the total execution time before an invoice is generated. It takes 16 seconds for an invoice to be generated, and even longer for multiple payments in one invoice. I have been requeste... | stackexchange/codereview |
I solved the Advent of Code problems last year in Python, and I wanted to learn a new language this year, so I decided to write up Part 1 of on of the hardest problems from last year - problem 15 - in Rust.
While the problem in all its particulars is quite difficult to understand fully, the basic idea is quite simple: ... | stackexchange/codereview |
I have written a Python program to take in two strings and print the larger of the two strings.
Here is my code -
string1 = input("Enter first string: ")
string2 = input("Enter second string: ")
count1 = 0
count2 = 0
for i in string1:
count1 = count1 + 1
for j in string2:
count2 = count2 + 1
if (count1 <... | stackexchange/codereview |
I am loading divs from separate HTML files into a div on the index.html page.
This is being done using jQuery's .load(). There is however, a lot of repetition and I'm wondering if there is a cleaner way to achieve this.
The HTML:
<nav class="menu-side">
<a href="#" id="about">About</a>
<a href="#" id="help"></i>Hel... | stackexchange/codereview |
I am currently working on a problem of an online judge (not a contest). The program must calculate how many years will require for the population A (which is always less than B) to be higher than B. If the time is more than a Century then print "More than a century" in Portuguese.
Input
1
90000 120000 5.5 3.5
Where 1 ... | stackexchange/codereview |
I'm recieving UDP messages as byte arrays and depending on details in some of the first byte, I need to convert remaining bytes into a multitude of different possible arrangements of other data types.
These data types are primarily 'uint', 'ushort' and just 'byte' but can be in any order, and there can be any number of... | stackexchange/codereview |
Given an integer , print the next smallest and next largest number that have the same number of 1 bits in their binary representation.
How can I improve this?
void printNextNumber(int num){
int inputNumOfBits = calcBits(num);
int nextLargest = num + 1, nextSmallest = num - 1;
//nextLargest
while (tru... | stackexchange/codereview |
I've seen at least two recent PHP questions that would do well from a Model-View-Controller ('MVC' from here-on-out in this question) setup. Now, me, being the horrible person I am, I wanted to build one because it's been a while since I've done any actual PHP work, and as much trash as I have been known to talk about ... | stackexchange/codereview |
I am creating an Ellipsoid class and I then want to instantiate a few constants (pre-defined Ellipsoids).
Below is my current implementation. I am not really satisfied with it except that it works very well but feels a but clumsy and there is probably a much cleaner way to do this.
# -*- coding: utf-8 -*-
from colle... | stackexchange/codereview |
This is the code I wrote in order to find the smallest value in a list using recursion.However I feel like there would be a better way to do this?
def minimum(lst):
"""
parameters : lst of type list
return : the value of the smallest element in the lst
"""
if len(lst) == 1:
return lst[0]
... | stackexchange/codereview |
I run subprocesses with lot of output (compilation of Unity 3D projects).
I use log parsers to find known issues.
class LogParser(object):
def __init__(self):
self.report = []
def __call__(self, output: bytes):
for decoded_line in output.decode().splitlines():
self.parse(line)
... | stackexchange/codereview |
I made a small python script to create an audio sound used as stimuli. It's one of my first uses of super(), and I do not know if I did it right. I'm looking for any improvement in both optimization and style you could suggest.
import pyaudio
import numpy as np
class SoundStimuli:
def __init__(self, fs=44100, dura... | stackexchange/codereview |
I have created the classic "guess the random number" game:
Generator Interface
package ishan.guessingGame.randomNumberGenerators;
public interface RandomNumber {
public int generate();
}
Generator Implementation
package ishan.guessingGame.randomNumberGenerators;
import java.util.Random;
public class SimpleRando... | stackexchange/codereview |
In my current project, I have to build a criteria builder which users can use to find "contacts" (the definition of which is not relevant). For this, I have created the front-end in Elm, which will then create a JSON-request to the back-end. The back-end has to deserialize this JSON and create a jOOQ query which will t... | stackexchange/codereview |
I'm very new to Angular, and trying to get my head around whether or not I'm doing it the Right Way (tm).
I want to filter a set of results by their properties, where if none of the filters are checked, all the results are displayed, but if one or more filters are checked, all results which match the checked properties... | stackexchange/codereview |
From SICP:
Exercise 3.8
When we defined the
evaluation model in section 1.1.3, we
said that the first step in evaluating
an expression is to evaluate its
subexpressions. But we never specified
the order in which the subexpressions
should be evaluated (e.g., left to
right or right to left). When we
intr... | stackexchange/codereview |
I'm wanting to reduce the amount of code in this set of statements, as it seems quite repetitive:
if ($('#Size').val() === 'extra-cab' && $(this).attr("id") === 'canopy-17x-select') {
$('.rack-kit input[type="checkbox"]:checked').prop('checked', false).trigger('change');
}
if ($('#Si... | stackexchange/codereview |
Abstract
I'd like to have advice on how to :
implement methods that rely on a state,
when the instance is mutable and may be in an inconsistent state,
in such a way that the methods either silently fail or return nil,
without having to nil guard / coerce state to meaningful values everywhere.
Anyway, if my design i... | stackexchange/codereview |
I've created my own AutoComplete form element based on @nextui-org/autocomplete to be able to use it along with react-hook-form. I am relatively new at TS, at least on generics, so I am not sure if I am overusing generics or have any mistakes really.
// AutoComplete.tsx
import {
Autocomplete as NUIAutocomplete,
Au... | stackexchange/codereview |
I have a method to get the time parameter, is this code neat, can the return parameter use other data structures?
private Map<String, Object> getTimeCondition(long smallDaysToSubtract, long bigDaysToSubtract) {
DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.yyyy_MM_dd);
ZoneId zoneId = ZoneId.... | stackexchange/codereview |
Assume I created an image in NumPy:
image = imread(...)
And the image is RGB:
assert len(image.shape) == 3 and image.shape[2] == 3
I want to check (i.e. get a boolean mask) which pixels are (R=255, G=127, B=63) in a cleaner and efficient way:
mask = (img[:, :, 0] == 255) & (img[:, :, 1] == 127) & (img[:, :, 2] == 63)... | stackexchange/codereview |
I was inspired to write a query that produced a graph mapping the perceived quality of your Stack Exchange answers over time.... in other words, "Are your answers getting better, or worse?"
Because answer scores are very 'spiky', it seems natural to calculate a sliding average with a configurable window, to show trends... | stackexchange/codereview |
I'm hoping to automate the 'Manage Nuget Packages for Solution' Consolidate User Interface using Powershell in the 'Package Manager Console'.
The following script should take ONE of the packages in the consolidation list and 'fix it'.
#do just one
get-package | Group-Object Id | foreach { [pscustomobject]@{ packagename... | stackexchange/codereview |
I wrote a program to print the following pattern using recursion to hands on recursion and my output is perfect but I want to know another and the most optimized approach for this.
This is the sample output of my program if we insert n = 5:
54321
4321
321
21
1
public class JavaApplication2 {
/**
* @... | stackexchange/codereview |
Note: This code was first posted on another forum by me under the name Candy. Read this note before you declare this code copied.
Since I was bored, I decided to code a Rock Paper Scissors game in Python in my iOS device (There are offline interpreters available). The very first version of my code was ugly and large, s... | stackexchange/codereview |
I have the below code which increases the code complexity. Any way to refactor it?
I am trying to refactor the below code so that the CCM can be reduced for the code. i.e code complexity matrix.
//// TODO: Needs refactoring
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
... | stackexchange/codereview |
Is there any way to refactor this?
public IEnumerable<Option> Options
{
get
{
{
List<Option> ListOption = new List<Option>();
if (!String.IsNullOrEmpty(Option1))
{
ListOption.Add(new Option() {Name=Option1 });
}
if (!String.Is... | stackexchange/codereview |
Due to a lack of every standard from C++11 upwards in my IDE I rolled an own litte lambda expression like construct some time ago, which I want to share now. I wouldn't necessarily recommend using this in production code, since #defines aren't the best way to go.
First of all, we need an any class. Mine is called Whate... | stackexchange/codereview |
I've been programming with Python 2.7 for about six months now and if possible, I'd like some critique to see what I might have done better or what I might be doing wrong.
My objective was to make a script scraper that finds variables and functions, outputting them to a text file along with their line number. It also o... | stackexchange/codereview |
I was hoping that some more experienced programmers could help me make my implementation of Dijkstra's algorithm more efficient.
So far, I think that the most susceptible part is how I am looping through everything in X and everything in graph[v].
My graph is formatted as:
g = {0:{1:2}, 1:{0:2, 2:6}, 2:{1:6}}
This is ... | 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 |
This is my first PHP script (although I like to think I'm a good general coder).
The script accepts a number from the user, uses it to generate a regular expression, and then returns all dictionary words that match that expression.
It's currently live here, and I'd appreciate any comments on style, security, best pr... | stackexchange/codereview |
I have written a small plugin library for CKFinder that I would like some critiques on.
The library is located here.
If you are looking for where to start, check out plugin.php and hook function in here in the assets/ckfinder/core/connector/php/php5/CommandHandler/ folder.
I would really love to hear your critiques on:... | stackexchange/codereview |
This is my first attempt at open source contribution via a Python discord bot, built to analyse user-uploaded log files and give quick, at-a-glance information for support staff.
The PR is here: https://github.com/Ryujinx/ryuko-ng/pull/3
My main concerns are:
Is this structured properly?
What could I improve? I've att... | stackexchange/codereview |
I am writing automated tests for a web app and at one point I need to make sure that a user can only engage in activities allowed by a set permission. I have written all the standalone methods that perform the required tests and now I need to group all of them together and test. I came up with something that looks like... | stackexchange/codereview |
I'm implementing std::once_flag and std::call_once for a particular MinGW build where they are not available, using only stuff available in the rest of the standard. The required semantics would be easy to implement with something like:
struct once_flag {
private:
std::mutex _M_mutex;
std::atomic_bool _M_has_ru... | stackexchange/codereview |
For a specific usage I made a very simple template engine in Python, to display value. The code:
import re
class Template(object):
"""A simple template engine support only the substitute of variable"""
def __init__(
self, delimiter_start='[', delimiter_end=']',
identifier=r'^[^\d\W]\w*$... | stackexchange/codereview |
I have a small function which checks if the given String has all 0's. This method would be used quite often and want to know if it's effectively written. Any help would be greatly appreciated.
/*
* Input parameters: Employee Number
* Returns true if sum of employee number is greater than 0,
* else false.
*/
privat... | stackexchange/codereview |
I wanted to have a custom section in my app.config file in which any element could reference and reuse (or better said could inherit) any string value that is defined in it or above it in the element hierarchy. In other words, a child element could reuse any string value that it has or that its parents have.
For exampl... | stackexchange/codereview |
In mobile phones technologies, a SectorId is a 128-bit value broadcast by a 1xEV-DO BTS system.
That is a 16 bytes data.
I made a structure to store them:
using System;
using System.Globalization;
using System.Linq;
using System.Text;
public struct SectorId
{
readonly byte[] id;
SectorId(byte[] id)
{
... | stackexchange/codereview |
The cube, 41063625 (\$345^3\$), can be permuted to produce two other cubes: 56623104 (\$384^3\$) and 66430125 (\$405^3\$).
In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube.
Find the smallest cube for which exactly five permutations of its digits are cube.
fro... | stackexchange/codereview |
I posted a question here ffmpeg batch script for video resizing but I forgot the issue of the rotation and the video files were scaled with wrong dimensions.
Below is the improved version of the script
#!/bin/bash
set -eu
status=true
fail() {
echo "$@" >&2
status=false
}
# Resize a single file
resize() {
... | stackexchange/codereview |
A simple tab scroller built with React.js that utilizes jQuery for the animation.
Questions
I've only just started learning React and I've recently come across <MyComponent></MyComponent>, though the information was limited. Where can I go to learn more about this?
Would it be better to use the previous question's way... | stackexchange/codereview |
Next release of Rubberduck will introduce a very cool @Folder annotation system that the Code Explorer will use to organize modules into - you guessed it - folders:
...which is tremendously awesome, because VBA doesn't have any concept of namespace, and the VBE doesn't offer anything better than a "Classes" folder to ... | stackexchange/codereview |
I have the following script to reveal sections on a page if certain text in an is clicked. How do I collapse all other sections if any one of them is selected and make it scalable for 20 items?
The following solution looks like it needs refactoring, and also when clicking icn_1, for instance, all other sections might ... | stackexchange/codereview |
The class below takes in a string of genre IDs deserialized from JSON and spits them back out in a format I can actually use. I'm definitely a beginner and would like to better myself, I feel like with this class specifically my lack of Java knowledge really shows.
Here is an example of the input the class is receiving... | stackexchange/codereview |
I have multiple onEdit app script functions in my Google Spreadsheet which work individually but I cannot work out where to put the brackets to nest them. This is my code which is a little messy and probably needs a tidy up.
// Cut Employees Left from Unit Standards sheet and paste in Unit Standards - Employees Left sh... | stackexchange/codereview |
I have made a search function that seems to work for passing the tester. I am just unsure if it will always be without errors. Can someone tell me if they see any flaws in the logic, and if so, where to look to improve?
Search function
//looks up the word in the object. If it is in the object,true is returned.
//You ... | stackexchange/codereview |
Just what it says on the tin: a brainfuck interpreter in JavaScript.
function brainfuck(source) {
var code = source.replace(/[^-+<>.,[\]]/g, '').split(''); // program code
var loop = []; // stack of loops created by bracket operators
var data = []; // array of data cells stored by the program code
va... | stackexchange/codereview |
I'm looking for advice how to improve the code. It's a mess, but I don't know how to improve it. There are some mathematical errors, projectile movements are behaving strangely, code is messy in general, unit positions are off, etc.
var canvas = document.createElement("canvas");
canvas.id = "canvas";
var ctx = canvas... | stackexchange/codereview |
I'm trying to make a random object spawning script in Unity.
Bellow is the code, any suggestions for improvement / changes?
I'm new to both Unity and C#.
// Game objects and Transforms
public Transform playerTransform;
public Transform[] obstaclePrefab;
// spawn params
public float minYDicstane = 6.0f;
public float ma... | stackexchange/codereview |
I often receive large Excel-sheets in which data has been inserted via copy and paste. Usually a lot of the cells contain whitespaces at the beginning and the end before / after the actual value.
I made a VBA-script for to get rid of these whitespaces.
' Removes whitespaces at the
' beginning and the end
' of all cell... | stackexchange/codereview |
Note: A run is a series of adjacent chars that are the same.
I just want to answer a few questions:
Is this readable?
Does it need commenting or is it self-descriptive enough?
Are there any efficiency tweaks this could have?
Is this a good way to test?
Which is the preferred/conventional syntax?
int maxCheck = 0,
... | stackexchange/codereview |
I tried to write a foolproof function for the first part of the first problem on adventofcode, which asks for the count of ( characters minus the count of ) characters in a string.
The function intentionally ignores any other characters in the input string.
function findEndFloor(floors, upFloorSymbol, downFloorSymbol)... | stackexchange/codereview |
Im constructing metadata about a class. With reflection i iterate over the class properties, and those properties have attributes (name, validation etc). When iterating those attributes, i typecast to some specific attribute-types, and if successful store the relevant attribute information. Im looking to do this in a m... | stackexchange/codereview |
Checking if some port is up on the network is a very common task when working with remote services. A common way to check is using telnet, but I have two practical issues with that:
telnet is not available in all systems, for example in recent versions of Windows.
When connection is successful with telnet, an interact... | stackexchange/codereview |
The following is my usage of the Memento Pattern when one class uses the copy constructor of a sister class (a separate derived class of the base class) and wishes to revert to the previous class. Note that allMementos is a map of Mementos instead of just a single Memento because of possible multiple conversions betwe... | stackexchange/codereview |
I have a text file which is tab delimited:
1 324 2344
1 8372 1234
2 62 12
2 872 12111
2 1211 28736
3 87636 198272
The first "column" contains the id value and the rest containing data. I would like a csv file to be created for each id value so in this example, there would be 3 csv fi... | stackexchange/codereview |
When processing large files (say for parsing or performing computations based on the contents), we want to be able to use multiple processes to perform the job faster.
In my case I wanted to count the frequency of appearance of features in a LibSVM formated file, similar to a word-count which is a typical parallel proc... | stackexchange/codereview |
I'm trying to do this:
Getting user's ID based on his email name.
Using that user_id to check all his emails that have been sent for him so far.
// db connection here
$sth = $dbh_conn
->prepare("SELECT id FROM users WHERE email = ?")
->execute(array($email));
$num_rows = $sth->fetch(PDO::FETCH_ASSOC);
if($num_rows)... | stackexchange/codereview |
The code below is the core of a Genetic Algorithm (NSGA-II to be precise, without crowding-distance calculation), but I've taken out all the GA-specific parts and made a generic example. I think I've carried over most of the principles/'constraints' from the original algorithm, but I might have missed something.
As you... | stackexchange/codereview |
// variables
// arr has elements to be sorted
var arr = []
// temp is to store the intermediate results after merging
var temp = []
// seen is for marking visited i.e. sorted half as green
var seen = []
// length of array
var len = 50
// canvas initialisations
var canvas = document.getElementById("myCanvas")
canvas.... | stackexchange/codereview |
I've written a python program to rank the names that appear in the file(s) based on their frequency. In other words, there are multiple files and want to rank the frequency of the names that appears the most first, then the least at the end. Each name can appear only once in each file. In other words, the same name can... | stackexchange/codereview |
I recently had a requirement to export data to CSV in a different culture & hit an issue (see https://stackoverflow.com/a/40871162/361842).
Here's my workaround:
function ConvertTo-SpecifiedCulture {
[CmdletBinding()]
param (
[Parameter(Mandatory,ValueFromPipeline)]
[PSObject]$InputObject
... | stackexchange/codereview |
I wrote a little library for myself: implementing a generic finite state machine. I will be using this library in class assignments.
I clearly have little understanding of C++ templates because most changes I make break it and take around 30 minutes to debug each. So I would like some review especially regarding my use... | stackexchange/codereview |
I solved the following question
You are asked to ensure that the first and last names of people begin
with a capital letter in their passports. For example, alison heck
should be capitalised correctly as Alison Heck.
Given a full name, your task is to capitalize the name appropriately.
Input Format
A single line of in... | stackexchange/codereview |
Following is based on a problem description from a Codility test, as a task in an interview.
DeepestPit - problem description
A non-empty zero-indexed array B consisting of M integers is given. A pit in this array is any triplet of integers (X, Y, Z) such that:
0 ≤ X < Y < Z < M
sequence [B[X], B[X+1], ..., B[Y]] is ... | stackexchange/codereview |
I have this function that allows the user to supply a number and that many rows are appended to the existing table:
$('#add-row').click(function() {
if($('#insert-rows-amnt').val() < 1) {
alert('Please enter number of rows to insert');
} else {
for(i = 1; i <= $('#insert-rows-amnt').val(); i++) ... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.