instruction
stringlengths
71
71.9k
from itertools import izip_longest def partition(n, iterable): p = izip_longest(*([iter(iterable)] * n)) r = [] for x in p: s = set(x) s.discard(None) r.append(list(s)) return r print partition(2, range(100)) I saw it from a recruit and the company said there were potential problems,...
I haven't used regex a lot and I needed to set up a script that can gather a list of file paths that should adhere to a strict formatting convention, so I thought that sounded like a good opportunity to use them. To explain a bit, there's a set of sequence folders inside a root folder, and in those sequences is a set ...
I have no much experience with C++, so it is about time to start actually doing something about it. All in all, I coded this tiny unit test library: assert.h: #ifndef ASSERT_H #define ASSERT_H #include <iostream> #define ASSERT(CONDITION) assert(CONDITION, #CONDITION, __FILE__, __LINE__); #define REPORT as...
Everything is evaluated in compile-time. You will need a C++14 compiler. The compilation time is quite long, and with a bigger list input, you'll get some error messages like constexpr evaluation hit maximum step limit. #include <iostream> #include <limits> #include <initializer_list> template<typename T> class List {...
I'm dealing with a searching query where the user will pick from menus and checkboxes the variables-criteria I'm passing to the toWeb method and a list will be returned. This works fine but I'm going to add two more variables and it's already hard to follow. public List<newEvent> toWeb(string name, string egk, string ...
I'm solving Project Euler problem 7, which says: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? Here's the code I've written: def primes(n): primes = [] attempt = 3 while len(primes) < (n-1): for i in range(len...
I've been implementing a custom internal server error page in ASP.Net MVC which will check if the current user is either an administrator or accessing the page from localhost, and if so, show them a whole bunch of details about the error to debug it with, otherwise just send them to a basic HTML error page. So far, it ...
I made the layout for a new project which will allow you to subscribe to periodic emails about your favorite Stack Exchange site (I'm not very happy with the SE-provided one). Since I'm horrible at design and in essence new to HTML/CSS/Javascript, I figured I'd get started with that so the hard part is over. Below is t...
Why am I not just using a Pivot Table / Database? a) I've never ever used either before. And I don't have time to learn how before this project needs to actually be finished. b) The final output is going to be a report for the Company Directors. As such, the flexibility of choosing which bits of data to output in wha...
For some background, I am learning from the following Stack Overflow question that I asked regarding creating the this code. I was playing around with different combinations of whereKeys and queries, and I found a solution that seems to be working. I'm not really sure if this is the correct or most efficient way to ha...
The purpose of this code is to search the entire database for duplicate records and produce a script that a user could then run to delete all of the duplicates. The stored procedure takes the following parameters: @DiscludeTables varchar(max): a string of Table Names separated by semicolons. These tables are not in...
Working through CodeEval's Interrupted Bubble Sort, I have a working algorithm, but there's a speed issue. I'm trying to do this with Ruby and I keep getting an error that it's timing out after 10 seconds. I'm not sure what else I could be doing here to speed things up. def bubble(arr, interrupt) i = 0 while...
Floating point inaccuracies are really annoying. I understood that in its true sense while developing the next version of Point (this time I'm actually foolproofing my code). Before I upload it for review, I want a class that I wrote, called Numbers to be reviewed. Numbers.java package library.util; /** * This class ...
I have written nested while loops to read in some of the columns in a text file that looks like this: comp id subreddit created ranks recorded_at rank_length 0 3ckf7b pics 1436373189.0 [1, 1, 3, 5] [1436392502, 1436396101, 1436399701, 1436403301] 4.0 0 3csv79 UpliftingNews 1436538581.0 ...
I have a JavaScript (jQuery) 'init' file with various variables/event handlers and functions that are currently written in no particular order. I've read that it's good to organise these by declaring variables at the top of the file, using an init function and binding event handlers etc. Here is the file in its full an...
I have an index page which gets passed $_POST['timestart'] and $_POST['timeend'] variables. In addition, I have a cart page that has variables passed to it from the index page, and it passes variables back (with header) to the index page depending on what is done. In order to retain the initial $_POST['timestart'] an...
This game works out the basic of a Tic Tac Toe game. I am looking to see if this can be redone in any way to make the code more smaller since this is really big. private string player = "x"; private string cpu = "o"; public Form1() { InitializeComponent(); Buttons(); Grid(); } private void Form1_Load(obje...
I have written a couple of macros (? and ??) for performing unit tests, but I'm having some difficulty with modifying it, so I was hoping to get some feedback on how to tidy up what I have written so far. Yes, I know that unit test frameworks already exist, but I'm trying to learn by doing. Here is an example of usage:...
I just wrote a utility program in C that converts numbers of different bases to 'standard' well-known bases (hex, dec, oct, bin). I called it repnum, short for "represent number." You will notice a 'template' that I like to employ when writing C programs. Any suggestions? repnum.h #ifndef REPNUM_H #define REPNUM_H #if...
After receiving some awesome feedback in my first post yesterday, I was able to grasp the "building block" method of creating javascript in chunks and putting them together to create coherent/straightforward code. I've done quite a bit of refactoring and am fairly pleased given my initial goals for this project, but I ...
I am trying to generate JSON from a query. All this seems to be too much grinding it out. string function getJSON() output="false" { var result = "["; var myrow = 0; for(var row in this.qryLocation) { myrow++; result &= "[" & row.LocationID & ',' & ...
I created a generic version of IDA*. I am attempting to create the following code with exceptional quality and performance. I'm hoping to try and create short code tutorials regarding. However, the quality of my code may not be up to standard for a tutorial on the subject. I attempted to closely follow the pseudoco...
I've been working on this project to learn networking and concurrency as well as C++11 practices. I'm just looking for a general code review. #define _WINSOCK_DEPRECATED_NO_WARNINGS #include <WinSock2.h> #include <iostream> #include <string> #include <vector> #include <thread> #include <mutex> #pragma comment(lib, "w...
Been working on a BMR calculator on and off for a while now. Created an interface and been over different ways to store user input, different ways to calculate BMR/TDEE etc. I created another class called User for the calculations (as suggested by someone). This way I can pack the data of a user together with any metho...
I designed a simple drop-out stack a while back. Basically, I just want to get a few opinions on whether or not this is a good implementation and whether I am understanding the concept of a drop-out stack correctly. I know there are other / better ways to implement a stack, but I'm interested specifically in doing it w...
I have some code that allows for SQL reuse for C#. I'm pretty happy with it, but the fact that I can't find anything similar on the web makes me think I'm going about it the wrong way. I have a GitHub repo with a Visual Studio solution, and the code is repeated down below. Here's the use case: I'm working on a fairly s...
I want to check a text for consecutive repeating characters. For example, with a minimum of 3 consecutive chars, this should match: Okeee OOOkee Alsoook This should not match: No not okee, oh no This is my code: public static bool HasConsecutiveChars(string source, int sequenceLength) { if (str...
How well is this Tic Tac Toe code written? Where may I improve it? This is meant to be a platform for a machine learning algorithm. The code is written so any player may play first. Once a player plays first and starts the game, the code enforces turns. Overwrite protection is also enforced. #! /usr/bin/python3 class x...
I am building a simple REST client in Swift 2. The methods the client offers can return errors. Every method returns the same errors (network problem, unauthorized, etc...). But each method can also return "specialized" error, than are needed only for the method itself. I am trying to "extend" my ErrorType enum to matc...
I am still working on basic data structures for C. Now I came up with a hash map: unordered_map.h: #ifndef UNORDERED_MAP_H #define UNORDERED_MAP_H #include <stdlib.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif typedef struct unordered_map_t unordered_map_t; typedef struct unordered...
I've seen tutorials about node promises and such but not using bind. I feel like I can do lots of things this way and keep everything clean: Updater.prototype.generateLocFieldForDocs = function(docs) { console.log('list obtained') async.eachLimit(docs, 10, this.generateLocFieldForDoc.bind(this), this.generateLocFie...
I came up with this during English lessons many years ago to kill some time, and just decided to try code it. It's basically a 3D version of Connect Four/Noughts and Crosses/Tic Tac Toe, but the grid can also flip itself, which means the people good at spacial awareness have a chance against people good at planning ahe...
I'm learning about using LESS and wanted to get anyone's input on if I'm using the concepts, syntax, etc. correctly.I know this might seem subjective and not the correct place to post, so please let me know if there is a more appropriate place to do this. LESS code .centered(@position: inline, @width: 100%){ marg...
Motivation const_cast is a beast that I seldomly encounter. But when I do so it is mostly a bad experience. Nobody knows what most of the C++ programmers do but so far I only ever had one use for const_cast: to cast away a const from a type. For this task const_cast is too verbose: const std::vector<int> constVectorOfI...
Here I have a simple algorithm to percent-encode any string. (Specification from Wikipedia; note that this is not compatible with URLEncoder.encode()) Is this an efficient solution to the problem? Using a StringBuilder should be efficient, but it doesn't seem great since every character is added to the StringBuilder ...
I want to extend the Closeable-Interface so that I can add Listeners, that get notificated when the resource is closed. The CloseListener-API is rather simple and straight forward: public interface CloseListener { public void objectWillBeClosed(CloseableObservable closeable); public void objectClosed(CloseableObse...
I'm wrapping ui-select in my own directives to pre-configure and style it, as I need it for my app in different select widgets. They appear on many pages, for example accountSelect, countrySelect, contactSelect and so on. What I really dislike is, that I'm mostly copy-and-pasting the directive's code and then just chan...
I'm a newbie in Tkinter and I've managed to make the "Lights Off" puzzle using Tkinter with Python 3. The game starts by presenting 9 buttons arranged in a 3x3 matrix. The text of the button will be either 0 (which denotes that the light is off) and 1 (which denotes that the light is on). Clicking on a button inverts t...
I have a session class that needs to be setup based on different needs of the client code. Sometimes a new session needs to be created, or continued, or resumed (loaded from database after a user has saved their progress and came back). Right now the client code has to ALWAYS execute Start(), Continue(), or Resume() af...
Now I have this d-ary heap data structure. Note that for d = 2 this is a binary heap. The client programmer specifies the value of d when constructing the heap. See what I have: heap.h: #ifndef HEAP_H #define HEAP_H #include <stdbool.h> #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif typedef struct h...
More refactoring based you guys' great feedback. This time around I worked on using global/local variables properly and efficiently, putting return values to use, renaming variables so that the code is more understandable, and simplifying functions so that they serve one main purpose. My main concerns/focuses now: I'm ...
I want to model this scenario in object oriented language: A hospital has number of patients A patient can have zero or more medical conditions A medical condition is identified by name and date Please review my code and tell me: What can I do to incorporate object oriented fundamentals like reusability and extensib...
The discussion in the comments of this answer made me wonder how hard it would be to write a built-in only version of dirname. This is what I ended up with but I'm reasonably confident it should be able to be improved (I haven't spent much time thinking about it yet). Any improvements/suggestions are welcome. #!/bin/sh...
Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the Presenter be responsible for Thread safety, you can end up with deadlock issues, and also too many little tasks getting started; not great. I have written a class designed to manage these updates in the view ...
For my application, I've opted to use Integrated Security with Windows Authentication to access the SQL database. I've created AD security groups for each role and given them GRANT permissions on the tables and views they need to do their job. To further keep the end users from getting to the controls I'm checking the ...
I made some code to check that e-mails given apply to the right format, and I'm sure there must be a better way to do this. import javax.swing.JOptionPane; public class MailTest { public static void main (String [] args){ String email=""; int at1=0,at2=0; int dot1=0; boolean at = fa...
This question is a followup to Simple RPG skeleton, Part 1 - The Character. This is the second "part" of my development of this skeleton, and it now includes two new classes, Entity, and SpecType. The Entity class essentially serves as a base class for any character-like object, and has the following attributes and met...
I felt nostalgic recently, and decided to install a Commodore-64 emulator. C-64 BASIC 2.0 is the first language I ever programmed in... some 20 years ago (yes, C-64 was already well beyond deprecated by then). Implementing a simple fizzbuzz in such a limited language, and un-learning pretty much everything I learned in...
I don't feel that my code is secure, and would like some help in using prepare statements for the following; $track = "INSERT INTO resources_record (name,email,stage,format,topic,max_cost,mentor,total_cost,duration) VALUES ('".$fullName."', '".$email."', '".$stage."', '".$format."', '".$topic."', '".$cost."',...
I've writen a C# JSON parser, but its performance is not as good as JSON.NET. Running the same test, my parser takes 278 ms and JSON.NET takes 24 ms. What should I do to optimize it? It seems that the dynamic type slows down the lib. I know this parser doesn't support floats and negative numbers, but it doesn't matter....
I'm working on a small program to perform various tasks on text content, primarily at the word level. I wrote these methods as ways to help prepare the raw text file into something more malleable, like a List<String>, where at a later point I can perform various routines such as counting and sorting words, and so on. ...
This program is supposed to determine the day of the week for 2015. Could someone tell me how I could shorten my code? #include <stdio.h> #include <conio.h> void findDay(int , int); int main(void) { int jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec; for(jan=1; jan<=31; ++jan) { printf(" 01/%d/201...
I am using this R function to web scrape data from the google play store. Is there a way to increase its efficiency using R? This code takes about 4 seconds for 14 urls with my machine/internet connection. library(rvest) library(RCurl) library(foreach) library(doMC) registerDoMC(4) #insert number of your real Core...
I'm using Java 7. private Long difference; public Long timeDifference(String weboutput) { try { Calendar calendar = GregorianCalendar.getInstance(); Calendar today = new GregorianCalendar(); Date inputTime; if (weboutput.length() <= 11) { // for data fetched for current date. ...
The goal here is to, add a credit card image, and remove all other credit card images, of a certain input field. I had a even larger code, with a lot of addClass() and removeClass()... then, I shrink it until I have this. Still, I feel it's still a huge block of code. The point here is to short things up, but NOT until...
I have inherited some legacy code that I'm now trying to clean up. I feel like the 2nd null check is redundant, see comments: private java.lang.Object __equalsCalc = null; public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof ArrayOfColumn)) return false; // Here is first check if ...
I use Groovy to write business rules into big, long term Java software. Use Groovy in object way, that is not as groovy Script, but every elementary groovy source overrides some Java API class. i.e. AtLoginScript, PreparePaport etc. I had an idea to clone in very little scale IDE functionality: generate class from, or ...
Challenge Description: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Source I want to receive advice on my code. total_sum = 0 for i in range(1000): if (i%3 == 0 or i%5 == 0)...
Problem 11 Largest product in a grid What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? import numpy as np initial_max = 0 candidate_max1 = 1 candidate_max2 = 1 candidate_max3 = 1 S = {} S[1] = "08 02 22 97 38 15 00 40 00 75 04 05 07 ...
In order to save memory space. Strings inside an embedded device are stored in a particular way. Each 32-bit location holds up to 4 chars instead of only 1 char in the usual case. I wrote a function that convert an encoded string back to its original string. I am new to Python, so I would like to know whether or not I ...
I am having performance problems with the following python function: def remove_comments(buffer): new_buffer = '' lines = buffer.split('\n') for line in lines: line_wo_comments = line.split('--')[0] + '\n' new_buffer = new_buffer + line_wo_comments return new_buffer When buffer is very ...
This is a pretty straightforward library function I've got here. I've had to build it in to about 3 different forms but I never heard of this kind of function anywhere else. I'm trying to make it as readable and clear as possible, but I also am not too familiar with the best way to capture values in JavaScript. As far ...
This is an implementation of a practice problem from cprogramming.com: Temperature Converter Challenge The problem: In this challenge, write a program that takes in three arguments, a start temperature (in Celsius), an end temperature (in Celsius) and a step size. Print out a table that goes from the start temperatur...
This is a game that is supposed to be based on strategy and guessing. The letters need to match in a ABCD fashion on each button on buttons[0] - buttons[3] ... and buttons[n] - buttons[n] in each square, kind of like a matrix, although there is no matrix math involved. This is how the game starts: Each time a user cli...
I have implemented a recursive binary search in Python and tried to implement some verification to my code. Other than that, is there any optimization I am missing? def isSorted(ary): for i in range(1, len(ary)): if (ary[i] < ary[i - 1]): return False return True def binSearch(ary, elem, f...
I was trying to write a dynamic programming algorithm using a bottom up approach that solves the subset sum problem's version where the solution can be either an empty set and the initial set can only contain positive integers. The following is my implementation, but I am not sure it is correct for all cases. def _get_...
I have 3 tables: Table couples consist of save_id, id_candidate_red, id_candidate_blue Table candidates_red consist of save_id, id_candidate, enter_match Table candidates_blue consist of save_id, id_candidate, enter_match And I am running the query SELECT * FROM couples as c LEFT JOIN ...
I currently have a JavaScript file that I'm using to fix the navigation on a website I've built. The code is by no means 'DRY', though, and I'd like to fix that issue. //fixing the nav dropdowns for mobile //concrete and joint repair dropdown section $(document).ready(function() { // Optimalisation: Store the re...
The helper should be able to set a default value if the value can't be fetched with the provided key. There is also a bool that will throw an error if the key value or the default value could not be fetched or converted. Can I make it more compact, safer, and still have the same functionality? It feels like I am using...
First play with the game a little bit, and it is quite fun (a little hard but very satisfying when you win, be sure to put it full page): <!DOCTYPE html5> <head> <title>Lights on</title> <script> document.addEventListener('DOMContentLoaded', randomize_and_color, false); function random_zero_or_one() { ...
Part 1 I've followed some of the suggestions: Adding newlines to error messages Implementing options (I decided to use boost instead of getopt) Using strerror for fstream failure Allow multiple files to be compiled (to produce one binary - I wasn't sure if the suggestion meant one binary for each file) Things I did n...
Part of me thinks that it would be simpler to ditch Apple's move API and just updated position with a timer. I know that's what I did with a JS canvas snake game I built a while ago. But I'm also trying to learn the iOS API so unless that's clearly the best choice I'd prefer the most idiomatic way. Also, I'm pretty sur...
I have updated the code and the program now works as it should. If you could critique my code that would be great. I am new to C so I guess I will have made some rookie error :) #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <stdbool.h> // Function to check if alphabet characte...
I have a REST web service that uses OAuth 2 for authenticating and authorizing requests. I have an endpoint, that when receiving the correct credentials, responds with an access token that will be used in consequent requests. This avoids persisting a session and using cookies, which is what we wanted to accomplish when...
I happened to come across one question: Given an integer 'x' (Only positive), write an algorithm that returns integer 'y' such that it has the same number of bits set as 'x' and is not equal to 'x' and the distance |x-y| is minimized. Example: x: 01 y: 10 Now I wrote some bit manipulation as follows and it's wor...
I have the following Greasemonkey script that fetches some data from a Yahoo webpage and injects it into a webpage. It has the feature that it only fetches the data once per day instead of fetching it every single time the page is loaded. I think my displayresults function is a little messy just because it has to acces...
I haven't done much programming in C++, so I figured I'd try making an Optional class. I'm mainly concerned that I didn't follow good conventions or that I didn't use exceptions well. I know that there are no comments, but for now, let's ignore that. The idea is that my Optional class can be used instead of pointers an...
I wrote my solution to Project Euler #18 and #67 in C++ (which I'm relatively new to), and was just wondering what everyone else thinks of it. It executes in 3-4ms and works flawlessly (even for triangles not given by the website). But I'm not a professional programmer or anything, so I wouldn't know if it's necessaril...
This is a text-based RPG game I've made in C++ and would love some review on it. I am a 100% complete newbie with maybe 2 weeks of C++ experience so I'd love some lessons on what I did wrong and how I can improve! I mainly just use a lot of switch statements and if statements. If there is anything wrong or things that ...
I was looking for a unit testing library for C++, and I found many. Unfortunately, I decided I didn't want to use any of them. I decided to make my own. This is the result. I made heavy use of the preprocessor, and followed the convention of leading underscore to mean non-published. Everything is done in all-caps, to t...
When using the pimple idiom it is necessary to represent your "impl" as a forward declared pointer in the header file. This necessitates a lot of boilerplate code to implement the rule of five. Instead, I want to wrap std::unique_ptr with a template class DeepPtr which automatically deep copies on copy construction, a...
This script's only responsibility is to keep a process alive. Forever. It's sole dependencies shall be bash and coreutils. I'm not sure if it would be compatible with sh, that would be even better. #!/bin/bash # # (c) Netcetera AG # Author: Christian Mäder date="10.07.2015" version="1.0" # respawn() { while true;...
This code solves a challenge problem that a local company is hosting to attract/screen applicants. The link to the challenge is here. In brief, we are given a wordlist containing approximately 100,000 words and we are asked to find the combination of words which has MD5 hash 4624d200580677270a54ccff86b9610e. The constr...
squish is an onomatopoeic string function provided by Ruby on Rails that works on strings. Given a string, squish condenses all the consecutive spaces into one.1 (Imagine that you take a string at both ends and compress it with both hands, spaces will be merged and you will hear the typical squish sound). I went I litt...
I made a program that contains a root-finding algorithm for polynomials as a function and contains 3 test polynomials. The algorithm is Brent's method and is based entirely off the pseudocode from Wikipedia. Is there anything I should change to make the code faster/easier to understand/etc? The code does run and prints...
The situation is that a certain asynchronous operation is called multiple times, which is basically to consolidate results. But I want to abort every time a new request comes in, which means that only the last call will run completely. Does this solution look reasonable? I have tried replicating the process in a test p...
From: Principles of Computing Part 1 Course on Coursera I got -2 pts on my OWLTEST which uses Pylint for style guide. The error states: Too many branches (17/12) function "merge", line 7 What does that mean? I worked really hard on making this program work and wrote it from scratch. I would also like to know i...
I'm currently working on an implementation of a CSRF protection. What is the best practice when we detect a CSRF? Is it better to 404 the page, 403 (forbidden), 200 (OK) with an error message, something else? Bonus : here's my code. I'm not very proud of the preg_replace and ob_*. If you also have suggestions on how to...
#!/usr/bin/python file=open("C:/python27/python operators.txt","r+") wordcount={} for word in file.read().split(): if word not in wordcount: wordcount[word] = 1 else: wordcount[word] += 1 for k,v in wordcount.items(): print k, v
Now I have this circular array-based list in C. Circularity allows pushing/popping to the both ends of the list in constant amortized time. Inserting/removing at random locations runs in linear time, yet I optimized it a little bit: Suppose we are inserting an element at arbitrary location. We can shift the left elemen...
This is a update of this question since the requirements for this task changed. I have a function that takes a description as a String and returns a shortened version of the description. The shortening is done by checking if a word matches the key of the Map<String,String> MAPPER and replaces the word by its abbreviati...
Summary I am experimenting with a plugin pattern for a generic Python application (not necessarily web, desktop, or console) which would allow packages dropped into a plugin folder to be used according to the contract they would need to follow. In my case, this contract is simply to have a function called do_plugin_stu...
Recently I had an interview project, which I did and sent, so this question is not for avoiding thinking. I am just struggling to build my own opinion about it so I decided to ask in public. My question in general is that: is the code design is too complex? I know the opinions may vary, but in general: do you PHP prefe...
In simulating physical equations (such as fluid dynamics) it is common to write an application that deals with 1, 2, and 3 dimensions. A common C/Fortran approach is to make all vectors (for example) have a size of 3, and then to carry around a global constant to say how many elements are valid. We have tried to use C...
I wrote my own version of a search binary tree in Java. Could someone kindly review it? public class Tree { private Node root; public Node find(int id) { Node current = root; while(current != null) { if (current.getId() == id) // Node found retur...
This is an updated version of: Class to manage updates coming in from another thread Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the Presenter be responsible for Thread safety, you can end up with deadlock issues, and also too many little tasks getting sta...
I'm wondering if there is a better (cleaner?) method than my current implementation. I'm currently encoding a PHP SimpleXMLObject (USPS Tracking API) to JSON and looping through said JSON object via JavaScript to operate the front-end. Examples from my current implementation below: Function to display dialog implemente...
I wrote a simple GUI applications to help me select 'positive' regions of a bunch of photos for the purpose of training an object detectir using OpenCV Haar Cascades. For training purposes, you need a series of 'positive' images which show the kind of item you want, closely cropped, and then you need a bunch of negati...
Introduction I am preparing to use a basic script to cover how you can connect to a MySQL database using PDO. This script is meant for educational purposes (introductory class on PHP/MySQL) and does of course not cover all security aspects of database connections. Points of focus Conformity to the PSR-1 and PSR-2 stan...
The given code find the minimum element in a sorted array rotated by some fixed distance. Eg: [1, 2, 3, 4, 5, 6, 7] -> [3, 4, 5, 6, 7, 1, 2] The elements in the array are all unique. Just wanted to check if the code handles all edge cases and is correct. def findMin(ary): def recurse(lo, hi): # Base cases ...