instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
This function finds links from Clyp.it and offers users a link to embed the content. Please let me know what you think of it. It works, but probably has some redundancies and inefficiencies. $(document).ready(function() { var clyplinks = $('a[href^="https://clyp.it/"]').filter(function() { return this.inn...
stackexchange/codereview
In interrupted bubble sort, we need to stop the sorting based on the iteration count. This seems pretty straightforward to me. I have this code, which seems to work fine, but it isn't fast enough for larger input sets. How can I make this faster? s = '36 47 78 28 20 79 87 16 8 45 72 69 81 66 60 8 3 86 90 90 | 2' ls = s...
stackexchange/codereview
I wanted to write something that would be useful for the indices of a grid where if one walked off the edge of the grid they would re enter on the opposite side. This could in theory help with checking for special cases when checking for neighbours to a certain position on the grid. For example the neighbours of positi...
stackexchange/codereview
Following up on @Vogel612's friendly advice from the vba-rubberducking chat room, I am posting my working code for open review. Thanks also to @Mat'sMug for the help! This will be my first task that I have completely automated via batch file scheduling, so I have included some spaces to pass error messages to the vbscr...
stackexchange/codereview
I had some difficulties implementing a redis-like plugin basil.js, particularly the LREM method. The complexity was to loop only once (and not the whole array every time if we have 0 !== count) ascending or descending. My code below works and passes tests, but I was wondering if another smarter implementation (fewer in...
stackexchange/codereview
I'd like feedback on my function to convert FASTA data to a dictionary in Python. Here's an example of FASTA text: >gi|33112219|sp|O93279.1|A4_TAKRU RecName: Full=Amyloid beta A4 protein; AltName: Full=ABPP; Short=APP; AltName: Full=Alzheimer disease amyloid A4 protein homolog; Contains: RecName: Full=Beta-amyloid prot...
stackexchange/codereview
I recently wrote a small script to deploy a mongodb cluster on a single machine. The cluster is composed of : 3 configurations server that holds the same informations (they are replicas ) 2 shard server wich will store the data one mongos which manage connection to the cluster The script parse a configuration file ...
stackexchange/codereview
I am adding below code for review as i am bit new to boto3. This Script adds tags (key and value) to All Volumes of EC2 listed in Excel. Is there any more effective way i could have written this? Also I am using AWS temporary credentials by editing ~/aws/config and making profiles. Is there any other way i can use w.r....
stackexchange/codereview
I have a json file - WorkflowNames.json with contents as - ["ImportOrder", "ValidateOrder", "ProcessOrder", "ArchiveOrder"] My C# code to read this json file is - private Dictionary<string, bool> GetWorkflowNames() { var appDataFolder = ConfigurationMgr.GetAppPath("App_Data"); var jsonFilePath = Path.Combine(appDa...
stackexchange/codereview
Inheritance Challenge 2 - Employees, Bosses and Trainees Create a main class with a Main Method, then a base class Employee with the properties Name, FirstName, Salary and the methods Work() and Pause(). Create a deriving class boss with the propertie CompanyCar and the method Lead(). Create another deriving class...
stackexchange/codereview
The Cardshifter team has been working at "translating" a very complex Java class into JavaScript, to make it more accessible to somebody who would want to fork the game and make their own modification, which is an objective that's been close to our hearts since the very beginning (for the game to be very "moddable"). ...
stackexchange/codereview
The following code aims to identify and delete duplicate files in a folder. At first, files are compared by size, and then (if needed) by hash. The helper function sort_duplicates determines which file of the group of duplicates to keep. I have skipped the part of the code dealing with CLI. As a self-learner of comput...
stackexchange/codereview
I made this math script, where you enter an equation and it solves it for you. I was wondering what you thought of the code, and what I could have done better or what doesn't follow Ruby best practices. The code is also on Github here if you want to see the readme and how to use define_equation() #!/usr/bin/env ruby r...
stackexchange/codereview
I have the following code in my project that installs linux sl on Windows using PowerShell. Is there anything you'd improve about this? param([String]$Profile, [Switch]$Help, [Switch]$Force) $ErrorMessages = @() $Payload = " # <Code inserted by Install-Steam-Locomotive> function Steam-Locomotive {wsl sl -e} function ...
stackexchange/codereview
I am working on a stock analysis application in Python and I have the need to determine whether an input ticker symbol is an Exchange Traded Fund (ETF) or not. First I need to determine if the given ticker is even valid. Second I need to determine if it is an ETF or a company stock. So, I have some simple functions ...
stackexchange/codereview
I am writing a credit card generator. I have method GenerateVisa() who will return either a 13 or 16 numbers string. This is the default value but GenerateVisa can also take a parameter. THis parameter will allow us to force the output to either 13 or 16. What is this parameter? I could use a int like GenerateVisa(int ...
stackexchange/codereview
This is my very first Bash script that does something real. I'm here to learn, so please tell me if and how this can be done better. #!/bin/sh # Daniele Brugnara # October - 2013 if [ -k $1 ]; then echo "Error! You must pass a repository name!" exit 1 fi SVN_PATH="/var/lib/svn" currPath=$(pwd) cd $S...
stackexchange/codereview
I'm working on system that tags images. I'm going to use the xxHash (lz4) for hashing images. With hashes of size 64 bits, it looks like I won't have a 50% chance of a collision until ~4 billion images are added. At that point I think a collision would be the least of my worries. The size of my VARCHARs in the images a...
stackexchange/codereview
I'm looking for suggestions on how to clean up JavaScript/jQuery code that looks like the example in the Before snippet. I'm a backend developer so some of the constructs in JavaScript are foreign to me. I took a stab at it in the After block but I'm not sure if there is a name for that design pattern. Most of the JS c...
stackexchange/codereview
Use case: We have a simple two tables plus a link table setup using some modern RDBMS. For example: Hospital table (id, name, ...) Physician table (id, name, ...) Visiting_Privilege table (hospital_id, physician_id, ...) Our goal is to find records that are "missing" (absent) from the link table. Using our example: L...
stackexchange/codereview
Use cases Messaging app between two users. GameMain is for multithreading application refers to SendMessageWrokers.java Only 2 user need to be defined and message app needs to finalize after a restriced amount of message count. GameMain.java package org.nb; import java.util.List; import java.util.concurrent.*; public...
stackexchange/codereview
I wanted to share a bit about how to implement your merge sort. Merge sort is a divide and conquer algorithm that breaks down an array into smaller pieces and eventually pieces them back together one by one sorting the data as it does so. Merging the elements together takes n time for each level that is merged. Each le...
stackexchange/codereview
Inspired by CodeWars We have a string s Let's say you start with this: "String" The first thing you do is reverse it: "gnirtS" Then you will take the string from the 1st position and reverse it again: "gStrin" Then you will take the string from the 2nd position and reverse it again: "gSnirt" ...
stackexchange/codereview
Matlab profiler throws this horrible bottleneck which is called 700000 times: for k =1:model.nlf, for r =1:model.nlf, KuyDinvKyu = zeros(model.k,model.k); for q =1:model.nout, KuyDinvKyu = KuyDinvKyu + model.KuyDinv{k,q}*model.Kyu{q,r}; end if (k == r) model.A...
stackexchange/codereview
I thought I would try and write a solution to the Wolf, Goat and Cabbage problem in Java 8 to try and get to grips with lambdas. I am looking for any feedback you might provide. The feedback I am looking for is mainly on code structure and where I could make more, or more simple, use of new Java 8 features. The basic i...
stackexchange/codereview
I have written code to find a duplicate char from a string. Can the code be improved? Input: Hello World output : l = 3 its a dup o = 2 its a dup My approach is step 1: sort the string step 2: remove all the whitespace step 3: copy std::string to char [] and loop through the array unt...
stackexchange/codereview
I'm trying to use a Perlin noise generator to make the tiles of a map, but I think the code is too slow, I mean, I took some hours to complete the generation of 1000 x 1000 chart. (I didn't used timeit.timeit() to check the time, I simply executed the script in the afternoon and in the evening I got the result...) Note...
stackexchange/codereview
I'm currently writing a little tool to get into Go. As I'm not familiar with the language I'm especially looking for Conventional go stuff. utility.go feels wrong.Should I wrap the client and email/password into a struct in utility? What would you advice. Every critique on anything is very well welcome! Small info: ...
stackexchange/codereview
I have a section of code that I've been attempting to clean up and hopefully speed up. The section of code where I pass values in order to generate a key and update a table on a different sheet I think is my biggest problem. However I would like any suggestions/modifications to clean this section up first. An overview ...
stackexchange/codereview
I used a Raspberry Pi and Adafruit LCD with buttons to build a small thermostat for my house. This is the hardware I used to you can imagine how the button and the code work: https://www.adafruit.com/products/1110 I know I need to build some kind of state machine but I don't know how to handle persistance in python tha...
stackexchange/codereview
I have recently coded a system where an instance of class Player is created for each connected socket, once the player class has been created, in its constructor the Socket that connected starts receiving data from the client side. I won't be including the client side code, just the server side for this question. Once ...
stackexchange/codereview
I am quite a novice. The below code does what I require but I was hoping you could help me speeding it up and simplifying it please. I know should start with basics when learning VBA..but it's just so exciting. Probably it would be faster if I applied For i to x, next i method Could you please help or guide me to a bet...
stackexchange/codereview
I am working on a fifteen puzzle, and just got it working finally. My next step is to implement an Iterative Deepening search on the puzzle to solve it. I assume you go column by column, row by row with a loop until the checkwin function is complete? I would really love any pointers or guidance that can be given. Does ...
stackexchange/codereview
Challenge: Given three query types simulate heap operations. Specifications: 1. "1 v" - Add an element v to the heap. 2. "2 v" - Delete the element v from the heap. 3. Print the minimum of all the elements in the heap. It is guaranteed that the element to be deleted will exist in the heap. Only distinct e...
stackexchange/codereview
As a self-learning project, I wrote an expression parser using the shunting yard algorithm in JavaScript. It's a larger part of what I plan to be a program for handling dice expressions in tabletop games, like 2d6 (2 six-sided dice). I know a parsing library would be a better fit, but this is also a self-learning proj...
stackexchange/codereview
Here is my Boyer Moore code in Python: def BoyerMoore(stringy, substring): if stringy == substring: return 0 ASCIIcharset = [-1]*256 for x in xrange(len(stringy)): ASCIIcharset[ord(stringy[x])] = x stringLen = len(stringy) substringLen = len(substring) for i in xrange(stringLen ...
stackexchange/codereview
A robot can move in one step from cell X to cell Y if and only if the distance between the centers of the cells X and Y measured in meters is equal to the sum of integers contained in X and Y. It then returns the index of the cell which the above condition does not meet which is the index only [0, 1, 4] and its value ...
stackexchange/codereview
In this post, I will compare performance of a circular list and a conventional list with head/tail -references: package com.github.coderodde.sentinellisttexperiment; public class SentinelListtExperiment { private static final int ADD_FIRST_N = 50_000_000; private static final int ADD_LAST_N = 50_00...
stackexchange/codereview
Following this website I wrote a neural network which uses the MNIST training data to recognize digits. The author writes that it should take a couple of minutes to train the network with 30 epochs of training. My network needs something like 5 minutes alone for 1 epoch of training. How could I make it process faster? ...
stackexchange/codereview
There may not be a "right" way to do it, but I'm inexperienced in functional programming. I'd like some feedback on how the code can be written in a more idiomatic way. Here it is: import Data.Maybe (fromJust, isJust) sepInt n = if n >= 10 then ( sepInt ( n `div` 10 ) ) ++ ((n `mod` 10):[]) el...
stackexchange/codereview
I have implemented a rather simple object pool for the sake of entities in my game world, and it works quite well. Advantages: Elements stay in contiguous memory - can be iterated just like in an array, at any time. Allocation, deallocation and dereference in O(1). Freeing elements does not require updating existing ...
stackexchange/codereview
This script takes a CSV of numbers and processes them to check to see if the numbers conform to the UK standard 11 digit numbers. Any errors are outputted to a log and the correct numbers sent to an XML for processing by a server process. import csv import re import datetime import xml.etree.cElementTree as ET import ...
stackexchange/codereview
The task involves analyzing a bunch of lines containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and combining them into a two-digit number. The goal is to find the sum of all these calibration values. Note: sometimes there is only 1 digi...
stackexchange/codereview
This is a follow-up question to Iteration of password hashing in PHP I've gone trough a lot of documentations and stuff to get a feel for this hashing jungle, and done some adjustments to my code along the way. PBKDF2 seemed like a good fit, so that's wath I went for. Also, it's important to know that I don't have acce...
stackexchange/codereview
I'm trying to set multiple attributes in d3 but I get an error for the stroke width attribute due to the dash. I can get around this by chaining another attribute's call but I would like to keep them all in one call if I can. Is this possible? var edges = svg.selectAll("line") .data(data.edges) .enter()...
stackexchange/codereview
I would like to properly raise an error if self._header was not created when I initialize a NewFile object. This is working now, but perhaps there is more formal way of catching the error below: class NewFile(object): """ Docstring """ def __init__(self, filename): self.localdir = 'C:\\Users\\User\\Doc...
stackexchange/codereview
I wrote a program to download a manga series fron www.mangapanda.com Here it is: import os import requests from lxml import html from cleanname import clean_filename dir_loc = r'' website_url = r'https://www.mangapanda.com' manga_url = r'https://www.mangapanda.com/one-piece' def check_url(url): url_status = re...
stackexchange/codereview
I'm trying to dive deeper into C#, and so I've been experimenting with some code. I'm creating a console application that shows the path of a projectile depending on the angle, and it works great! You can check it out here actually. It's not perfect, but I like it. Is there a better way to use my for loops? I'm using 3...
stackexchange/codereview
How do I improve this code for reading an epub file? The code is as follow: package org.example.mymenu; import java.awt.print.Book; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; //import java.util.List; //import org.example.mymenu.Book; /...
stackexchange/codereview
I have written a server-side app in Python that manages email by comparing senders against different lists and then dispositioning the messages according to which list the sender is on. As a side module, I wrote list_manager.py to ensure that a sender exists on only 1 list. It works, but it's already a bit unwieldy w...
stackexchange/codereview
I have previously asked here for a review of my Pong game. Since then I have implemented most of the recommendations but I'm not sure I did so correctly, the result can be found on my github. Would it be possible to get another review? Below is the whole source code of the game: main.cpp /* * Pong game * Author: Ch...
stackexchange/codereview
I wrote a simple quadratic equation solver with Ruby to help me solve quadratic equations. Please tell me what I did right or wrong, and what I can do to improve it. #!/usr/bin/ruby if ARGV.length != 3 STDERR << "Usage: #{$0} <a> <b> <c>\n" exit 1 end a = ARGV[0].to_i b = ARGV[1].to_i c = ARGV[2].to_i...
stackexchange/codereview
We were discussing Standard Deviations in chat, so I decided to write a standard deviation calculator: static double PopulationStandardDeviation(List<double> numberSet) { double mean = numberSet.Average(); return Math.Sqrt(numberSet.Sum(x => Math.Pow(x - mean, 2)) / numberSet.Count); } static double SampleSta...
stackexchange/codereview
I have a program which I require to cease some of it's activities at specific times. This can change day-to-day, week-to-week. The code below (working) is a test script. My program would check use the sleep_data() data set to check if the current date falls within any of the periods for a given day alongside the other ...
stackexchange/codereview
I would like to know how to know how can I optimize my current Post method , I initialize object where I am creating list of json items. Also how can I reduce many if and if else statments? For this post and get methods I am using swagger , is it possible to declare exceptions objects somewhere globaly? What kind of go...
stackexchange/codereview
Although this code uses ros2 my concern is about C++ code quality, because I still struggle when it comes to making good design decisions with regards to single responsibility, dependency injection, and callbacks, etc. I tend to second-guess decisions due to lack of experience. I am also always worried about which obj...
stackexchange/codereview
I'm (very) new to Scala, and decided I'd try to get a handle on some of the syntax and general language constructs. This currently doesn't implement any backtracking and will only solve things if they can be derived exactly from the values given in the initial board. That being said, I don't particularly care about a...
stackexchange/codereview
I have two behaviours: pulling or cloning a git repository. It started as an Enum, but then I had to switch over the enum all the time. I wanted to turn it into some kind of strategy pattern and fiddled around with the declaration of the enum values. I found the following solution, but I have two questions regarding it...
stackexchange/codereview
I'm using advent of code 2019 to start learning Python. I've read the Python style guide, and I'm trying to write readable and reusable code. This piece of code is an implementation of the IntCode computer used in many of the assignments. If you'd like to see code for the specific assignments, it's on my Github. Here's...
stackexchange/codereview
Goal: Create a simple battleship game to test what I've learned so far. #include <stdio.h> #include <stdlib.h> #include <time.h> void buff_clr(void) { char junk; do{ junk=getchar(); }while(junk!='\n'); } struct coord { int y; int x; }coords; int randgen(int **ships_ptr,int n) { int i,...
stackexchange/codereview
I'm currently working to implement a simple configuration file parser. I intend to add more functional down the road. ConfigReader.hpp #include <string> #include <vector> class ConfigReader { public: struct record { std::string section; std::string name; std::str...
stackexchange/codereview
I currently had a colleague reviewing my code and he had a comment on a factory class I created. It's very simple: class ResponseFactory { public function create(array $curlInfo, array $rawResponse): ResponseInterface { return new Response($curlInfo, $rawResponse); } } $responseFactory = new Respon...
stackexchange/codereview
I have a List of objects, List<myObject> objectList, and each object contains a List of strings like so: myObject: StringList( "A_1", "B_1", "C_1", "D_1", "E_1", "F_1" ) myObject: StringList( "A_2", "B_2", "C_1", "D_2", "E_2", "F_1" ) myObject: StringList( "A_2", "B_3", "C_1", "D_3", "E_2", "F_1" ) I'm trying to...
stackexchange/codereview
I was asked this recently, and I couldn't figure out the best way. We are trying to replicate Google's search results where the search terms are bolded (using a b tag) in the results. Input Terms Output The search is cool {sea} The <b>sea</b>rch is cool Origi...
stackexchange/codereview
I implemented a function for pager link creation, it looks like this: function createPagerObject(pageUri, page, totPages) { const MAX_PAGES_IN_PAGER = 6; // for the first three pages the starting would be 1 let pageNumber = Math.sign(page - 3) > 0 ? page - 3 : 1; let pager = []; for(let i = 0; i <...
stackexchange/codereview
I was hoping to get some input on a class module I'm designing to abstract away the boilerplate of utilizing asynchronous queries in VBA. cQueryable supports both synchronous and asynchronous queries. So you could do something like call a package to populate temp tables. This would be done synchronously because you'd w...
stackexchange/codereview
I wrote the following code to read constants from annotations: public class ContentUtils { static { String[] videoFormats = null; String[] imageFormats = null; try { Field multipartFileField = MultipartFileWrapper.class.getField("multipartFile"); Extensions annotation...
stackexchange/codereview
I have written this small function in Javascript for changing the padding on an element in HTML. It works well, however, I wonder if there is a better way to write it without so many if statements? window.addEventListener("resize", navPadding); function navPadding() { let width = window.innerWidth; if(w...
stackexchange/codereview
I have been practicing recursion lately and I came up with this code to solve the water jug problem, given two jugs of volume jug1 and jug2, where jug1 < jug2, obtain a volume t, where t < jug2. The algorithm below basically always pours from the smaller jug into the bigger jug, how would you improve the solution ? I t...
stackexchange/codereview
I'm working on a project the scenario: teacher model then is the teacher has not a profile the institute which working at will upload the courses does this is written the way I have tried in the course model? class Course(models.Model): course_name = models.CharField(max_length=20) student = models.ManyToMany(Stu...
stackexchange/codereview
Memory:O(log(max)base(mod)*mod)Speed:O(log(max)base(mod)*n) I did a radix sort in place to not get a auxliar array. In the process i discorver a few things. Is imposible to do LSD radix sort in place with out sacrifice speed, belive me if i say i try. THIS WILL BE NOT EXPLAING counting sort, you can do it for in plac...
stackexchange/codereview
I currently use this code to extract the required GPU data. Can you review this method for efficiency or best coding practices? Code import wmi c = wmi.WMI() def gpu_check(): gpu_ouy =["fu","7"] gpu_a ="" gpu_b ="" ass = str(c.Win32_VideoController()[0]) asss = str(c.Win32_VideoController()[1]...
stackexchange/codereview
The code below takes a specified number of card decks, and shuffles them according to the Fisher-Yates method. Does this implementation have any bias? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace randomShuffle { class Program { static void Main(string[...
stackexchange/codereview
I've been trying to create a calculator to find mass using any and all known equations. The program will also return the steps used to find mass so the user can 'check their work' on physics assignments. My biggest problem so far (and was solved by much copy-pasta) is the equations themselves. I'd like to be able to c...
stackexchange/codereview
I wrote a simple emacs module that generates standard templates that I use for my blog's static site generator. (defun hakyll-site-location () "Return the location of the Hakyll files." "~/Sites/hblog/") (defun hakyll-new-post (title tags) "Create a new Hakyll post for today with TITLE and TAGS." (interactive ...
stackexchange/codereview
This method works correctly and verifies whether a user has permissions to view or edit the first parameter (value). I think it is not the best implementation, because there are too many conditions and the List object isn't necessary. How to improve it? protected override Exception GetValidationException( object value,...
stackexchange/codereview
Question Any way I can optimize this further using new C++11 or C++17 features? Would also like feedback on my variable naming, memory management, and style (notice my placement of varible_name++ in some areas), and how I've abstracted the sort into a recursive_merge_sort function and a merge function. Code #include <i...
stackexchange/codereview
I want to refactor this code into js object, but not sure how. How should I do it? I initialize an object for every item in the DS.data_per_folder array. how can I define it in a higher level? Where should I init it then? .. DS.data_per_folder[CurrentContextMgr.current.folder.attr('id')] = { a...
stackexchange/codereview
The problem that I have is to find the minimum number of ways to go from one box to another box of a chess board. Now, I have created a code which is not very elegant but works. I am interested in if the code will give me the correct answer. Here is the code: import java.util.*; class Main{ public static void main(St...
stackexchange/codereview
In the last 2 years or so, I've learned a great deal about how to write better Scala code, but I know that I've barely scratched the surface. This is part of a library that I've been using. It has evolved a great deal since the first version and I'm curious to see how many mistakes I'm still making. I am particularly c...
stackexchange/codereview
I'm replacing my Visual Studio project files with FASTBuild makefiles because it builds in a fraction of the time. Right now FASTBuild isn't well known. The official documentation is sorely lacking, and I can't find anyone else talking about it online. I've spent quite a bit of time programming-by-error-message to figu...
stackexchange/codereview
Bitmap page allocator that scans the bitmap linearly looking for size amount of pages. Everytime it founds a free page, it check if the next size pages are also free, if yes it marks them as allocated and returns a pointer to the first page uint64_t *bitmap; #define setpage(p, x) bitmap[p / 64] = x << (p % 64) | bitm...
stackexchange/codereview
This is a multiple choice game. It has a web page where you enter a question, which can have multiple answers along with multiple options. Can anyone recommend any improvements for my code? //correct & options are both arrays. These arrays are being passed through an AJAX call function addQuestion($topicID, $difficulty...
stackexchange/codereview
I've been working on a simple neural network implemented in python. Currently, it seems to be learning, but unfortunately it doesn't seem to be learning effectively. The graph below shows the output of my neural network when trained over about 15,000 iterations, with 1000 training examples (it's trying to learn x2). Th...
stackexchange/codereview
I'm currently writting piece of logic which copies entities from one user account to another. My current strategy in doing this is like that: Consider the following code: public class MobileOrderSettings:ICloneable { public long Id { get; set; } public bool allowCash { get; set; } public int deliveryPrice ...
stackexchange/codereview
As a follow-up of my previous non-off-the-bat Ant Colony Simulator, we have this one that works off-the-bat... quite; the code for when the ants find and take the food isn't really done but it would be almost impossible to do it anyway, if someone wants to contribute directly to the code, please do it in GitHub. scent....
stackexchange/codereview
I am trying to extract data from meshgrid output where zCs is 1000 x 1000 matrix of z values which is produced from meshgrid of s using bin2mat. s is a struct which has x, y, z data. res is 1000. Based on the threshold I am trying to extract logical which is then used to extract data from s whose z values are between ...
stackexchange/codereview
My code works for user output alignment to the right side by maximum length of 4 different user input. I have 2 question. Is there a simplier way for append method in my code ? Is there a simplier way for right alignment by maximum legth of 4 different user input. Thank You for Your Time... """ Main purpose of this c...
stackexchange/codereview
While working with Android GUI my approach to adding Listeners for GUI elements is usually: Button helpBt = (Button) findViewById(R.id.help_button); helpBt.setOnClickListener(new View.OnClickListener() { /* Code */ }); Currently, I am at learning stage. However, will this approach be maintainence 'friendly' as I ...
stackexchange/codereview
I'm having trouble finding a clean way to handle checked exceptions thrown by a lambda function passed as a parameter in Java. I'm writing a Client which will interact via RMI with a Server to play a game; a Client needs to be registered on the Server to be able to login, and it needs to be logged in to play a game. It...
stackexchange/codereview
Consider the following method that I have for checking write permissions on a directory path: /// <summary> /// Check existence and write permissions of supplied directory. /// </summary> /// <param name="directory">The directory to check.</param> protected static void CheckPermissions(string directory) { if (!Dire...
stackexchange/codereview
I finally got my upload form and code that uploads to db. I used tutorial from this site. As I am php newbie, I want to know how secure this code is and if it is not secure at all (which I am almost sure of...) could someone tell me how to make it secure. This upload should be only for pdf, jpeg, jpg, doc files. Also t...
stackexchange/codereview
I have invented the fastest string search algorithm. It is called ""Choudhary String Search Algorithm (choudharyStringSearchAlgorithm)"". I have compared my algorithm with Brute Force Algorithm, Boyer Moore Algorithm, Rabin Karp Algorithm, and Knuth Morris Pratt Algorithm and my algorithm is the fastest. You can copy t...
stackexchange/codereview
I've a Linq query that performs poorly: var minuteValues = ValuesInMemory.Where(o => o.Key.Day == tmpValue.QuoteDate.Day && o.Key.Hour == tmpValue.QuoteDate.Hour && o.Key.Minute == tmpValue.QuoteDate.Minute && o.Key.Se...
stackexchange/codereview
I want to use my Web Scraper to get all tweets about Apple up to a date I specify. At the moment I'm scraping the tweets of today, or the last few days. However, my goal is to scrape all tweets from the last 3 years. When I run my code it takes hours for only a period of a few days. Does anyone have any tips for me on ...
stackexchange/codereview
I'm trying to improve my understanding of inheritance and template classes in C++ so I coded a hash table (see compilable source code below). I would be greatly appreciative of any comments on how to improve this code. Description: The LinkedList template class inherits from the template class Stack. The Stack class co...
stackexchange/codereview
I'm working on a pothole map web app in Google Apps Script. The map gets its data from a Google spreadsheet (from manual surveying), which is then transformed via hits to the Geolocation and Google Maps Roads APIs. There are 101 markers on the map (one marker per row of data, which represents either a pothole or a clus...
stackexchange/codereview
I need to get a list of all files supported by some libary (images) in a specified directory and all subderictories. Root directory of drive might be chosen and in this case I want to skip system folders like "Windows" and "AppData" (some other?). For such task I can use Directory.GetFiles() but problem is - it will st...
stackexchange/codereview
Nothing more to add than the title. Looking for code review, optimizations and best practices. public final class BaseAdder { private BaseAdder() { } /** * Given two numbers and their bases, adds the number * and returns the result in the same base. * * This code supports max-base 26. ...
stackexchange/codereview
I have a task to connect to S3 get a JSON file with the names of artists, use the youtube-data-api and search for the top 10 songs. Then send it back in a given format to S3 back. console.log("Loading up the best code ever!!!"); //packagess import var fs = require('fs'); var AWS = require('aws-sdk'); var Singer = requ...
stackexchange/codereview