instruction
stringlengths
71
71.9k
I wrote my first Python program today after working through a few books. I decided to build a group initiative tracker for our D&D group and was hoping to get some feedback. Critiques on code efficiency, formatting, suggestions, etc would be appreciated. My plan is to eventually take this from a command-line applicatio...
I have written multi producer single consumer code with bounded buffer. Please review the code for any improvements or mistakes. #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <semaphore.h> #include <string.h> #define SIZE 50 #define PRODUCERS 5 #define TOTAL 2 #define ENTER p...
Assume we have an string that contains the character 'c'. This character can be located anywhere within the string. The exercise is to remove 'c', and the characters that, if they exist, are on its immediate left or right. I have devised an algorithm, assuming that 'c' = '*'. Its flowchart can be found here and the cod...
I've got this working almost to where I want it. The part I can't get right may be due to the programming so I'd like to get a review. I'm making JSON calls to the Twitch API that sends back a list of people who are streaming video on code camps channel on the Twitch website. I have a semi populated array of users to s...
Original question can be found here I took the advice I got to heart, and re-wrote it. Once again I'd appreciate any advice as to how I can improve this using best practices. Jar.java package com.tn.jar; public class Jar { private String itemName; private int numberOfItems; private int numberToGuess; ...
I'm new to this competitive programming world. This morning I came across this question, which required the time to be less than 1 sec. But my code runs for 1.000069 sec, thereby rejecting my solution. Question: There are N chocolate boxes, and you will be given with a chocolate index for which we have to guess the co...
I'm creating a web page which has two types of users with very similar permissions: Person and Company. The main difference is in their attributes and probably different billing. I've created only one UserProfile for both types of users. What do you think? Is it safe? Should I expect some problems later because of this...
In order to divide an IEnumerable in C# by a predicate, I implemented the following (in a static class): public static IEnumerable<IEnumerable<T>> SplitBeforeIf<T>(this IEnumerable<T> input, Func<T, bool> pred) { //This exists to store the predicate satisfier, which I kept as //the first T in the inner IEnumera...
I've been developing a simple CMS both for practical use and learning about Laravel, and I decided to implement a simple service that makes it possible for the administrators to send messages to one another. However, the finished JavaScript code, while completely functional, ended up being a bit sketchy so I'm looking ...
I am new to Java in general, but wanted to get some input on the code for a CS class I am taking. It is a program that plays the Hi-Lo guessing game with numbers. A user may choose to quit mid-game by entering 0 and then they are prompted to play again if they choose. If they guess correctly, they are also prompted t...
My program will divide the decimal (\$30.0575\$) by a range of fractions (\$\frac{1}{1}, \frac{1}{2}, \frac{1}{4}, \dots, \frac{1}{48})\$ leaving me with list of improper fractions that look like this: \$\frac{1}{1} * 30.0575\$ \$\frac{1}{2} * 60.115\$ \$\frac{1}{3} * 90.1725\$ \$\dots\$ \$\frac{1}{48} * 1442.76\$ My...
Challenge: Given an array arr, find element pairs whose sum equal the second argument arg and return the sum of their indices. If multiple pairs, that have the same numeric elements but different indices are possible, return the smallest sum of indices. Once an element has been used, it cannot be reused to pair with an...
I'm just trying to learn the basics of React and Flux, and the above code works and I can see it works nicely. index.js import React from 'react' import ReactDOM from 'react-dom' import UI from './components/ui.js' ReactDOM.render(<UI />, document.getElementById('ui')); component/ui.js import React, { Component } fr...
I started this because I thought it would be a fun and easy way to brush up on my C++. It turned out to be a lot more complicated than I thought. I learned about std::allocator and move constructors and other things I had never seen before, so it was a good learning exercise. The interface is based on std::vector, thou...
I have written this PrimeFactorize utility method in C# (using LINQPad) which works fine, but feels like it is a bit slow, I was wondering what might be improved. Also looking for any criticism not related to efficiency to make the code better. // Generate prime factors for a number, e.g., input 12 returns 2 2 3 public...
I wrote a Java FX application that translates binary to and from String and numbers in Java. Whenever the program is translating large amounts of text to binary it takes a very long time, and leaves the application unresponsive. Could a more efficient algorithm be used to speed up the process? // Turns binary into...
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 10 001st prime number? How can I make this more efficient and cleaner? public class Problem7 { public static void main(String[] args) { // a prime factor is something that can divide by only...
I have a login method in my controller. I would like to get rid of the imperative "thinking" and write something more functional. def login(conn, %{"login" => %{"password" => password}}) do conn = conn |> fetch_session if count_attempt_login(conn) <= 10 do conn |> attempt_login(password) ...
I started a tutorial online to get a little bit more knowledge about views. But after I did the basic I decided to finish the game. The game is a little "I spy" game where the user tries to guess the item loaded in a picture on the screen. They are been helped with some hints showed at the bottom. The user has 3 tries ...
Original Problem: HackerRank I am trying to count the number of inversions using Binary Indexed Tree in an array. I've tried to optimise my code as much as I can. However, I still got TLE for the last 3 test cases. Any ideas that I can further optimise my code? # Enter your code here. Read input from STDIN. Print outpu...
I'm doing an exercise, and would like to know if what I'm doing is correct and follows the correct structure for rollback in case a transaction fails. I would like to know as well if my try...catch statements are well implemented. create procedure spTeste2( @tit1 bigint = 111, @tit2 bigint = 222 ) as begin try ...
Basically, here's the problem statement: Given an IEnumerable<T> source and an IEnumerable<T> exceptions, return an IEnumerable<T> result which contains all of source, without exceptions, only omitting exact instances of a value. I.e.: if a value appears twice in source, but once in exceptions, then result will have t...
I have written this to practice Test Driven Development. I would like to know if the process is right and how it could be improved. Problem Statement : A wizard can cast spell on goblin and make his size big, normal or small. He can also make the goblin visible or invisible. In addition to this, the wizard can keep tra...
I've written a Ledger class for a daemon process, which is supposed to keep track of an exchange's orderbook. My main concern is the way I keep track of the orders - more precisely, the containers I use to store them: a combination of set() and dict() appeared like the most feasible solution. However, I'm wondering If...
I use the gem act_as_votable to allow users to select categories they like. To get the categories a user likes: current_user.get_voted(Category) These categories have children categories, and I need to find the posts in those children categories. I use this line to do it: @categories_posts = current_user.get_voted(C...
I'm a Go (and programming in general) newbie and the task was to program a Go server that would accept incoming messages, take each line, reverse its order and case and send it back. Besides doing that I also wrote a client (just for the hell of it and to help me test my server). I wonder if some things could've been d...
I was reading this code where author claims that its the fastest implementation which I doubt, hence I decided to write my version of the same problem. 'use strict'; module.exports = function unique(arr) { if (!Array.isArray(arr)) { throw new TypeError('array-unique expects an array.'); } return arr.filter(f...
My code given below will produce the correct output but it tends to take way too much time with larger data thus timing out for some of the test cases. I've linked to the problem description here: It's New Year's Day and everyone's in line for the Wonderland rollercoaster ride! There are n people queued up, and each p...
var argon2 = require('argon2') var nano = require('nano')('http://127.0.0.1:5984') var users = nano.db.use('users') var private = { generateHash: (password, callback) => { argon2.generateSalt().then((salt) => { argon2.hash(password, salt).then((hash) => { callback(hash) }) }) } } var ...
This is the problem statement. I have submitted successfully a \$O(n^2)\$ solution and I would like to know if there is a way to improve the running time to, maybe, \$O(n \log n)\$. Having dropped out of school because of chemistry, Luka got a job driving trucks. One evening he parked his three trucks in a rest area...
I'm learning Ruby 2.3 and I've tried to implement a function which performs the Luhn credit card verification algorithm on an input string, returning true if it matches and false if it doesn't. def luhn(card_no) card_no.split("") # Break into individual digits .reverse # Start from the end ....
I need a code review for my first jQuery plugin. It seems like a lot of code and I want to hear something about my plugin code structure and more. ; (function($) { 'use strict'; $.fn.mpopup = function(options) { //Default settings var defaults = { overlayClass: 'mpopup-overlay', overlayColor...
index.php,general message.php, logout.php, site life.php (this page for session and put it in the other pages by required) Database: connection.php <?php $dsn = "mysql:host=localhost;dbname=mg"; $username = "root"; $password = ""; $options = array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ); try{ $conn = ne...
I'm working through Cracking the Coding Interview. The first challenge is to implement an algorithm to determine if a string has all unique characters. I've gone through several iterations, but here's my "final" solution. I've made several assumptions: We are considering case-insensitive strings. We are only consider...
This is my first Python project, so: create a pot with dimensions (radius, thickness of wall, thickness of base, height), fill it with food (to a specific height). Determine the ratio between the volume of the food and the volume of the (metal in the) pot. I am aware that this code does not take handles, rims, dents an...
I've been experimenting with how to pass my managed object context throughout my application in Core Data and I came across an approach that I'd like reviewed. I've been creating a protocol for all of my View Controllers that need a managed object context to implement: protocol ManagedObjectContextProperty { var ma...
I already have two versions of this code reviewed (thanks @Bobby). They can be found here and here. The question is still the same. The goal is maintainability and following best practices. Jar.java package com.tn.jar; import java.util.Random; public class Jar { private String itemName; private int numberOf...
I have the following snippet code which, within a loop, creates a JavaScript object where some of the properties maybe undefined: reader.on('record', function(record) { let p = record.children; let player = {}; // below we create a dynamic key using an object literal obj['name'], this allows use to use ...
I have a class (Patient) with many instances.. I need a way to share the instances with other users, so I thought of converting the instance into a string and sharing it, then reconverting it into an instance From instance to string func ToString(pt: Patient) -> String { let myarray: [String] = [ pt.id, ...
I have a combobox with two items. And if one is selected I want to write data to "salary" table and if selected another, to "other" table. The difference between two code blocks is only one word. I would like to know how I could avoid repeating same code twice. string myConnection = "datasource=localhost; port=3306; u...
I just started programming and have taken too much time to code the solution for this problem: In this problem you will test your knowledge of Java loops. Given three integers, \$a\$, \$b\$, and \$n\$, output the following series: $$a + 2^{0}b, a + 2^{0}b + 2^{1}b, \ldots \ldots, a + 2^{0}b + 2^{1}b + \ldots + 2^{n...
I know B+ trees are not meant to be use in memory, but I just implemented it as an exercise. I'm looking for a general review. #ifndef B_PLUS_TREE_H #define B_PLUS_TREE_H #include <vector> #include <algorithm> namespace mds { template <typename T, typename D, typename Func = std::less<T>> class b_plus_tree { ...
I'm wondering if this code can be optimized in terms of time complexity. The problem is checking to see if a string has all unique characters. #include <iostream> #include <string> using namespace std; //Assuming ASCII bool checkString (string user) { if (user.length() > 256) { return false; } ...
I have written a small Brainfuck interpreter in C. More recent version hosted here. I have found it very hard to test my interpreter because writing a program in Brainfuck is somewhat hard (or at least very tedious) and many snippets I found online either don't give output or do so very cryptically, so I don't know 100...
As practice with the (ever so painful) C Strings I wrote a string reversal program. I am new to C, so I wanted to make sure that I am not using bad coding practices. It runs just fine (at least with expected input), but I am not sure if the logic is as good as it could be. #include <stdio.h> #include <stdlib.h> #inclu...
I need some advice to improve my Triangle class. I know some of my code is sloppy, such as in the Triangle constructor. can someone give me advice on how to improve it? #pragma once #include "Shape.h" #include <algorithm> class Triangle :public Shape { std::vector<Point> _vertices; float _a, _b, _c, _s; publi...
My code works, but I need help on revising it to make it shorter and simple if possible on my main.cpp part ONLY. The other files is to make the program compile and work out if you want to see the output. main.cpp: #include <stdio.h> #include "bintree.h" #include <string.h> #include <list> #include <stack> #include <st...
I'm just wondering if you would consider this to be safe from SQL injection. A peculiarity of my program is I need to dynamically access table names depending on my scenario. This is not for publishing online, but I wish to know if this approach is any good. I'm using Python3 and SQLite3. My database object contains th...
Here is my code which implements a undirected graph in java. I'm fairly new to java(I come from C) and I am not sure if this is a good implementation. Here are a few things i worry about - Did I use encapsulation in the correct way? Did I overuse/underuse it? Is this a good way of implementing a graph given that i wa...
I have this simple cache mechanism for a repeated task in service. It uses static variable to store the information. Please suggest on how is it and if it could be better. Premise: I need to verify transaction from stores. There can be lots of transactions happening repeatedly from multiple stores. Thus, this simple ca...
I have some program which takes input via stdin, writes output to stdout, and errors to stderr. I would like to call that program from another program, supplying data via stdin, and capturing output/errors via stdout and stderr. I have written the below, which seems to work fine - however, I don't know if this is the...
I recently answered a question on Mathematics Stack Exchange, where I used a small Python program to check the following : For all 6-digit numbers, with all digits being different, choosing the digits one by one from left to right, the second last digit can always be chosen so that the number will never be a prime. In ...
I have an up-down numeric control on my form (attEdgeUpDown), which has value 0-8. I have eight checkboxes (attEdgeBox1 to attEdgeBox8). I want to display as many boxes as the numeric control shows. Can this be done more efficiently? private void attEdgeUpDown_ValueChanged(object sender, EventArgs e) { int edgeValue = ...
See Problem - 151B - Codeforces for details. I think I have been very messy with using the Streams. Can you review for a good and better implementation with Streams? Any other improvements? public void solve(InputReader in, PrintWriter out) { int n = in.nextInt(); List<Person> ps = new ArrayList<>(); for (i...
I would like feedback on the class I've written. The purpose is to dynamically create and interact with SQLite3 databases, accepting lists of complete or incomplete statements. import sqlite3 class DB(object): """DB initializes and manipulates SQLite3 databases.""" def __init__(self, database='database.d...
I'm a beginner Python (2.7) programmer, and I've just started solving basic problems on SPOJ. I correctly solved the ADDREV problem (http://www.spoj.com/problems/ADDREV/), however my code takes 0.06s time and 8.8M memory to run. The top Python 2.7 rankers for the problem take <0.005s and 4.00M. Since I am starting out ...
I partially refactored the code so okFields uses the extracted function checkStringLength. Now I also want problemFields() to use the same refactored function, but there is a difference between how okFields and problemFields use the function: you see that the problemFields has a little ! in front of validator, and I do...
I'm implementing a simple merge sort to practice with Python's Threads. I've tried to split the job into two threads, that sort normally, then I can join them and merge the result. However, it takes almost twice as long with two threads than it does with the "normal" algorithm. Did I do something wrong or is it normal ...
So I have this sub query: *(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')* And I was using it 3 times to get the same value. In this SELECT statement: Select a, b, c, d, price *(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 as RealTVA...
Here comes the next round. I've implemented some of the suggestions from the previous review. That being said, though, there are a few things that I have on the horizons but haven't yet put in that were suggested. I am currently working on implementing dependency injection so that the database object is not redundantly...
I was asked to complete a coding challenge for an interview. The challenge being to write a test function to check whether or not a string was a broken record. A broken record is defined as a string that contains a sequential repeated substrings. For example: # These are broken records "This is is a broken record" "Thi...
I've created a small class to generate unique random strings. It works fine. I also want to log the collisions of the generated strings. I check if the generated string is in the array for uniquness: public static function add(&$array = [], $length = 1) { $hash = self::rand_str($length); while (in_array($hash, ...
I have created a few extension methods to get the direct reports of a UserPrincipal as UserPrincipals themselves. This saves the user of the API quite a bit of typing. public static IEnumerable<UserPrincipal> GetDirectReportUserPrincipals( this UserPrincipal userPrincipal) { var directReportDistinguishedNames =...
My background is medical, but I required a program that calculated whether my patients are "normal" or 1-2 SD values away from the mean. The program works just fine, but I'm interested how I can do better. (This all was made after I started learning python a month ago, so please be kind) I'm particularly interested in ...
A continuation of Memoizing decorator with retries, part 2, and related to https://codereview.stackexchange.com/a/133493/47529. I liked my decorator before, but especially in my original use case of a spotty network connection it makes sens to allow for some delay between attempts. The specifics of this delay should be...
I have a Word VBA script that auto-generates a table caption based on user input & a previous heading. Its purpose is to speed up editing & formatting of massive software documents (like the 1000+ page test procedure I'm currently reviewing). At this point, it's slightly quicker than scrolling back up, copying the head...
The code below is the BLL and the DAL logic for the form submission with multiple pages. A form will have more than one page, will have a button on every page until it reaches the final submission. For the first page when submitted,the following actions need to be done. Database table 1 should generate a RefNo RefNo ...
I've been writing a brainfuck interpreter in python 3. It's nothing serious, but I'm trying to make it as good as possible (considering program structure, user experience and etc) for my own learning purpose. Any suggestion is welcomed. """A brainfuck interpreter written in Python 3.5.""" import argparse __all__ = ['...
The title pretty much explains everything. I'm try to check if a line in a file contains user.Handle and '-r'+any single digit number, AND that the aforementioned user.Handle does not contain '-r'. I'm sure there is an easier way to do this. And I'm sorry if this made your eyes bleed. if (line.Contains(user.Handle) && ...
I am an absolute beginner. This is the first thing I've ever coded in VBA. I don't know if I'm allowed to ask for just criticism in general without a question. But just in case I can't, this file is going to get very large and I imagine I will have resource optimization problems - so what should I have done differentl...
This function derives a 'stars' rating from a product score that is retrieved from local storage. What would be the best way to refactor these else if statements? $scope.ratingStars = function(productID) { var bottomLine = $filter('filter')($localStorage.bottomlinesObject.bottomlines, {domain_key:''+produ...
I need to know if I am going in the right direction with my code so far. I am really trying hard to transition from procedural, page-based programming into OOP MVC. So far I have written a simple router, and MVC for updating users. First, my index.php file acts as my bootstrapper. index.php: // start session session_st...
Here is my code for checking to see if two strings are anagrams. This seems a little short. Am I missing anything? Both time and space complexity seem to be \$O(1)\$. //Determine if a string is an anagram //Time complexity: O(1) //Space complexity: O #include <iostream> #include <string> using namespace std; bool an...
I have made a multi-platform Snake clone in C++ using OpenGL and GLUT. I am a beginner in graphic game development. I would like to add more features, but I have programmed the base game so far. I would love it if you could review my code and tell me how to make it better. #include <ctime> #include <deque> #include <GL...
I just wrote a cows and bulls implementation in Rust. It seems a little large. Are there any changes I could make while still keeping it easily readable? extern crate rand; use rand::Rng; use std::{io,process,str}; fn input_check(s: &str, size: u32) -> bool{ //Check if number is positive valid number let mut r...
This is a problem from Project Euler and on Hackerrank (here)- 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible (divisible with no remainder) by all of the numbers from 1 to N? Input Format Fir...
I would like to use C to implement the following formula: $$\mathbf S(u,v)=\sum_{r=i-p}^{i}\sum_{s=j-q}^{j}N_{r,p}(u)N_{s,q}(v)\mathbf P_{r,s}$$ Namely, $$ \left(N_{i-p,p}(u),\cdots,N_{i,p}(u)\right)_{1\times(p+1)} \begin{pmatrix} \mathbf{P}_{i-p,j-q} & \cdots & \mathbf{P}_{i-p,j}\\ \vdots& \cdots &\vdots\\ \mathbf{P}...
Could this code be improved? Would you suggest more sophisticated way of doing client-side signup validation? <!DOCTYPE html> <html> <head> <script> function validateForm() { var name = document.forms["registrationForm"]["username"].value; if (name == null || name == "") { ...
Part 1 here. I improved my code from my previous question (linked above). using System; using System.Collections; using System.Collections.Generic; /// <summary> /// Used to store data as bits. Acts as a queue - first data added is the first data removed. /// Data should be read in the same order it is written. If rea...
I'm a beginner and self learning programming students. While learning binary tree data types, for the sake of understanding graph theory and other interesting programming problems, I've writen the below implementation. Would you please suggest if there's anything wrong or either this can be improved. It may seem rein...
I've implemented an identity function (well, actually a functor struct) in C++. The goal is that every occurrence of an expression expr in the code can be substituted by identity(expr) without changing the semantics of the program at all. I make it a struct with a templated operator() instead of simply a function templ...
I tried to implement a queue using two stacks. I saw there are questions about this topic, but in my example, I used build-in stack from java. My question is, can someone give me some advice to make my code more efficient or better (in turn of class structure, for-loop, etc)? This is for practising and understanding ho...
Although my code works as expected, there are a few gotchas. A single row is not filled at once; instead, I can see partially filled rows during the rendering process(Fixed in the updated code below.). The application still feels slow; can it be optimized further? And the biggest thing, how can I make the code more OO...
I am currently using Python 3.5.2 to create a connect four basic game. My game should work for two players and tell you when you have won, be it horizontal vertical or diagonal. However I do not know how to make my code smaller or more efficient, is there a way to cut down, or is my method just not very efficient in it...
This is my improvement of a minesweeper game I took from the internet, which I am quite proud of. Nevertheless I am willing to hear your opinions, suggestions, and comments. /* Minesweeper V2.0 Written by:-Shivam Shekhar Improved and understood by Eshel BM*/ #include<windows.h> #include<stdio.h> #include<conio.h> #in...
I'm working on a node.js bindings for libcurl. As libcurl accepts many callback functions as options (like CURLOPT_READFUNCTION for example), I had to store their respective javascript callbacks somewhere when those options were set. Initially I had the following class members (Easy.h:71): Nan::Callback *cbChunkBgn; Na...
What are nonogram tables? Nonograms, also known as Hanjie, Picross or Griddlers, are picture logic puzzles in which cells in a grid must be colored or left blank according to numbers at the side of the grid to reveal a hidden picture. There are two kind of nonogram tables, ones with only one row and column, and kinds...
I'm currently working on my first project and I have been programming in python for 4 days now. I currently have a dilemma where my code is running too slowly. I don't want you to make a full review, I am mostly interested in advice on how to optimise my code. Here is my code: Note that the comments aren't perfect Engl...
My code creates a "grid" of empty places, where 0 is used as the place holder, in a size specified by the user. I was wondering if there were more efficient ways of doing this,or perhaps ways that make more aesthetically pleasing grids with less code. My code is in working order and does as it says on the label, I also...
I've gotten a lot of feedback about my tracking system already. So now I'm changing gears and looking at my email generation system. I have a class called Email which manages the sending of emails, validation of user email addresses, and validation of whether the user is a permissible "victim". To do this, I created a ...
I'we created an interface that communicates with Postman collection and Jira api more precise the Xray addon for jira. I would much appreciate if you could give me notes on how to improve this code. Adding variables in constructor, too loosely maybe. Function add_steps_to_test_case_v1 and add_steps_to_test_case_v2 cou...
I am fairly new to C++ programming and I, so far, love it. I just have been trying to make sure what I am doing is fast, unique, readable, and efficient. Is there anyway I can improve this code, or is there ways I can improve my coding convention (in C++)? Here I wrote a program that generates a 20 random vectors of bi...
Yesterday, I gave an interview after a long time, and I was asked a question which I couldn't solve on the spot. I had to implement a sort function for a Array of strings in JavaScript, with the following requirements: The Array will always contain Strings For sorting, Upper Case has higher priority than Lowe Case Let...
This function of my program is searching a file that is formatted as first_name last_name rate hours: John Smith 25 80 Mary Johnson 15.5 60.0 ... With one space between each item. The user enters the first name and last name of the employee and while the line is not equal to null it searchs for the employee. If its f...
I have a seemingly simple issue. Consider this list: a = [[12.0, 5.0, 63.0], [0.1, 2.0, 7.1, 3.0, 2.3, 5.0, 8.4]] I want to find the mean (using numpy) of all the elements in its sublists combined. In this case the result should be: 10.79 obtained as: np.mean([12.0, 5.0, 63.0, 0.1, 2.0, 7.1, 3.0, 2.3, 5.0, 8.4]) The...
I have the following bash script that: Finds all files with .cfc and .cfm extension and converts them to lowercase Stores the relative file paths to those files (filenames.txt) Chops those files to get only the name, excluding the extension (files.txt) Loops through 1500 files checking for references to any of the oth...
I have a simple Angular application that lists some object requests from a backend, allows the users to click once to edit the item, and then click again to update the object in the backend. Here's a Codepen demonstration. I've replaced the backend service in this Codepen to return a $q promises, rather than making act...
Task: This function searches given null terminated string pStr by given subset of regular expression pMatch. Return value is matched string appeared in pStr. If nothing has matched, return value is empty string. The subset of regular expression grammar is defined as follows: A string is set of 8-bit characters. Beware...
Was fiddling with java-8; trying to write a program for getting all Armstrong Numbers between 1 and 10_000_000. Following is my working solution: public class ArmstrongNumbers { public static void main(String[] args) { IntStream.range(1, 10_000_000) .filter((n) -> { int ...
Following code has some issues: $args = func_get_args(); $paths = array(); foreach ($args as $arg) { $paths = array_merge($paths, (array)$arg); } $paths = array_map(create_function('$p', 'return trim($p, DIRECTORY_SEPARATOR);'), $paths); $paths = array_filter($paths); return DIRECTORY_SEPARATOR . join(DIRECTORY_SE...