instruction
stringlengths
71
71.9k
From SICP Exercise 1.28: One variant of the Fermat test that cannot be fooled is called the Miller-Rabin test (Miller 1976; Rabin 1980). This starts from an alternate form of Fermat’s Little Theorem, which states that if \$n\$ is a prime number and \$a\$ is any positive integer less than \$n\$, then \$a\$ rai...
I have some code where the purpose is the decide if a char is between quotes in an expression. For example, awk '{print $1}' has a { between quotes. The function that I want to test is int IBQplain(int pos, char *str, int offset); int IBQdouble(int pos, char *str, int offset); int IBQsingle(int pos, char *str, int o...
The third post in the Code Explorer series is about the UI and main VM. This is the XAML, except a few hundred lines of styling: <UserControl x:Class="Rubberduck.UI.CodeExplorer.CodeExplorerControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.micro...
I have a json file which needs to be restructured. The following is the code. while IFS='' read -r line || [[ -n "$line" ]]; do COUNT=$(( $COUNT + 1 )) #echo "[$COUNT]" [ $COUNT -lt 5 ] && continue sj=`echo $line | jq ._source` index=`echo $line | jq ._index | tr -d '"'` itype=`echo $line | jq...
To brush up my C I decided to do some OOP programming in C. I have never tested this before, but I was curious to try it since seeing an example of it a while ago. I decided to implement a simple hash table. My first approach was to give each instance of the object its own methods, i.e. pointers to functions, but this ...
This is a follow up of Simple, generic background thread worker class What changed? Moved from synchronized lazily evaluated static instances to true Singletons per the on-demand holder idiom https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom Added a constructor to auto-start the Thread. Why is this ...
I was solving the DIVFACT problem from Sphere Online Judge: Given a number, find the total number of divisors of the factorial of the number. Since the answer can be very large, print the answer modulo \$10^9+7\$. Input The first line contains \$T\$, the number of test cases \$T\$ lines follows each containing the ...
(Note: this is originally posted as this SO question ) I'm trying to refactor the error logging and exception throwing into a method. Original code: private Box retrieveBox() { BoxParameter param = new BoxParameter("red", 10, 5, 3); List<Long> boxIds = boxDao.retrieveByParameter(param); if (boxIds.isEmpty...
For a while now I've been meaning to post some of my Haskell code here so that someone can tell me what parts of the language/base library I've been completely overlooking. This is the first thing I've brought into a "working/finished" state that isn't a PE problem, and unfortunately it is a tad big. It is rather mathe...
Here's my solution but I am looking for ways to improve the time complexity of solution. Also this question is categorized as being solved by stack so I would like to know how to approach it using stacks? Problem statement: Given n non-negative integers representing the histogram’s bar height where the width of each ba...
Is there an easier way of importing data into an Excel array or other data structure? I've tried researching collections but I have found the documentation hard to comprehend. MSDN The code I have opens a select file and searches for the column header and then loops through each row storing the data according to header...
This script reads records from a CSV file of customer names and addresses. The first record of the file is the header (field names); the fields could be in any order, and sometimes have different variations on the field names. I import the header into a one-dimensional array of field names, and use this loop to assign ...
I built a 404 page which involves parallax scrolling text. The program updates the position of 100-200 text nodes at each animation frame called with window.requestAnimationFrame. It runs decently well on my MacBook (although it occupies significant CPU), but on weaker computers like my phone, it runs very sluggishly. ...
EDIT: I've created a repo and uploaded it to Maven (still in dev though). Any suggestion or pull request is more than appreciated. :) https://github.com/enrichman/vigenere I had the need to write a simple encryption algorithm (no security needs, it just needs to look a bit random) and I thought to add a bit of random ...
This does what I want: function test(data){ for(var key in data){ if(/_is$/.test(key)){ var obj = {} obj[key] = data[key]; return obj; } } } test( {a: 'a', user_id_is: '1', b: 'b'} ) > Object {user_id_is: "1"} But 8 lines of code for such a simple task looks ineff...
I'm sure that my server can work with better performance, but it's just a dream. Parsing a very long strings is not so obvious task for me. I have a server that handles a lot of clients requests and finds a substring of a string. Server package api import ( "net/http" "stackexchange/api/controllers" ) func st...
I want to create a simple CRUD app using angular on the frontend. I'm not really happy with the logic here, it seems a bit convoluted for fairly simple functionality. <div class = "container-fluid"> <div id = "table" class = "row" ng-repeat = "o in objects" ng-init = "o.isBeingEdit = false"> <...
The following code is designed to be a multidimensional array that works off of a continuous block of memory. It is designed to be able to be resized at runtime, but only when a resize is explicitly requested. #include <memory> #include <cstddef> namespace detail{ //frame buffer class: represents a 2d array of au...
Here is my code to create a definition text from 3 arguments. Is there any way to make it work with better performance and look nicer? private const string IllegalCharacters = "\\" + "\"" + "'#,.[]{}" + " "; public static string CreateDefText(string mainId, string secondaryId, string extraText) { ...
I've made this function to map alphabetic coordinates to their corresponding ordinal number. var exec = document.querySelector('#exec'); // Maps alphabetic characters to their index // within the alphabet. // -------------------------------------------- // @param { string || array } chars - String // cons...
This is the "Minion's bored game" problem from Google's "Foobar challenge": There you have it. Yet another pointless "bored" game created by the bored minions of Professor Boolean. The game is a single player game, played on a board with \$n\$ squares in a horizontal row. The minion places a token on the left-most squ...
I am writing a Model to read, write and store settings. I think my code is pretty good, but I am not 100% sure. Any advice on how I could possibly improve it is welcome. import ntpath import yaml class Settings: def __init__(self, paths=None, default_path=None): """Load, write and store settings ...
Problem: Given 2 strings, consider all the substrings within them of length len. Len will be 1 or more. Returns true if there are any such substrings which appear in both strings. Compute this in linear time using a HashSet. I know as a matter of fact that there are many areas upon which my code could be impro...
This was my first foray into a Tkinter app and so I chose a simple and certainly overkill task to make into a gui. Aside from one small aspect, this code functions as I was intending and seems to have adequate performance. I'm looking for help to make it more pythonic, not by simply pep8-ing it but by helping me better...
I have written a script, that reformats the output of qstat -f1 of the PBS queueing system. Unfortunately this project is by far too big to post here complete, also I am still working on it. The purpose is to have a quick overview of what is running by whom and what resources are blocked. I am am also using chains, whe...
This is an update from here. This tool is a Windows Form application that can add fields and scripts to PDF files, as well as convert Microsoft Office Word documents to PDF. The usage is as follows: User opens program and presses "Select Files" button. A dialog opens allowing the user to select one or more Word docume...
I grabbed the form from some random site because I'm only interested writing the javascript at the moment. I am trying to check that a user has selected or entered text for all fields. I've made it a long if if-else but that can't be the best/most elegant/easiest solution. Leaving aside the radio button validation for ...
I hope this is the right place for this. I basically wrote the below script for a SharePoint 2013 where I needed to get the department of the currently logged in user. I was finally able to get it working, but I am not happy with the structure at all: // globals var currentUser; va...
I'm trying to learn Rust and am a beginner. How does one go about implementing a generic version of the Fibonacci sequence without using Copy trait in Rust? My code is given below. I had to use Copy trait, otherwise the compiler would complain cannot move out of borrowed content [E0507] in the method next() (everywh...
I have a similar problem as in this mail. I want that every time I return the same C++ managed object to Python, I get the same PyObject. With the standard converter I get always a new wrapper-PyObject. The solution should fulfill the following requirements: get() == get() (the Python object is always equal, whatever ...
I have a project here that looks pretty good and does exactly what I want it to do. The codepen is here. What I need to find out is if these divs that flip can be shortened in any way: <div class="flip-container" id="flipcontainer"> <div class="flipper" id="flipper"> <div class="front" id="front"> ...
Memcache get and set can hit a race condition if you use them together to achieve something like locking because it is not atomic. A Simple memcache locking logic using get and set would look like: def access(resource): if memcache.get(resource): return "Access Denied" else: memcache.set(resource,...
"Funny String" problem from Hackerrank Suppose you have a String, \$S\$ of length \$N\$ indexed from \$0\$ to \$N-1\$. You also have some String, \$R\$, that is the reverse of \$S\$, where \$S\$ is funny if the condition is \$\left|S[i] - S[i-1]\right| = \left|R[i] - R[i-1]\right|\$ is true for all \$i \in [1, N-1]\$....
I'm considering an application where a large data needs to be written to file often. I would like to use a queue and have a producer and consumer running on different threads. Additionally, I would like to have a fixed size queue as the data size can be very large. I've implemented a simple test of boost::lockfree::...
I'm currently working with an SDK where methods return an optional array of objects with optional properties. Only the array itself is optional, it will either be nil or always contain non-optionals. I'm struggling to find a cleaner way to unwrap optional properties for each non-optional in the array: class Person { ...
I am a new SO/SE user and I initially asked this question on SO, but i was 'sent' here -for some reason i don't clearly understand but anyway- so here I am..! I was actually curious about my require.js setup, cause it is the first time I 'm using it and having seen many different approaches/examples, I am not sure if ...
// The DataLayer to MySQL require_once $_SERVER["DOCUMENT_ROOT"] . "/api/DAL/classes/User.dal.php"; class User { public $id; public $name; public $age; public function __construct($id = null) { $this->dl = new UserDAL(); // Get an existing user object if (!empty($id)) { ...
Problem statement Phone Number Write a program that cleans up user-entered phone numbers so that they can be sent SMS messages. The rules are as follows: If the phone number is less than 10 digits assume that it is bad number If the phone number is 10 digits assume that it is good If the phone number is 11 digits and...
I've gone through previous questions about implementing hash tables in python, but I have something little more specific. I am handling collisions with linear probing, and I want to grow/shrink my table when I go below/above a given loading factor. My put/get methods are heavily based from this source. I would like to ...
Just checking if I could still do it: #include <iostream> #include <algorithm> std::size_t getParent(std::size_t n) { return (n - 1) / 2; } template<typename I> void heapify(I begin, I end) { std::size_t size = std::distance(begin, end); for(std::size_t loop = 1;loop < size; ++loop) { std::...
On Monday and Tuesday I started learning Erlang through the Erlang Koans, and around Wednesday night I decided to use my newfound knowledge to implement a simple text editor (Akin to ed(1)). Currently I have the following (also on GitLab): -module(text). -compile(export_all). %% State => {file, buffer, cursor} main() ...
How can I optimize this code Header File: #pragma once #ifndef Account_h #define Account_h #include "stdafx.h" #include <iostream> #include <string> #include <fstream> #include <iomanip> #include <assert.h> using namespace std; struct Birth_Date { int Day; int Month; int Year; }; struct Name { // Nam...
I wrote some classes to convert some documents (PDF, DOC, DOCX and TXT) to only text so that it can be stored in a search engine. Here's how I use those classes : $file = 'text.doc'; // comes from the user, hardcoded for the example $file_extension = pathinfo($file, PATHINFO_EXTENSION); switch($file_extension){ c...
I have a task in my program that is inserting thousands (94,953 in one instance and 6,930 in another) of records into my database using Entity Framework. Right now I am doing this and calling the .Add() method for each record but it takes about 1 minute to insert the smaller batch and over 20 minutes for the larger bat...
I am trying to read a big file line by line, inspect and cleanse each row and write to either of two output files depending on the outcome. I am using channels for this. I am still quite new to this language so trying to build stuff by looking at examples. I have kept a global count variable which I am printing at eac...
I have a set of validation functions which return a response code along with an error message if the validation fails. Requests can be of three types, and each of them contains a different type of values to be validated. My question is what are the options to avoid the repetitive code, particularly in the message assig...
I just created a simple gallery with scroll. Everything works fine but I'm not sure how should I optimize this code: document.addEventListener("DOMContentLoaded", function() { var smallImages = document.querySelectorAll('li img'); var bigPhotoDiv = document.querySelector('.bigPhoto img'); var scroller = do...
I'm making an Angular web app to solve a pain with traditional messaging my friend and I had, of sending batches of messages (on multiple different topics) to each other every few hours and not having a UI optimized for that style of conversation. I have a few concrete questions (and of course welcome anything else use...
I am a fairly beginner-level programmer, and I have been working through the Project Euler Puzzles. I am currently on Problem #11, which asks to find the largest product of four consecutive numbers (horizontally, vertically, or diagonally) in a grid. I would like someone to look at my code and give me any tips, pointer...
This is one of the projects from freeCodeCamp. It's a game of Simon (a memory game). I would like a review on my code. var generatedPattern = []; var playerPattern = []; var patternLength = 1; var redRef = 1; var greenRef = 2; var blueRef = 3; var yellowRef = 4; function generateNextPatternValue() { if (patternLeng...
Outline I have a form that needs validation. The problem is that the software requires custom validation that depends on multiple parameters. I decided to pass the object into a function which will dynamically give the object the functions it needs to be validated. Then once the validation is completed, I remove those ...
The purpose of this code is to check for errors in my code for a custom shell. In a previous answer, they say that my code didn't have error-checking. You need to check the result of every function that might fail POSIX arithmetic expansion So I've been asking about how to do it. https://stackoverflow.com/question...
I have created a PHP class to print into html easily from an array or object. Using this class, you can get rid of multiple echo blocks or ugly concatenation while working with data arrays to transform into html. class PrintEasy { /** * Print single data item with html * Include variable names within a [...
My today's goal was to create a little advanced mouse clicker in Bash for Linux powered by xdotool. This clicker implements 15 pixel random range in which it clicks for some users not wanting to get caught for some cheating. But that is not the idea. It is just part of it. It may have multiple uses. There may be multip...
To get more familiar with the multi-threading aspects in the Rust language I decided to multi-thread my earlier implementation of The rusty Sieve of Eratosthenes. I have to say that it is probably in a worse state than the code in that question and it has been written a couple of days ago already, it just wasn't put up...
Is this code missing any "Kotlinisms"? I've just started learning Kotlin so I'm not yet familiar with the Kotlin way of doing things. The program will guess a number you are thinking of. package challenges.difficult /** * Created by jbarnes on 04/06/2016. * Challenge: https://www.reddit.com/r/dailyprogrammer/comment...
The question I am attempting to solve (and have solved successfully): What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? (In case you need a link to the challenge.) The purpose of this code review to to see if there are some obvious ...
The code works perfectly fine for me (compiled it in BlueJ and Eclipse) but I was wondering what other more experienced programmers thought of it. I'd specifically like to know if it could be shorter or be made more resource efficient. /** * This program is just a simple addition calculator that can use whole numbe...
In a zsh I want to loop over all files in a configuration files' directory (/etc/myapp/) to source them. The files should be sourced in order and are named with two leading digits 10-early 40-middle 99-last. A user without write permission to /etc should be allowed to extend the list of files and override the global on...
I programmed in Java before, but I feel that I lack the "true way" of programming (OOP concepts, design, algorithm), so I started to learn all of these but I need your opinions and suggestions so I can improve my skills and to be sure that I got all the concepts right. I know that there are multiple ways of doing some ...
I am new to programming (less than a year), and I would like to improve. I solved a problem on CodeWars and copied both my solution and the top voted solution below. I listed specific questions after my solution. I would like to know, what would be considered the better overall solution in a real production environment...
This is a follow up for the 2D Gravity Simulator-like Game question. Since then I have developed my javascript skills further, and now I'm using ES6 mainly. Note that even through this code uses the EaselJS library, the question is principally about its design so no EaselJS skill needed. Also I wanna avoid posting a b...
I am looking to see if my implementation of the removal/deletion method in a binary search tree is sufficient, readable, and runs in \$O(\log n)\$ time. It's been awhile since I've written a data structure and wanted to see if I still had it. The basic structure of my BST is a Node with 3 pointers. A pointer to its par...
I'm currently trying to optimize this class I have for fractal generation. The equation is meant to be pluggable; I have used z => z*z + c so that it's not using the Complex.Pow method (eliminating a method call per iteration). Without changing it from the Complex data type, how else can I optimize this method, and is ...
I wrote up merge sort code for some late night snack. I have gotten it working, but was just looking learn if I was missing anything in terms of efficiency. Could this code be significantly improved in terms of efficiency (space/time/unnecessary checks)? package com.komal.sort; import java.util.Arrays; import java.util...
I am new to programming, and think this code could be improved upon. Any suggestions? #include <stdio.h> #define size 10 void main() { int i,j,ii,jj,arr[size]={1,2,4,2,1,1,2,1,1,2}; int count=0, max_count=0, start_index=0, temp_start_index=0; for(i=0;i<size;++i) { for (j=size-1;j>=0;...
I wanted to see if anyone would like to review the existing code I have for a beginner program that simulates a battle. I have learned a heck of a lot while doing it, and I had a few questions regarding some things that I found worked, but I am not sure on the why of them working. Please do note that this is not finish...
In my ongoing attempts to become a better blog writer I have some written some more code that needs reviewing. Full Source: https://github.com/Loki-Astari/Examples/tree/master/Version1 First Article: https://lokiastari.com/posts/SocketProgramminginC This is a Simple Client Server implementation using RAW Sockets. MakeF...
In my ongoing attempts to become a better blog writer I have some written some more code that needs reviewing. Full Source. First Article. This is a simple C++ wrapper for Sockets. Here the bit I am not 100% happy with is needing to introduce a Socket.tpp file to hold getMessageData(). This is because the function is t...
This is the code I use to dynamically build error messages. Utility.h #ifndef THORSANVIL_SOCKET_UTILITY_H #define THORSANVIL_SOCKET_UTILITY_H #include <string> #include <vector> #include <sstream> namespace ThorsAnvil { namespace Socket { template<std::size_t I = 0, typename... Tp> inline typename std::enabl...
Problem CharGrid The CharGrid class encapsulates a 2-d char array with a couple operations. int countPlus() Look for a '+' pattern in the grid made with repetitions of a character. A '+' is made of single character in the middle and four "arms" extending out up, down, left, and right. The arms start with the middle ...
I've started to go through Node tutorials on nodeschool.io, and the second assignment was to write a program that will count the number of newlines in a file and print it out. My solution looks like this var fs = require('fs'); var file = process.argv[2]; var buff = fs.readFileSync(file); var str = buff.toString(); va...
I have created a Like/Unlike system. The user clicks one to indicate a "like", and clicks again to "unlike" it. Currently I do that like this: try { -- like $stm1 = $db_conn->prepare("INSERT into votes (post_id, user_id) VALUES (?, ?)"); $stm1->execute(array($post_id,...
There is a nice algorithm to randomly choose an element from a list in a single pass: Pass through the list keeping the element chosen so far (X) and the number of elements processed (N). When processing element Y, let X:=Y with probability 1/N. When nothing is left, return X. I implemented this using templates: templa...
I recently published a JavaScript module for NPM which is also available on Github by the name of rawiki-parse-csv. The code takes raw CSV data and returns an array. The method has one option to include the first line as a header in which case an object is returned within the array. If the option is not set each line w...
It is a basic calculator where the user inputs two numbers, and an operation and the program makes it into an equation and gets the answer. For example, if the user enters number 2 number 3 and tells it to multiply, it will display the answer as 6. I just want to know how this could be improved. Could I have used loo...
I was learning backtracking algorithms earlier today, and was excited and wrote this code for n-Queens problem. Being my first try at backtracking algorithms, I would appreciate if you guys could chip in some suggestions/flaws in my code. Also, I had a really tough time getting this to work - I struggled mainly in tryi...
I had the task to write a Lotto simulator. My program works as follows: To start, the user can type in 6 numbers. Then the winning numbers are randomly chosen. The program then shows the winning numbers followed by the numbers the user chose at the beginning. Finally, the user has the option if he wants to play again,...
The goal was to create a tool to help manage folders structures, and allow me to create templates of this folders and store them as a JSON template. The following functionalities have been implemented: Make a copy of a directory tree (folders only). Create a JSON template of the directory tree. Create a directory tree...
I've been preparing for interviews and picking up modern C++. A recent prep question I did was to find all combinations (or distinct subsets) of letters from a string. E.g. 'AA2'-> {'A', '2', 'A2', 'AA2'}. Note that the order doesn't matter. I would like feedback both on the approach and on use of C++ style/best pra...
The following code generates Diffusion Limited Aggregates on a two-dimensional square lattice. Some of the code has been omitted (e.g. support for differing lattice types and dimensions) for code-length reasons and due to the fact that the key thing here is optimisation improvement suggestions. The full code is on GitH...
I would like some feedback to the code I wrote for the card game War. While programming it, I wanted to make classes that I could easily use for other card games too (hence why some functions are actually unused). from random import shuffle import time class card: def __init__(self, suit, rank): self.suit ...
As the title says, simple quicksort to help myself get used to C++ templates and iterators. Main concern is whether there's a better way to template so that you can have a simple function (e.g. quicksort) that accepts any container type (specifically should I have some kind of assert or more complicated template to ma...
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see The Genetic Code. The repository with all my up-to-date solutions so far can be found here. Problem: HAMM Given two strings \$s\$ and \$t\$ of equal length, the Hamming distance between \$s\$ and \$t\$, de...
Sita shortlists 4 gifts priced at r1, r2, r3 and r4 respectively. She wants to buy 3 of these gifts such that it doesn't exceed her budget of x. Input and Output Format: Input consists of 5 integers that correspond to r1, r2, r3, r4 and x. Output consists of 2 integers. The first integer corresponds to the min...
In my ongoing attempts to become a better blog writer I have some written some more code that needs reviewing. Full Source: https://github.com/Loki-Astari/Examples/tree/master/Version3 First Article: http://lokiastari.com/posts/SocketProtocols/ This is an extension to my previous work on Sockets and wraps the socket in...
I was wondering if someone could quickly skim over this for me really quickly and tell me if there's anything I could improve code-wise. What I have right now seems pretty big and clustered, and I'm almost positive that there's a way it can be compressed and made more efficient, and maybe even faster. I'm also hopeful ...
I have written a string parser that is designed to split a string by spaces, excluding spaces wrapped in strings. Here is some example inputs and outputs: | Rule | Input | Output | |------|-------------------------------|-----------------------------------| | 1 | 'f...
This question has the tuple_selection_sort<> template that sorts the variadic template of a tuple using a comparator (any template taking two types that has a value data member of type bool). If the following tuple... // sizeof: 1, 4, 1, 8, 1, 4 std::tuple<char, int, char, double, char, float> Is s...
My focus was to have clean, structured code. It has to be efficient. The display doesn't have to look that good. The circles do overlap and sometimes the word doesn't fit inside the circle, but those are problems aren't really my concern right now and I will fix later. circle.py import pygame import random # Define th...
I've written a model for an app that generates math facts kids have to solve by evaluating the operation and the difficulty you pass to it at initialization. I don't like how I am repeating the code that performs the operations. For instance, performAddition() and performMultiplication() both perform the same thing. Ho...
I have made this code as my summers vacation project in Turbo C++ (I know its old and outdated, but that's what they teach us in our school). The code allows users to order different pizzas and even create them using ingredients they like. After that the pricing is displayed based on the amount and serving of the ingre...
In my ongoing attempts to become a better blog writer I have some written some more code that needs reviewing. Full Source: https://github.com/Loki-Astari/Examples/tree/master/Version4 First Article: http://lokiastari.com/posts/SocketProtocols/ This code replaces the hand written socket code with a libcurl wrapper. #in...
I made a bunch of functions and an enumeration, that together allow me to write something like a switch expression. It's not as powerful as Swift switch statements, since it's lacking pattern matching and I don't intend to use this in real code, it was just an experiment. Here is what I got: enum Caze<T: ForwardIndexTy...
Please note: An updated solution is here Let’s imagine that we designed more or less universal firmware for a microcontroller unit to be used across multiple types of devices. So we have something common in the binary data exchange protocol, and something different. The most common way to define incoming command pars...
This is part of a larger working system which I'm now trying to clean up. In the interests of making the system more test-able I'm splitting up the functions which can be split, but this 100-line function is messing me up. Short overview, this takes 5 inputs:- matchedslots - A list of 4 times (nearest-match actual rep...
I needed a better string formatting options like ToUpper and ToLower but I also wanted to be able to use the default formattings so I created a custom formatter. It's main purpose is to support a template engine where the user should be able to use different formattings like upper or lower case. I still however couldn'...
I had to write an algorithm that prints the partitions of a natural number in lexicographic order. Example of I/O: If the algorithm reads from partitiinumar.in.txt n=5 In partitiinumar.out.txt we should have: 1 1 1 1 1 1 1 1 2 1 1 3 1 2 2 1 4 2 3 5 The problem is that I have a time limit for the execution of the al...
When opening a rtc-stream a thread should always grab the newest picture because otherwise there would be a huge buffer with "old" pictures. Also a call from getMatFromStream() should never return the same picture. If there was no new picture it should wait till a new one is available. package apclient.model; import o...
I have a web application where I list files in the UI to many users at the same time. There are many people who monitor the files and process them. However, I don't want multiple users processing the same file. I am using simple memcache dictionary as data structure to interpret if it is locked. If the key "filename" i...